aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2read.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2019-03-27 13:21:24 -0600
committerTom Tromey <tromey@adacore.com>2019-04-01 10:36:58 -0600
commit05caa1d236440cd8967f8804be8dbcf27fb490b6 (patch)
treebe5a159d7aa6d8d434c51aac2951495455e55ffc /gdb/dwarf2read.c
parent9d1447e09d4aa673826039321163b5a684e8e043 (diff)
downloadgdb-05caa1d236440cd8967f8804be8dbcf27fb490b6.zip
gdb-05caa1d236440cd8967f8804be8dbcf27fb490b6.tar.gz
gdb-05caa1d236440cd8967f8804be8dbcf27fb490b6.tar.bz2
Handle DW_AT_ranges when reading partial symtabs
add_partial_subprogram does not handle DW_AT_ranges, while the full symtab reader does. This can lead to discrepancies where a function is not put into a partial symtab, and so is not available to "break" and the like -- but is available if the full symtab has somehow been read. This patch fixes the bug by arranging to read DW_AT_ranges when reading partial DIEs. This is PR symtab/23331. The new test case is derived from dw2-ranges-func.exp, which is why I kept the copyright dates. gdb/ChangeLog 2019-04-01 Tom Tromey <tromey@adacore.com> PR symtab/23331: * dwarf2read.c (partial_die_info::read): Handle DW_AT_ranges. gdb/testsuite/ChangeLog 2019-04-01 Tom Tromey <tromey@adacore.com> PR symtab/23331: * gdb.dwarf2/dw2-ranges-main.c: New file. * gdb.dwarf2/dw2-ranges-psym.c: New file. * gdb.dwarf2/dw2-ranges-psym.exp: New file.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r--gdb/dwarf2read.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 658c862..a5e953b 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -18751,6 +18751,25 @@ partial_die_info::read (const struct die_reader_specs *reader,
main_subprogram = DW_UNSND (&attr);
break;
+ case DW_AT_ranges:
+ {
+ /* It would be nice to reuse dwarf2_get_pc_bounds here,
+ but that requires a full DIE, so instead we just
+ reimplement it. */
+ int need_ranges_base = tag != DW_TAG_compile_unit;
+ unsigned int ranges_offset = (DW_UNSND (&attr)
+ + (need_ranges_base
+ ? cu->ranges_base
+ : 0));
+
+ /* Value of the DW_AT_ranges attribute is the offset in the
+ .debug_ranges section. */
+ if (dwarf2_ranges_read (ranges_offset, &lowpc, &highpc, cu,
+ nullptr))
+ has_pc_info = 1;
+ }
+ break;
+
default:
break;
}