aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2expr.c
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2008-03-18 19:40:47 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2008-03-18 19:40:47 +0000
commitae0d2f24fd27f8510e4b6703293f7e9b4dafa805 (patch)
tree4b058ddaa3adb544c0a1f7a20f06a5b8f208f3a0 /gdb/dwarf2expr.c
parent188e2ff3a5ded6200f709798d66421fc7535447d (diff)
downloadfsf-binutils-gdb-ae0d2f24fd27f8510e4b6703293f7e9b4dafa805.zip
fsf-binutils-gdb-ae0d2f24fd27f8510e4b6703293f7e9b4dafa805.tar.gz
fsf-binutils-gdb-ae0d2f24fd27f8510e4b6703293f7e9b4dafa805.tar.bz2
2008-03-18 Ulrich Weigand <uweigand@de.ibm.com>
Jim Blandy <jimb@codesourcery.com> Daniel Jacobowitz <drow@false.org> * dwarf2expr.h (struct dwarf_expr_context): Add ADDR_SIZE member. (dwarf2_read_address): Update prototype. * dwarf2expr.c (unsigned_address_type): Add ADDR_SIZE parameter. (signed_address_type): Likewise. (dwarf2_read_address): Replace BYTES_READ parameter with ADDR_SIZE. (execute_stack_op): Update calls to unsigned_address_type, signed_address_type and dwarf2_read_address. Fix implementation of DW_OP_deref_size. * dwarf2loc.h (dwarf2_per_cu_objfile): Add prototype. (dwarf2_per_cu_addr_size): Likewise. (struct dwarf2_locexpr_baton): Replace OBJFILE with PER_CU. (struct dwarf2_loclist_baton): Likewise. * dwarf2loc.c (find_location_expression): Update calls to dwarf2_read_address. Use dwarf2_per_cu_objfile and dwarf2_per_cu_addr_size to retrieve PER_CU parameters. (locexpr_describe_location): Likewise. (dwarf2_evaluate_loc_desc): Replace OBJFILE with PER_CU parameter. Set ctx->addr_size to dwarf2_per_cu_addr_size (per_cu). (dwarf2_loc_desc_needs_frame): Add PER_CU parameter. Set ctx->addr_size to dwarf2_per_cu_addr_size (per_cu). (locexpr_read_variable): Update dwarf2_evaluate_loc_desc call. (loclist_read_variable): Likewise. (locexpr_read_needs_frame): Update dwarf2_loc_desc_needs_frame call. * dwarf2read.c (dwarf2_symbol_mark_computed): Set baton->per_cu instead of baton->objfile. (dwarf2_per_cu_obfile): New function. (dwarf2_per_cu_addr_size): Likewise. * dwarf2-frame.c (struct comp_unit): Move higher. (struct dwarf2_cie): Add UNIT and ADDR_SIZE members. (execute_stack_op): Add ADDR_SIZE parameter; set ctx->addr_size. (execute_cfa_program): Add FDE parameter. Replace EH_FRAME_P parameter by using fde->eh_frame_p. Use read_encoded_value to implement DW_CFA_set_loc. (struct dwarf2_frame_cache): Add ADDR_SIZE member. (dwarf2_frame_cache): Set cache->addr_size. Update calls to execute_stack_op and execute_cfa_program. (dwarf2_frame_prev_register): Update calls to execute_stack_op. (size_of_encoded_value): Remove. (read_encoded_value): Add PTR_LEN and FUNC_BASE parameters. Remove call to size_of_encoded_value. Implement DW_EH_PE_funcrel. (add_cie): Set cie->unit backlink. (decode_frame_entry_1): Set cie->addr_size. Update calls to read_encoded_value. (dwarf2_build_frame_info): Allocate UNIT on objfile obstack.
Diffstat (limited to 'gdb/dwarf2expr.c')
-rw-r--r--gdb/dwarf2expr.c81
1 files changed, 32 insertions, 49 deletions
diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c
index 1102cf0..a099878 100644
--- a/gdb/dwarf2expr.c
+++ b/gdb/dwarf2expr.c
@@ -32,7 +32,7 @@
static void execute_stack_op (struct dwarf_expr_context *,
gdb_byte *, gdb_byte *);
-static struct type *unsigned_address_type (void);
+static struct type *unsigned_address_type (int);
/* Create a new context for the expression evaluator. */
@@ -192,20 +192,17 @@ read_sleb128 (gdb_byte *buf, gdb_byte *buf_end, LONGEST * r)
return buf;
}
-/* Read an address from BUF, and verify that it doesn't extend past
- BUF_END. The address is returned, and *BYTES_READ is set to the
- number of bytes read from BUF. */
+/* Read an address of size ADDR_SIZE from BUF, and verify that it
+ doesn't extend past BUF_END. */
CORE_ADDR
-dwarf2_read_address (gdb_byte *buf, gdb_byte *buf_end, int *bytes_read)
+dwarf2_read_address (gdb_byte *buf, gdb_byte *buf_end, int addr_size)
{
CORE_ADDR result;
- if (buf_end - buf < gdbarch_addr_bit (current_gdbarch) / TARGET_CHAR_BIT)
+ if (buf_end - buf < addr_size)
error (_("dwarf2_read_address: Corrupted DWARF expression."));
- *bytes_read = gdbarch_addr_bit (current_gdbarch) / TARGET_CHAR_BIT;
-
/* For most architectures, calling extract_unsigned_integer() alone
is sufficient for extracting an address. However, some
architectures (e.g. MIPS) use signed addresses and using
@@ -229,21 +226,18 @@ dwarf2_read_address (gdb_byte *buf, gdb_byte *buf_end, int *bytes_read)
address being returned. */
result = value_as_address (value_from_longest
- (unsigned_address_type (),
- extract_unsigned_integer
- (buf,
- gdbarch_addr_bit (current_gdbarch)
- / TARGET_CHAR_BIT)));
-
+ (unsigned_address_type (addr_size),
+ extract_unsigned_integer (buf, addr_size)));
return result;
}
-/* Return the type of an address, for unsigned arithmetic. */
+/* Return the type of an address of size ADDR_SIZE,
+ for unsigned arithmetic. */
static struct type *
-unsigned_address_type (void)
+unsigned_address_type (int addr_size)
{
- switch (gdbarch_addr_bit (current_gdbarch) / TARGET_CHAR_BIT)
+ switch (addr_size)
{
case 2:
return builtin_type_uint16;
@@ -257,12 +251,13 @@ unsigned_address_type (void)
}
}
-/* Return the type of an address, for signed arithmetic. */
+/* Return the type of an address of size ADDR_SIZE,
+ for signed arithmetic. */
static struct type *
-signed_address_type (void)
+signed_address_type (int addr_size)
{
- switch (gdbarch_addr_bit (current_gdbarch) / TARGET_CHAR_BIT)
+ switch (addr_size)
{
case 2:
return builtin_type_int16;
@@ -292,7 +287,6 @@ execute_stack_op (struct dwarf_expr_context *ctx,
CORE_ADDR result;
ULONGEST uoffset, reg;
LONGEST offset;
- int bytes_read;
switch (op)
{
@@ -332,8 +326,8 @@ execute_stack_op (struct dwarf_expr_context *ctx,
break;
case DW_OP_addr:
- result = dwarf2_read_address (op_ptr, op_end, &bytes_read);
- op_ptr += bytes_read;
+ result = dwarf2_read_address (op_ptr, op_end, ctx->addr_size);
+ op_ptr += ctx->addr_size;
break;
case DW_OP_const1u:
@@ -550,34 +544,20 @@ execute_stack_op (struct dwarf_expr_context *ctx,
{
case DW_OP_deref:
{
- gdb_byte *buf = alloca (gdbarch_addr_bit (current_gdbarch)
- / TARGET_CHAR_BIT);
- int bytes_read;
-
- (ctx->read_mem) (ctx->baton, buf, result,
- gdbarch_addr_bit (current_gdbarch)
- / TARGET_CHAR_BIT);
- result = dwarf2_read_address (buf,
- buf + (gdbarch_addr_bit
- (current_gdbarch)
- / TARGET_CHAR_BIT),
- &bytes_read);
+ 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,
+ ctx->addr_size);
}
break;
case DW_OP_deref_size:
{
- gdb_byte *buf
- = alloca (gdbarch_addr_bit (current_gdbarch)
- / TARGET_CHAR_BIT);
- int bytes_read;
-
- (ctx->read_mem) (ctx->baton, buf, result, *op_ptr++);
- result = dwarf2_read_address (buf,
- buf + (gdbarch_addr_bit
- (current_gdbarch)
- / TARGET_CHAR_BIT),
- &bytes_read);
+ 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,
+ addr_size);
}
break;
@@ -628,8 +608,10 @@ execute_stack_op (struct dwarf_expr_context *ctx,
first = dwarf_expr_fetch (ctx, 0);
dwarf_expr_pop (ctx);
- val1 = value_from_longest (unsigned_address_type (), first);
- val2 = value_from_longest (unsigned_address_type (), second);
+ val1 = value_from_longest
+ (unsigned_address_type (ctx->addr_size), first);
+ val2 = value_from_longest
+ (unsigned_address_type (ctx->addr_size), second);
switch (op)
{
@@ -662,7 +644,8 @@ execute_stack_op (struct dwarf_expr_context *ctx,
break;
case DW_OP_shra:
binop = BINOP_RSH;
- val1 = value_from_longest (signed_address_type (), first);
+ val1 = value_from_longest
+ (signed_address_type (ctx->addr_size), first);
break;
case DW_OP_xor:
binop = BINOP_BITWISE_XOR;