diff options
author | Tom Tromey <tromey@redhat.com> | 2013-05-06 19:44:04 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2013-05-06 19:44:04 +0000 |
commit | b6807d988a28dc2718bae1abba1f28779bc0c3c3 (patch) | |
tree | bb4adece022138ab739318623eec8dce672a03b8 /gdb/dwarf2loc.c | |
parent | 3aef2284c6976e2b497d5e712cf0cedcc14bed58 (diff) | |
download | gdb-b6807d988a28dc2718bae1abba1f28779bc0c3c3.zip gdb-b6807d988a28dc2718bae1abba1f28779bc0c3c3.tar.gz gdb-b6807d988a28dc2718bae1abba1f28779bc0c3c3.tar.bz2 |
* dwarf2loc.c (invalid_synthetic_pointer): Move earlier.
(indirect_pieced_value): Call dwarf2_fetch_constant_bytes
if needed.
* dwarf2loc.h (dwarf2_fetch_constant_bytes): Declare.
* dwarf2read.c (write_constant_as_bytes)
(dwarf2_fetch_constant_bytes): New functions.
gdb/testsuite
* gdb.dwarf2/implptrconst.c: New file.
* gdb.dwarf2/implptrconst.exp: New file.
* lib/dwarf.exp (Dwarf::_nz_quote): New proc.
(Dwarf::_handle_DW_FORM): Handle DW_FORM_block1.
(Dwarf::_location): Handle DW_OP_GNU_implicit_pointer.
Diffstat (limited to 'gdb/dwarf2loc.c')
-rw-r--r-- | gdb/dwarf2loc.c | 54 |
1 files changed, 41 insertions, 13 deletions
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index ab4ecee..9e44096 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -90,6 +90,16 @@ enum debug_loc_kind DEBUG_LOC_INVALID_ENTRY = -2 }; +/* Helper function which throws an error if a synthetic pointer is + invalid. */ + +static void +invalid_synthetic_pointer (void) +{ + error (_("access outside bounds of object " + "referenced via synthetic pointer")); +} + /* Decode the addresses in a non-dwo .debug_loc entry. A pointer to the next byte to examine is returned in *NEW_PTR. The encoded low,high addresses are return in *LOW,*HIGH. @@ -2086,9 +2096,37 @@ indirect_pieced_value (struct value *value) get_frame_address_in_block_wrapper, frame); - return dwarf2_evaluate_loc_desc_full (TYPE_TARGET_TYPE (type), frame, - baton.data, baton.size, baton.per_cu, - piece->v.ptr.offset + byte_offset); + if (baton.data != NULL) + return dwarf2_evaluate_loc_desc_full (TYPE_TARGET_TYPE (type), frame, + baton.data, baton.size, baton.per_cu, + piece->v.ptr.offset + byte_offset); + + { + struct obstack temp_obstack; + struct cleanup *cleanup; + const gdb_byte *bytes; + LONGEST len; + struct value *result; + + obstack_init (&temp_obstack); + cleanup = make_cleanup_obstack_free (&temp_obstack); + + bytes = dwarf2_fetch_constant_bytes (piece->v.ptr.die, c->per_cu, + &temp_obstack, &len); + if (bytes == NULL) + result = allocate_optimized_out_value (TYPE_TARGET_TYPE (type)); + else + { + if (byte_offset < 0 + || byte_offset + TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > len) + invalid_synthetic_pointer (); + bytes += byte_offset; + result = value_from_contents (TYPE_TARGET_TYPE (type), bytes); + } + + do_cleanups (cleanup); + return result; + } } static void * @@ -2134,16 +2172,6 @@ static const struct lval_funcs pieced_value_funcs = { free_pieced_value_closure }; -/* Helper function which throws an error if a synthetic pointer is - invalid. */ - -static void -invalid_synthetic_pointer (void) -{ - error (_("access outside bounds of object " - "referenced via synthetic pointer")); -} - /* Virtual method table for dwarf2_evaluate_loc_desc_full below. */ static const struct dwarf_expr_context_funcs dwarf_expr_ctx_funcs = |