diff options
author | Tom Tromey <tromey@adacore.com> | 2022-01-13 09:48:18 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2022-01-20 07:22:23 -0700 |
commit | 6d263fe46e00afd8af3d609c1afd71d05eaf745e (patch) | |
tree | d671b8e628da5ec3db2c8641dcf18ae6c3843961 /gdb/dwarf2 | |
parent | dd8a5a84a746df2c9db53f5ac331d2c9b34422b2 (diff) | |
download | gdb-6d263fe46e00afd8af3d609c1afd71d05eaf745e.zip gdb-6d263fe46e00afd8af3d609c1afd71d05eaf745e.tar.gz gdb-6d263fe46e00afd8af3d609c1afd71d05eaf745e.tar.bz2 |
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.
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r-- | gdb/dwarf2/read.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 3fe6c3a..f7cb95b 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -10630,8 +10630,13 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu) /* Decode line number information if present. We do this before processing child DIEs, so that the line header table is available - for DW_AT_decl_file. */ - handle_DW_AT_stmt_list (die, cu, fnd, lowpc); + for DW_AT_decl_file. The PC check is here because, if LOWPC and + HIGHPC are both 0x0, then there won't be any interesting code in + the CU, but a check later on (in + lnp_state_machine::check_line_address) will fail to properly + exclude an entry that was removed via --gc-sections. */ + if (lowpc != highpc) + handle_DW_AT_stmt_list (die, cu, fnd, lowpc); /* Process all dies in compilation unit. */ if (die->child != NULL) |