diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2011-07-19 20:28:52 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2011-07-19 20:28:52 +0000 |
commit | 918dd9105923fdbf070e5782aed7cd6275caa321 (patch) | |
tree | e83ae92245cfabb66db1bb61baae37973eca1523 /gdb/dwarf2read.c | |
parent | 0e37a63c3cabe0baab792ed4169307ab4cdc791d (diff) | |
download | gdb-918dd9105923fdbf070e5782aed7cd6275caa321.zip gdb-918dd9105923fdbf070e5782aed7cd6275caa321.tar.gz gdb-918dd9105923fdbf070e5782aed7cd6275caa321.tar.bz2 |
gdb/
Fix crash if referenced CU is aged out.
* dwarf2loc.c (per_cu_dwarf_call): New variable back_to, use to for
xfree of block.data.
(indirect_pieced_value): New variable back_to, use to for xfree of
baton.data.
(dwarf2_compile_expr_to_ax): New variable back_to, use to for xfree of
block.data.
* dwarf2read.c (dwarf2_find_base_address): New prototype.
(load_cu): New function from ...
(dw2_do_instantiate_symtab): ... the code here ...
(process_full_comp_unit): ... and here.
(dwarf2_fetch_die_location_block): Call load_cu first. Call xmemdup on
retval.data.
gdb/testsuite/
Fix crash if referenced CU is aged out.
* gdb.dwarf2/dw2-op-call.exp (maintenance set dwarf2 max-cache-age 0):
New.
* gdb.dwarf2/implptr.exp: Likewise.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r-- | gdb/dwarf2read.c | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index da82a2e..a84d356 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -884,6 +884,9 @@ static void dwarf2_locate_sections (bfd *, asection *, void *); static void dwarf2_create_include_psymtab (char *, struct partial_symtab *, struct objfile *); +static void dwarf2_find_base_address (struct die_info *die, + struct dwarf2_cu *cu); + static void dwarf2_build_psymtabs_hard (struct objfile *); static void scan_partial_symbols (struct partial_die_info *, @@ -1788,6 +1791,23 @@ create_quick_file_names_table (unsigned int nr_initial_entries) delete_file_name_entry, xcalloc, xfree); } +/* Read in PER_CU->CU. This function is unrelated to symtabs, symtab would + have to be created afterwards. You should call age_cached_comp_units after + processing PER_CU->CU. dw2_setup must have been already called. */ + +static void +load_cu (struct dwarf2_per_cu_data *per_cu) +{ + if (per_cu->from_debug_types) + read_signatured_type_at_offset (per_cu->objfile, per_cu->offset); + else + load_full_comp_unit (per_cu, per_cu->objfile); + + dwarf2_find_base_address (per_cu->cu->dies, per_cu->cu); + + gdb_assert (per_cu->cu != NULL); +} + /* Read in the symbols for PER_CU. OBJFILE is the objfile from which this CU came. */ @@ -1801,10 +1821,7 @@ dw2_do_instantiate_symtab (struct objfile *objfile, queue_comp_unit (per_cu, objfile); - if (per_cu->from_debug_types) - read_signatured_type_at_offset (objfile, per_cu->offset); - else - load_full_comp_unit (per_cu, objfile); + load_cu (per_cu); process_queue (objfile); @@ -4714,8 +4731,6 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu) cu->list_in_scope = &file_symbols; - dwarf2_find_base_address (cu->dies, cu); - /* Do line number decoding in read_file_scope () */ process_die (cu->dies, cu); @@ -13813,7 +13828,8 @@ follow_die_ref (struct die_info *src_die, struct attribute *attr, } /* Return DWARF block and its CU referenced by OFFSET at PER_CU. Returned - value is intended for DW_OP_call*. */ + value is intended for DW_OP_call*. You must call xfree on returned + dwarf2_locexpr_baton->data. */ struct dwarf2_locexpr_baton dwarf2_fetch_die_location_block (unsigned int offset, @@ -13821,13 +13837,17 @@ dwarf2_fetch_die_location_block (unsigned int offset, CORE_ADDR (*get_frame_pc) (void *baton), void *baton) { - struct dwarf2_cu *cu = per_cu->cu; + struct dwarf2_cu *cu; struct die_info *die; struct attribute *attr; struct dwarf2_locexpr_baton retval; dw2_setup (per_cu->objfile); + if (per_cu->cu == NULL) + load_cu (per_cu); + cu = per_cu->cu; + die = follow_die_offset (offset, &cu); if (!die) error (_("Dwarf Error: Cannot find DIE at 0x%x referenced in module %s"), @@ -13864,6 +13884,12 @@ dwarf2_fetch_die_location_block (unsigned int offset, retval.size = DW_BLOCK (attr)->size; } retval.per_cu = cu->per_cu; + + if (retval.data) + retval.data = xmemdup (retval.data, retval.size, retval.size); + + age_cached_comp_units (); + return retval; } |