Bug 24675

Summary: gdb not loading debug info from .dwo file
Product: gdb Reporter: garyu.shi
Component: gdbAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: simark
Priority: P1    
Version: 8.2.1   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed: 2019-06-29 00:00:00

Description garyu.shi 2019-06-13 02:00:28 UTC
w/o -gsplit-dwarf, gdb can load  debug info from the program compiled w/ -g3

w/ -gsplit-dwarf,  gdb can __NOT__ load  debug info from the .dwo file compiled w/ -g3, such as macro definitions

Is this a known issue?

Bliss,
--gys
Comment 1 garyu.shi 2019-06-13 03:04:03 UTC
gcc (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0

It can be a bug in gcc...
Comment 2 Simon Marchi 2019-06-29 02:26:03 UTC
I see this too, here's a small reproducer:

---
#define NUM_STUFF 18

int main() {
    return NUM_STUFF;
}
---

$ gcc test.c -g3 -O0 -gsplit-dwarf -c && gcc test.o -o test
$ gdb ./test
(gdb) start
Temporary breakpoint 1 at 0x111d: file test.c, line 4.
Starting program: /home/simark/src/babeltrace/src/lib/graph/test 

Temporary breakpoint 1, main () at test.c:4
4	    return NUM_STUFF;
(gdb) p NUM_STUFF
No symbol "NUM_STUFF" in current context.


Without -gsplit-dwarf, NUM_STUFF is printed correctly.
Comment 3 garyu.shi 2019-06-29 23:53:58 UTC
looks gcc does not produce .dwo file properly for .debug_macro.dwo section; gcc uses DW_FORM_GNU_str_index, but use DW_MACRO_define_strp as opcode; the actual operands for DW_MACRO_define_strp are unsigned LEB128, which can't be read by fixed offset.