* dwarf2expr.c (dwarf2_read_address): Add gdbarch argument.
Call gdbarch_integer_to_address directly instead of converting
to value and back. Update comment.
(execute_stack_op): Update call site.
* dwarf2loc.c (find_location_expression): Likewise.
(locexpr_describe_location): Update
* dwarf2expr.h (struct dwarf_expr_context): Add gdbarch member.
* dwarf2-frame.c (execute_stack_op): Initialize ctx->gdbarch.
* dwarf2loc. (dwarf2_evaluate_loc_desc): Likewise.
(dwarf2_loc_desc_needs_frame): Likewise.
+2008-09-05 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * dwarf2expr.h (dwarf2_read_address): Add gdbarch argument.
+ * dwarf2expr.c (dwarf2_read_address): Add gdbarch argument.
+ Call gdbarch_integer_to_address directly instead of converting
+ to value and back. Update comment.
+ (execute_stack_op): Update call site.
+ * dwarf2loc.c (find_location_expression): Likewise.
+ (locexpr_describe_location): Update
+
+ * dwarf2expr.h (struct dwarf_expr_context): Add gdbarch member.
+ * dwarf2-frame.c (execute_stack_op): Initialize ctx->gdbarch.
+ * dwarf2loc. (dwarf2_evaluate_loc_desc): Likewise.
+ (dwarf2_loc_desc_needs_frame): Likewise.
+
2008-09-05 Ulrich Weigand <uweigand@de.ibm.com>
* breakpoint.h (struct bp_location): Change type of section
CORE_ADDR result;
ctx = new_dwarf_expr_context ();
+ ctx->gdbarch = get_frame_arch (this_frame);
ctx->addr_size = addr_size;
ctx->baton = this_frame;
ctx->read_reg = read_reg;
doesn't extend past BUF_END. */
CORE_ADDR
-dwarf2_read_address (gdb_byte *buf, gdb_byte *buf_end, int addr_size)
+dwarf2_read_address (struct gdbarch *gdbarch, gdb_byte *buf,
+ gdb_byte *buf_end, int addr_size)
{
CORE_ADDR result;
is sufficient for extracting an address. However, some
architectures (e.g. MIPS) use signed addresses and using
extract_unsigned_integer() will not produce a correct
- result. Turning the unsigned integer into a value and then
- decomposing that value as an address will cause
- gdbarch_integer_to_address() to be invoked for those
- architectures which require it. Thus, using value_as_address()
- will produce the correct result for both types of architectures.
-
- One concern regarding the use of values for this purpose is
- efficiency. Obviously, these extra calls will take more time to
- execute and creating a value takes more space, space which will
- have to be garbage collected at a later time. If constructing
- and then decomposing a value for this purpose proves to be too
- inefficient, then gdbarch_integer_to_address() can be called
- directly.
+ result. Make sure we invoke gdbarch_integer_to_address()
+ for those architectures which require it.
The use of `unsigned_address_type' in the code below refers to
the type of buf and has no bearing on the signedness of the
address being returned. */
- result = value_as_address (value_from_longest
- (unsigned_address_type (addr_size),
- extract_unsigned_integer (buf, addr_size)));
- return result;
+ if (gdbarch_integer_to_address_p (gdbarch))
+ return gdbarch_integer_to_address
+ (gdbarch, unsigned_address_type (addr_size), buf);
+
+ return extract_unsigned_integer (buf, addr_size);
}
/* Return the type of an address of size ADDR_SIZE,
break;
case DW_OP_addr:
- result = dwarf2_read_address (op_ptr, op_end, ctx->addr_size);
+ result = dwarf2_read_address (ctx->gdbarch,
+ op_ptr, op_end, ctx->addr_size);
op_ptr += ctx->addr_size;
break;
{
gdb_byte *buf = alloca (ctx->addr_size);
(ctx->read_mem) (ctx->baton, buf, result, ctx->addr_size);
- result = dwarf2_read_address (buf, buf + ctx->addr_size,
+ result = dwarf2_read_address (ctx->gdbarch,
+ buf, buf + ctx->addr_size,
ctx->addr_size);
}
break;
int addr_size = *op_ptr++;
gdb_byte *buf = alloca (addr_size);
(ctx->read_mem) (ctx->baton, buf, result, addr_size);
- result = dwarf2_read_address (buf, buf + addr_size,
+ result = dwarf2_read_address (ctx->gdbarch,
+ buf, buf + addr_size,
addr_size);
}
break;
number of elements allocated to the stack. */
int stack_len, stack_allocated;
+ /* Target architecture to use for address operations. */
+ struct gdbarch *gdbarch;
+
/* Target address size in bytes. */
int addr_size;
gdb_byte *read_uleb128 (gdb_byte *buf, gdb_byte *buf_end, ULONGEST * r);
gdb_byte *read_sleb128 (gdb_byte *buf, gdb_byte *buf_end, LONGEST * r);
-CORE_ADDR dwarf2_read_address (gdb_byte *buf, gdb_byte *buf_end,
- int addr_size);
+CORE_ADDR dwarf2_read_address (struct gdbarch *gdbarch, gdb_byte *buf,
+ gdb_byte *buf_end, int addr_size);
#endif /* dwarf2expr.h */
gdb_byte *loc_ptr, *buf_end;
int length;
struct objfile *objfile = dwarf2_per_cu_objfile (baton->per_cu);
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
unsigned int addr_size = dwarf2_per_cu_addr_size (baton->per_cu);
CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
/* Adjust base_address for relocatable objects. */
while (1)
{
- low = dwarf2_read_address (loc_ptr, buf_end, addr_size);
+ low = dwarf2_read_address (gdbarch, loc_ptr, buf_end, addr_size);
loc_ptr += addr_size;
- high = dwarf2_read_address (loc_ptr, buf_end, addr_size);
+ high = dwarf2_read_address (gdbarch, loc_ptr, buf_end, addr_size);
loc_ptr += addr_size;
/* An end-of-list entry. */
baton.objfile = dwarf2_per_cu_objfile (per_cu);
ctx = new_dwarf_expr_context ();
+ ctx->gdbarch = get_objfile_arch (baton.objfile);
ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
ctx->baton = &baton;
ctx->read_reg = dwarf_expr_read_reg;
baton.needs_frame = 0;
ctx = new_dwarf_expr_context ();
+ ctx->gdbarch = get_objfile_arch (dwarf2_per_cu_objfile (per_cu));
ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
ctx->baton = &baton;
ctx->read_reg = needs_frame_read_reg;
if (dlbaton->data[0] == DW_OP_addr)
{
struct objfile *objfile = dwarf2_per_cu_objfile (dlbaton->per_cu);
- CORE_ADDR offset = dwarf2_read_address (&dlbaton->data[1],
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
+ CORE_ADDR offset = dwarf2_read_address (gdbarch,
+ &dlbaton->data[1],
&dlbaton->data[dlbaton->size - 1],
addr_size);
fprintf_filtered (stream,