Bug 25730

Summary: GDB fails to resolve line numbers if there's no address range information for a CU
Product: gdb Reporter: Angelos Oikonomopoulos <angelos>
Component: symtabAssignee: Not yet assigned to anyone <unassigned>
Status: UNCONFIRMED ---    
Severity: minor    
Priority: P2    
Version: 9.1   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Attachments: Testcase

Description Angelos Oikonomopoulos 2020-03-26 15:36:30 UTC
Created attachment 12406 [details]
Testcase

When a compilation unit doesn't have any of DW_AT_{low,high}_pc or even DW_AT_ranges, find_pc_sect_compunit_symtab will not be able to resolve any PC to it and this results in the line table of the CU not being considered.

Adding a couple of symbols around the top-level inline asm statement works around the issue.

The actual example is from JavaScriptCore, but I've attached a minimal testcase for it, for which you can see the difference in the output below:

$ gdb -q without-markers 
Reading symbols from without-markers...
(gdb) b foo
Breakpoint 1 at 0x1174
(gdb) run
Starting program: without-markers 

Breakpoint 1, 0x0000555555555174 in foo ()

$ gdb -q with-markers 
Reading symbols from with-markers...
(gdb) b foo
Breakpoint 1 at 0x117b: file asm.h, line 17.
(gdb) run
Starting program: with-markers 

Breakpoint 1, foo () at asm.h:17
17      ".loc " STR(SLOT) " " STR(__LINE__) "\n movl    %edi, -4(%rbp)\n"

FWIW, both GCC and clang will generate no address range info for this CU. LLDB finds the line information regardless.