summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnu/usr.bin/binutils/gdb/dwarf2-frame.c84
-rw-r--r--gnu/usr.bin/binutils/gdb/dwarf2expr.c44
2 files changed, 42 insertions, 86 deletions
diff --git a/gnu/usr.bin/binutils/gdb/dwarf2-frame.c b/gnu/usr.bin/binutils/gdb/dwarf2-frame.c
index a13e8a14a13..8c624198453 100644
--- a/gnu/usr.bin/binutils/gdb/dwarf2-frame.c
+++ b/gnu/usr.bin/binutils/gdb/dwarf2-frame.c
@@ -372,17 +372,11 @@ execute_cfa_program (unsigned char *insn_ptr, unsigned char *insn_end,
{
struct dwarf2_frame_state_reg_info *old_rs = fs->regs.prev;
- if (old_rs == NULL)
- {
- complaint (&symfile_complaints, "\
-bad CFI data; mismatched DW_CFA_restore_state at 0x%s", paddr (fs->pc));
- }
- else
- {
- xfree (fs->regs.reg);
- fs->regs = *old_rs;
- xfree (old_rs);
- }
+ gdb_assert (old_rs);
+
+ xfree (fs->regs.reg);
+ fs->regs = *old_rs;
+ xfree (old_rs);
}
break;
@@ -426,7 +420,7 @@ bad CFI data; mismatched DW_CFA_restore_state at 0x%s", paddr (fs->pc));
case DW_CFA_offset_extended_sf:
insn_ptr = read_uleb128 (insn_ptr, insn_end, &reg);
insn_ptr = read_sleb128 (insn_ptr, insn_end, &offset);
- offset *= fs->data_align;
+ offset += fs->data_align;
dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
fs->regs.reg[reg].how = DWARF2_FRAME_REG_SAVED_OFFSET;
fs->regs.reg[reg].loc.offset = offset;
@@ -515,15 +509,29 @@ dwarf2_frame_default_init_reg (struct gdbarch *gdbarch, int regnum,
/* Return a default for the architecture-specific operations. */
static void *
-dwarf2_frame_init (struct obstack *obstack)
+dwarf2_frame_init (struct gdbarch *gdbarch)
{
struct dwarf2_frame_ops *ops;
- ops = OBSTACK_ZALLOC (obstack, struct dwarf2_frame_ops);
+ ops = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct dwarf2_frame_ops);
ops->init_reg = dwarf2_frame_default_init_reg;
return ops;
}
+static struct dwarf2_frame_ops *
+dwarf2_frame_ops (struct gdbarch *gdbarch)
+{
+ struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
+ if (ops == NULL)
+ {
+ /* ULGH, called during architecture initialization. Patch
+ things up. */
+ ops = dwarf2_frame_init (gdbarch);
+ set_gdbarch_data (gdbarch, dwarf2_frame_data, ops);
+ }
+ return ops;
+}
+
/* Set the architecture-specific register state initialization
function for GDBARCH to INIT_REG. */
@@ -532,8 +540,9 @@ dwarf2_frame_set_init_reg (struct gdbarch *gdbarch,
void (*init_reg) (struct gdbarch *, int,
struct dwarf2_frame_state_reg *))
{
- struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
+ struct dwarf2_frame_ops *ops;
+ ops = dwarf2_frame_ops (gdbarch);
ops->init_reg = init_reg;
}
@@ -543,8 +552,9 @@ static void
dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
struct dwarf2_frame_state_reg *reg)
{
- struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
+ struct dwarf2_frame_ops *ops;
+ ops = dwarf2_frame_ops (gdbarch);
ops->init_reg (gdbarch, regnum, reg);
}
@@ -890,6 +900,9 @@ struct comp_unit
/* Linked list of CIEs for this object. */
struct dwarf2_cie *cie;
+ /* Address size for this unit - from unit header. */
+ unsigned char addr_size;
+
/* Pointer to the .debug_frame section loaded into memory. */
char *dwarf_frame_buffer;
@@ -1085,14 +1098,6 @@ read_encoded_value (struct comp_unit *unit, unsigned char encoding,
case DW_EH_PE_textrel:
base = unit->tbase;
break;
- case DW_EH_PE_funcrel:
- /* FIXME: kettenis/20040501: For now just pretend
- DW_EH_PE_funcrel is equivalent to DW_EH_PE_absptr. For
- reading the initial location of an FDE it should be treated
- as such, and currently that's the only place where this code
- is used. */
- base = 0;
- break;
case DW_EH_PE_aligned:
base = 0;
offset = buf - unit->dwarf_frame_buffer;
@@ -1106,7 +1111,7 @@ read_encoded_value (struct comp_unit *unit, unsigned char encoding,
internal_error (__FILE__, __LINE__, "Invalid or unsupported encoding");
}
- if ((encoding & 0x07) == 0x00)
+ if ((encoding & 0x0f) == 0x00)
encoding |= encoding_for_size (ptr_len);
switch (encoding & 0x0f)
@@ -1265,7 +1270,6 @@ decode_frame_entry_1 (struct comp_unit *unit, char *start, int eh_frame_p)
/* This is a CIE. */
struct dwarf2_cie *cie;
char *augmentation;
- unsigned int cie_version;
/* Record the offset into the .debug_frame section of this CIE. */
cie_pointer = start - unit->dwarf_frame_buffer;
@@ -1281,12 +1285,12 @@ decode_frame_entry_1 (struct comp_unit *unit, char *start, int eh_frame_p)
cie->cie_pointer = cie_pointer;
/* The encoding for FDE's in a normal .debug_frame section
- depends on the target address size. */
- cie->encoding = DW_EH_PE_absptr;
+ depends on the target address size as specified in the
+ Compilation Unit Header. */
+ cie->encoding = encoding_for_size (unit->addr_size);
/* Check version number. */
- cie_version = read_1_byte (unit->abfd, buf);
- if (cie_version != 1 && cie_version != 3)
+ if (read_1_byte (unit->abfd, buf) != DW_CIE_VERSION)
return NULL;
buf += 1;
@@ -1312,15 +1316,8 @@ decode_frame_entry_1 (struct comp_unit *unit, char *start, int eh_frame_p)
read_signed_leb128 (unit->abfd, buf, &bytes_read);
buf += bytes_read;
- if (cie_version == 1)
- {
- cie->return_address_register = read_1_byte (unit->abfd, buf);
- bytes_read = 1;
- }
- else
- cie->return_address_register = read_unsigned_leb128 (unit->abfd, buf,
- &bytes_read);
- buf += bytes_read;
+ cie->return_address_register = read_1_byte (unit->abfd, buf);
+ buf += 1;
cie->saw_z_augmentation = (*augmentation == 'z');
if (cie->saw_z_augmentation)
@@ -1553,6 +1550,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
/* Build a minimal decoding of the DWARF2 compilation unit. */
unit.abfd = objfile->obfd;
unit.objfile = objfile;
+ unit.addr_size = objfile->obfd->arch_info->bits_per_address / 8;
unit.dbase = 0;
unit.tbase = 0;
@@ -1566,7 +1564,8 @@ dwarf2_build_frame_info (struct objfile *objfile)
unit.dwarf_frame_buffer = dwarf2_read_section (objfile,
dwarf_eh_frame_section);
- unit.dwarf_frame_size = bfd_get_section_size (dwarf_eh_frame_section);
+ unit.dwarf_frame_size
+ = bfd_get_section_size_before_reloc (dwarf_eh_frame_section);
unit.dwarf_frame_section = dwarf_eh_frame_section;
/* FIXME: kettenis/20030602: This is the DW_EH_PE_datarel base
@@ -1593,7 +1592,8 @@ dwarf2_build_frame_info (struct objfile *objfile)
unit.cie = NULL;
unit.dwarf_frame_buffer = dwarf2_read_section (objfile,
dwarf_frame_section);
- unit.dwarf_frame_size = bfd_get_section_size (dwarf_frame_section);
+ unit.dwarf_frame_size
+ = bfd_get_section_size_before_reloc (dwarf_frame_section);
unit.dwarf_frame_section = dwarf_frame_section;
frame_ptr = unit.dwarf_frame_buffer;
@@ -1608,6 +1608,6 @@ void _initialize_dwarf2_frame (void);
void
_initialize_dwarf2_frame (void)
{
- dwarf2_frame_data = gdbarch_data_register_pre_init (dwarf2_frame_init);
+ dwarf2_frame_data = register_gdbarch_data (dwarf2_frame_init);
dwarf2_frame_objfile_data = register_objfile_data ();
}
diff --git a/gnu/usr.bin/binutils/gdb/dwarf2expr.c b/gnu/usr.bin/binutils/gdb/dwarf2expr.c
index a60e5a90e86..50baced5f2e 100644
--- a/gnu/usr.bin/binutils/gdb/dwarf2expr.c
+++ b/gnu/usr.bin/binutils/gdb/dwarf2expr.c
@@ -42,8 +42,6 @@ new_dwarf_expr_context (void)
retval->stack_len = 0;
retval->stack_allocated = 10;
retval->stack = xmalloc (retval->stack_allocated * sizeof (CORE_ADDR));
- retval->num_pieces = 0;
- retval->pieces = 0;
return retval;
}
@@ -53,7 +51,6 @@ void
free_dwarf_expr_context (struct dwarf_expr_context *ctx)
{
xfree (ctx->stack);
- xfree (ctx->pieces);
xfree (ctx);
}
@@ -103,29 +100,6 @@ dwarf_expr_fetch (struct dwarf_expr_context *ctx, int n)
}
-/* Add a new piece to CTX's piece list. */
-static void
-add_piece (struct dwarf_expr_context *ctx,
- int in_reg, CORE_ADDR value, ULONGEST size)
-{
- struct dwarf_expr_piece *p;
-
- ctx->num_pieces++;
-
- if (ctx->pieces)
- ctx->pieces = xrealloc (ctx->pieces,
- (ctx->num_pieces
- * sizeof (struct dwarf_expr_piece)));
- else
- ctx->pieces = xmalloc (ctx->num_pieces
- * sizeof (struct dwarf_expr_piece));
-
- p = &ctx->pieces[ctx->num_pieces - 1];
- p->in_reg = in_reg;
- p->value = value;
- p->size = size;
-}
-
/* Evaluate the expression at ADDR (LEN bytes long) using the context
CTX. */
@@ -601,7 +575,6 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
break;
case DW_OP_div:
binop = BINOP_DIV;
- break;
case DW_OP_minus:
binop = BINOP_SUB;
break;
@@ -622,7 +595,6 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
break;
case DW_OP_shr:
binop = BINOP_RSH;
- break;
case DW_OP_shra:
binop = BINOP_RSH;
val1 = value_from_longest (signed_address_type (), first);
@@ -687,22 +659,6 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
case DW_OP_nop:
goto no_push;
- case DW_OP_piece:
- {
- ULONGEST size;
- CORE_ADDR addr_or_regnum;
-
- /* Record the piece. */
- op_ptr = read_uleb128 (op_ptr, op_end, &size);
- addr_or_regnum = dwarf_expr_fetch (ctx, 0);
- add_piece (ctx, ctx->in_reg, addr_or_regnum, size);
-
- /* Pop off the address/regnum, and clear the in_reg flag. */
- dwarf_expr_pop (ctx);
- ctx->in_reg = 0;
- }
- goto no_push;
-
default:
error ("Unhandled dwarf expression opcode 0x%x", op);
}