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/dwarf2loc.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/dwarf2loc.c')
-rw-r--r-- | gdb/dwarf2loc.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index 9d4aa8d..c29a07c 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -265,14 +265,19 @@ per_cu_dwarf_call (struct dwarf_expr_context *ctx, size_t die_offset, void *baton) { struct dwarf2_locexpr_baton block; + struct cleanup *back_to; block = dwarf2_fetch_die_location_block (die_offset, per_cu, get_frame_pc, baton); + back_to = make_cleanup (xfree, (void *) block.data); + /* DW_OP_call_ref is currently not supported. */ gdb_assert (block.per_cu == per_cu); dwarf_expr_eval (ctx, block.data, block.size); + + do_cleanups (back_to); } /* Helper interface of per_cu_dwarf_call for dwarf2_evaluate_loc_desc. */ @@ -966,6 +971,7 @@ indirect_pieced_value (struct value *value) struct dwarf_expr_piece *piece = NULL; struct value *result; LONGEST byte_offset; + struct cleanup *back_to; type = check_typedef (value_type (value)); if (TYPE_CODE (type) != TYPE_CODE_PTR) @@ -1013,10 +1019,14 @@ indirect_pieced_value (struct value *value) get_frame_address_in_block_wrapper, frame); + back_to = make_cleanup (xfree, (void *) baton.data); + result = dwarf2_evaluate_loc_desc_full (TYPE_TARGET_TYPE (type), frame, baton.data, baton.size, baton.per_cu, byte_offset); + do_cleanups (back_to); + return result; } @@ -2123,12 +2133,14 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, { struct dwarf2_locexpr_baton block; int size = (op == DW_OP_call2 ? 2 : 4); + struct cleanup *back_to; uoffset = extract_unsigned_integer (op_ptr, size, byte_order); op_ptr += size; block = dwarf2_fetch_die_location_block (uoffset, per_cu, get_ax_pc, expr); + back_to = make_cleanup (xfree, (void *) block.data); /* DW_OP_call_ref is currently not supported. */ gdb_assert (block.per_cu == per_cu); @@ -2136,6 +2148,8 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, dwarf2_compile_expr_to_ax (expr, loc, arch, addr_size, block.data, block.data + block.size, per_cu); + + do_cleanups (back_to); } break; |