diff options
author | Tom de Vries <tdevries@suse.de> | 2022-09-17 08:22:32 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2022-09-17 08:22:32 +0200 |
commit | 99d679e7b30ea9a0b6ffcd64e9ba35e43166151b (patch) | |
tree | 5055a9044da2cdf85d999d3c3d5298bae9af5bd1 /gdb/dwarf2 | |
parent | 5e3cecb21acfbdc16f65efc276733efe89f5aa25 (diff) | |
download | gdb-99d679e7b30ea9a0b6ffcd64e9ba35e43166151b.zip gdb-99d679e7b30ea9a0b6ffcd64e9ba35e43166151b.tar.gz gdb-99d679e7b30ea9a0b6ffcd64e9ba35e43166151b.tar.bz2 |
[gdb/symtab] Fix "file index out of range" complaint
With the test-case included in this commit, we run into this FAIL:
...
(gdb) p var^M
During symbol reading: file index out of range^M
$1 = 0^M
(gdb) FAIL: gdb.dwarf2/dw2-no-code-cu.exp: p var with no complaints
...
This is a regression since commit 6d263fe46e0 ("Avoid bad breakpoints with
--gc-sections"), which contains this change in read_file_scope:
...
- handle_DW_AT_stmt_list (die, cu, fnd, lowpc);
+ if (lowpc != highpc)
+ handle_DW_AT_stmt_list (die, cu, fnd, lowpc);
...
The change intends to avoid a problem with a check in
lnp_state_machine::check_line_address, but also prevents the file and dir
tables from being read, which causes the complaint.
Fix the FAIL by reducing the scope of the "lowpc != highpc" condition to the
call to dwarf_decode_lines in handle_DW_AT_stmt_list.
Tested on x86_64-linux.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29561
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r-- | gdb/dwarf2/read.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 0a3c292..ceb1451 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9498,8 +9498,8 @@ find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu) static void handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu, - const file_and_directory &fnd, - CORE_ADDR lowpc) /* ARI: editCase function */ + const file_and_directory &fnd, CORE_ADDR lowpc, + bool have_code) /* ARI: editCase function */ { dwarf2_per_objfile *per_objfile = cu->per_objfile; struct attribute *attr; @@ -9586,7 +9586,12 @@ handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu, gdb_assert (die->tag != DW_TAG_partial_unit); } decode_mapping = (die->tag != DW_TAG_partial_unit); - dwarf_decode_lines (cu->line_header, cu, lowpc, decode_mapping); + /* The have_code 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 (have_code) + dwarf_decode_lines (cu->line_header, cu, lowpc, decode_mapping); } /* Process DW_TAG_compile_unit or DW_TAG_partial_unit. */ @@ -9625,13 +9630,8 @@ 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. 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); + for DW_AT_decl_file. */ + handle_DW_AT_stmt_list (die, cu, fnd, lowpc, lowpc != highpc); /* Process all dies in compilation unit. */ if (die->child != NULL) |