https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91536
Bug ID: 91536 Summary: gcc generates invalid DW_OP_GNU_parameter_ref Product: gcc Version: 9.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: robert at ocallahan dot org Target Milestone: --- Compiling the following test program with `gcc -g -O2 -o ~/tmp/test ~/tmp/test.cpp`, `gcc (GCC) 9.1.1 20190503 (Red Hat 9.1.1-1)` volatile char volatile_store; struct X { int field; X() : field(111) {} __attribute__((noinline)) void method() { volatile_store = 2; } }; int main(void) { X x; x.method(); return 0; } gdb can't print `this` in `method`: (gdb) break method Breakpoint 1 at 0x401120: file /home/roc/tmp/test.cpp, line 7. (gdb) run Starting program: /home/roc/tmp/test Breakpoint 1, X::method (this=<optimized out>) at /home/roc/tmp/test.cpp:7 7 volatile_store = 2; gcc has generated a location list for `this` that uses `DW_OP_GNU_parameter_ref`: < 2><0x00000177> DW_TAG_formal_parameter DW_AT_abstract_origin <0x00000127> DW_AT_location <loclist at offset 0x00000055 with 1 entries follows> [ 0]<offset pair low-off: 0x00401120 addr 0x00401120 high-off: 0x00401128 addr 0x00401128>DW_OP_GNU_parameter_ref 0x00000127 DW_OP_stack_value `method`'s return address is 0x401025 in this case, which corresponds to this `DW_TAG_GNU_call_site`: < 2><0x0000010b> DW_TAG_GNU_call_site DW_AT_low_pc 0x00401025 DW_AT_abstract_origin <0x00000160> Unfortunately this `DW_TAG_GNU_call_site` is completely useless because it doesn't have any variables with `DW_AT_GNU_call_site_value`, so no wonder gdb can't find the value of `this`. The subprgoram at 0x160 is not helpful, that's just the subprogram containing the `DW_TAG_formal_parameter` at 0x177. Aside: the DWARF5 spec and the original proposal for `DW_TAG_(GNU_)call_site` (http://www.dwarfstd.org/ShowIssue.php?issue=100909.2 I think) don't list `DW_AT_low_pc` and `DW_AT_abstract_origin` as valid attributes, and thus don't document what they mean here.