Imagine the following code:
void baz() { } int main() { baz(); return 0; }
When compiling with with -gdwarf-4 -gsplit-dwarf LLDB is able to set the breakpoint correctly:
clang test.cc -g -fno-rtti -c -gdwarf-4 -gsplit-dwarf clang test.o -g -fno-rtti -gdwarf-4 -o test -gsplit-dwarf lldb test (lldb) target create "test" Current executable set to 'test' (x86_64). (lldb) b baz Breakpoint 1: where = test`baz() + 4 at test.cc:4:1, address = 0x0000000000400524
But not when -dwarf-5 is used. It thinks there are 2 locations:
clang test.cc -g -fno-rtti -c -gdwarf-5 -gsplit-dwarf clang test.o -g -fno-rtti -gdwarf-5 -o test -gsplit-dwarf lldb test (lldb) target create "test" Current executable set to 'test' (x86_64). (lldb) b baz Breakpoint 1: 2 locations.
The issue happens because starting from DWARF v5 DW_AT_addr_base attribute should be used
instead of DW_AT_GNU_addr_base. LLDB does not do that and we end up reading the
.debug_addr header as section content (as addresses) instead of skipping it and reading the real addresses.
Then LLDB is unable to match 2 similar locations and thinks they are different.
Use LLDB_INVALID_ADDRESS instead of zero as zero could be a valid base address.