llvm/lldb/test/Shell/SymbolFile/DWARF/x86/unused-inlined-params.test

# RUN: llvm-mc -filetype=obj %S/Inputs/unused-inlined-params.s \
# RUN:         -triple x86_64-pc-linux -o %t.o
# RUN: %lldb %t.o -s %s -o exit | FileCheck %s


# In this test we verify that inlined functions still mention
# all their parameters in `frame variable`, even when those
# parameters were completely optimized away from the concrete
# instance of the inlined function in the debug info.
# The debugger should look up the parameters in the abstract
# origin of the concrete instance.

# Let us check that unused parameters of an inlined function are listed
# at the inlined function entry.
image lookup -v -s break_at_inlined_f_in_main
# CHECK-LABEL: image lookup -v -s break_at_inlined_f_in_main
# CHECK: name = "unused1", type = "void *", valid ranges = <block>, location = <empty>
# CHECK: name = "used", type = "int", valid ranges = <block>, location = [0x0000000000000011, 0x0000000000000014) -> DW_OP_consts +42
# CHECK: name = "unused2", type = "int", valid ranges = <block>, location = <empty>
# CHECK: name = "partial", type = "int", valid ranges = <block>, location = [0x0000000000000011, 0x0000000000000019) -> DW_OP_reg4 RSI
# CHECK: name = "unused3", type = "int", valid ranges = <block>, location = <empty>

# Show variables outsid of the live range of the 'partial' parameter
# and verify that the output is as expected.
image lookup -v -s break_at_inlined_f_in_main_between_printfs
# CHECK-LABEL: image lookup -v -s break_at_inlined_f_in_main_between_printfs
# CHECK: name = "unused1", type = "void *", valid ranges = <block>, location = <empty>
# CHECK: name = "used", type = "int", valid ranges = <block>, location = [0x0000000000000014, 0x000000000000001e) -> DW_OP_reg3 RBX
# CHECK: name = "unused2", type = "int", valid ranges = <block>, location = <empty>
# Note: image lookup does not show variables outside of their
#       location, so |partial| is missing here.
# CHECK-NOT: partial
# CHECK: name = "unused3", type = "int", valid ranges = <block>, location = <empty>

# Check that we show parameters even if all of them are compiled away.
image lookup -v -s  break_at_inlined_g_in_main
# CHECK-LABEL: image lookup -v -s  break_at_inlined_g_in_main
# CHECK: name = "unused", type = "int", valid ranges = <block>, location = <empty>

# Check that even the other inlined instance of f displays the correct
# parameters.
image lookup -v -s  break_at_inlined_f_in_other
# CHECK-LABEL: image lookup -v -s  break_at_inlined_f_in_other
# CHECK: name = "unused1", type = "void *", valid ranges = <block>, location = <empty>
# CHECK: name = "used", type = "int", valid ranges = <block>, location = [0x0000000000000001, 0x000000000000000b) -> DW_OP_consts +1
# CHECK: name = "unused2", type = "int", valid ranges = <block>, location = <empty>
# CHECK: name = "partial", type = "int", valid ranges = <block>, location = [0x0000000000000001, 0x0000000000000006) -> DW_OP_consts +2
# CHECK: name = "unused3", type = "int", valid ranges = <block>, location = <empty>