Avoid bad breakpoints with --gc-sections
authorTom Tromey <tromey@adacore.com>
Thu, 13 Jan 2022 16:48:18 +0000 (09:48 -0700)
committerTom Tromey <tromey@adacore.com>
Thu, 20 Jan 2022 14:22:23 +0000 (07:22 -0700)
commit6d263fe46e00afd8af3d609c1afd71d05eaf745e
treed671b8e628da5ec3db2c8641dcf18ae6c3843961
parentdd8a5a84a746df2c9db53f5ac331d2c9b34422b2
Avoid bad breakpoints with --gc-sections

We found a case where --gc-sections can cause gdb to set an invalid
breakpoint.  In the included test case, gdb will set a breakpoint with
two locations, one of which is 0x0.

The code in lnp_state_machine::check_line_address is intended to
filter out this sort of problem, but in this case, the entire CU is
empty, causing unrelocated_lowpc==0x0 -- which circumvents the check.

It seems to me that if a CU is empty like this, then it is ok to
simply ignore the line table, as there won't be any locations anyway.
gdb/dwarf2/read.c
gdb/testsuite/gdb.ada/inline-section-gc.exp [new file with mode: 0644]
gdb/testsuite/gdb.ada/inline-section-gc/callee.adb [new file with mode: 0644]
gdb/testsuite/gdb.ada/inline-section-gc/callee.ads [new file with mode: 0644]
gdb/testsuite/gdb.ada/inline-section-gc/caller.adb [new file with mode: 0644]