From ab4352599fd0f57f6247323611120574b70d02ff Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Mon, 10 Dec 2012 22:02:34 +0000 Subject: [PATCH] * dwarf2read.c (dwarf2_cu): Enhance comment. (dwarf2_get_pc_bounds): Only add ranges_base for DIEs that live in the DWO file. (dwarf2_record_block_ranges): Ditto. --- gdb/ChangeLog | 5 +++++ gdb/dwarf2read.c | 23 ++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5f9ef4db5ed..cfbd0a3e748 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2012-12-10 Doug Evans + * dwarf2read.c (dwarf2_cu): Enhance comment. + (dwarf2_get_pc_bounds): Only add ranges_base for DIEs that live in + the DWO file. + (dwarf2_record_block_ranges): Ditto. + * dwarf2read.c (create_dwo_in_dwp): Tweak comment. * symtab.c (find_pc_sect_symtab): Add comment. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 7a1bbc5bf7a..b0f90ffa48a 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -483,7 +483,12 @@ struct dwarf2_cu (zero is a valid value though). Note this value comes from the stub CU/TU's DIE. Also note that the value is zero in the non-DWO case so this value can - be used without needing to know whether DWO files are in use or not. */ + be used without needing to know whether DWO files are in use or not. + N.B. This does not apply to DW_AT_ranges appearing in + DW_TAG_compile_unit dies. This is a bit of a wart, consider if ever + DW_AT_ranges appeared in the DW_TAG_compile_unit of DWO DIEs: then + DW_AT_ranges_base *would* have to be applied, and we'd have to care + whether the DW_AT_ranges attribute came from the skeleton or DWO. */ ULONGEST ranges_base; /* Mark used when releasing cached dies. */ @@ -10056,7 +10061,14 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc, attr = dwarf2_attr (die, DW_AT_ranges, cu); if (attr != NULL) { - unsigned int ranges_offset = DW_UNSND (attr) + cu->ranges_base; + /* DW_AT_ranges_base does not apply to DIEs from the DWO skeleton. + We take advantage of the fact that DW_AT_ranges does not appear + in DW_TAG_compile_unit of DWO files. */ + int need_ranges_base = die->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. */ @@ -10217,10 +10229,15 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block, if (attr) { bfd *obfd = objfile->obfd; + /* DW_AT_ranges_base does not apply to DIEs from the DWO skeleton. + We take advantage of the fact that DW_AT_ranges does not appear + in DW_TAG_compile_unit of DWO files. */ + int need_ranges_base = die->tag != DW_TAG_compile_unit; /* The value of the DW_AT_ranges attribute is the offset of the address range list in the .debug_ranges section. */ - unsigned long offset = DW_UNSND (attr) + cu->ranges_base; + unsigned long offset = (DW_UNSND (attr) + + (need_ranges_base ? cu->ranges_base : 0)); gdb_byte *buffer = dwarf2_per_objfile->ranges.buffer + offset; /* For some target architectures, but not others, the -- 2.30.2