static struct dwarf2_frame_state_reg *
dwarf2_frame_state_copy_regs (struct dwarf2_frame_state_reg_info *rs)
{
- size_t size = rs->num_regs * sizeof (struct dwarf2_frame_state_reg_info);
+ size_t size = rs->num_regs * sizeof (struct dwarf2_frame_state_reg);
struct dwarf2_frame_state_reg *reg;
reg = (struct dwarf2_frame_state_reg *) xmalloc (size);
{
struct dwarf2_frame_state_reg_info *old_rs = fs->regs.prev;
- gdb_assert (old_rs);
-
- xfree (fs->regs.reg);
- fs->regs = *old_rs;
- xfree (old_rs);
+ 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);
+ }
}
break;
case DW_CFA_offset_extended_sf:
insn_ptr = read_uleb128 (insn_ptr, insn_end, ®);
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;
{
/* Pre-initialize the register state REG for register REGNUM. */
void (*init_reg) (struct gdbarch *, int, struct dwarf2_frame_state_reg *);
+
+ /* Check whether the frame preceding NEXT_FRAME will be a signal
+ trampoline. */
+ int (*signal_frame_p) (struct gdbarch *, struct frame_info *);
};
/* Default architecture-specific register state initialization
/* Return a default for the architecture-specific operations. */
static void *
-dwarf2_frame_init (struct gdbarch *gdbarch)
+dwarf2_frame_init (struct obstack *obstack)
{
struct dwarf2_frame_ops *ops;
- ops = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct dwarf2_frame_ops);
+ ops = OBSTACK_ZALLOC (obstack, struct dwarf2_frame_ops);
ops->init_reg = dwarf2_frame_default_init_reg;
return ops;
}
void (*init_reg) (struct gdbarch *, int,
struct dwarf2_frame_state_reg *))
{
- struct dwarf2_frame_ops *ops;
+ struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
- ops = gdbarch_data (gdbarch, dwarf2_frame_data);
ops->init_reg = init_reg;
}
dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
struct dwarf2_frame_state_reg *reg)
{
- struct dwarf2_frame_ops *ops;
+ struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
- ops = gdbarch_data (gdbarch, dwarf2_frame_data);
ops->init_reg (gdbarch, regnum, reg);
}
+
+/* Set the architecture-specific signal trampoline recognition
+ function for GDBARCH to SIGNAL_FRAME_P. */
+
+void
+dwarf2_frame_set_signal_frame_p (struct gdbarch *gdbarch,
+ int (*signal_frame_p) (struct gdbarch *,
+ struct frame_info *))
+{
+ struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
+
+ ops->signal_frame_p = signal_frame_p;
+}
+
+/* Query the architecture-specific signal frame recognizer for
+ NEXT_FRAME. */
+
+static int
+dwarf2_frame_signal_frame_p (struct gdbarch *gdbarch,
+ struct frame_info *next_frame)
+{
+ struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
+
+ if (ops->signal_frame_p == NULL)
+ return 0;
+ return ops->signal_frame_p (gdbarch, next_frame);
+}
\f
struct dwarf2_frame_cache
table. We need a way of iterating through all the valid
DWARF2 register numbers. */
if (fs->regs.reg[column].how == DWARF2_FRAME_REG_UNSPECIFIED)
- complaint (&symfile_complaints,
- "Incomplete CFI data; unspecified registers at 0x%s",
- paddr (fs->pc));
+ {
+ if (cache->reg[regnum].how == DWARF2_FRAME_REG_UNSPECIFIED)
+ complaint (&symfile_complaints, "\
+incomplete CFI data; unspecified registers (e.g., %s) at 0x%s",
+ gdbarch_register_name (gdbarch, regnum),
+ paddr_nz (fs->pc));
+ }
else
cache->reg[regnum] = fs->regs.reg[column];
}
break;
case DWARF2_FRAME_REG_SAVED_REG:
- regnum = DWARF2_REG_TO_REGNUM (cache->reg[regnum].loc.reg);
- frame_register_unwind (next_frame, regnum,
- optimizedp, lvalp, addrp, realnump, valuep);
+ *optimizedp = 0;
+ *lvalp = lval_register;
+ *addrp = 0;
+ *realnump = DWARF2_REG_TO_REGNUM (cache->reg[regnum].loc.reg);
+ if (valuep)
+ frame_unwind_register (next_frame, (*realnump), valuep);
break;
case DWARF2_FRAME_REG_SAVED_EXP:
"undefined"). Code above issues a complaint about this.
Here just fudge the books, assume GCC, and that the value is
more inner on the stack. */
- frame_register_unwind (next_frame, regnum,
- optimizedp, lvalp, addrp, realnump, valuep);
+ *optimizedp = 0;
+ *lvalp = lval_register;
+ *addrp = 0;
+ *realnump = regnum;
+ if (valuep)
+ frame_unwind_register (next_frame, (*realnump), valuep);
break;
case DWARF2_FRAME_REG_SAME_VALUE:
- frame_register_unwind (next_frame, regnum,
- optimizedp, lvalp, addrp, realnump, valuep);
+ *optimizedp = 0;
+ *lvalp = lval_register;
+ *addrp = 0;
+ *realnump = regnum;
+ if (valuep)
+ frame_unwind_register (next_frame, (*realnump), valuep);
break;
case DWARF2_FRAME_REG_CFA:
dwarf2_frame_prev_register
};
+static const struct frame_unwind dwarf2_signal_frame_unwind =
+{
+ SIGTRAMP_FRAME,
+ dwarf2_frame_this_id,
+ dwarf2_frame_prev_register
+};
+
const struct frame_unwind *
dwarf2_frame_sniffer (struct frame_info *next_frame)
{
function. frame_pc_unwind(), for a no-return next function, can
end up returning something past the end of this function's body. */
CORE_ADDR block_addr = frame_unwind_address_in_block (next_frame);
- if (dwarf2_frame_find_fde (&block_addr))
- return &dwarf2_frame_unwind;
+ if (!dwarf2_frame_find_fde (&block_addr))
+ return NULL;
- return NULL;
+ /* On some targets, signal trampolines may have unwind information.
+ We need to recognize them so that we set the frame type
+ correctly. */
+
+ if (dwarf2_frame_signal_frame_p (get_frame_arch (next_frame),
+ next_frame))
+ return &dwarf2_signal_frame_unwind;
+
+ return &dwarf2_frame_unwind;
}
\f
/* 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;
static CORE_ADDR
read_encoded_value (struct comp_unit *unit, unsigned char encoding,
- char *buf, unsigned int *bytes_read_ptr)
+ unsigned char *buf, unsigned int *bytes_read_ptr)
{
int ptr_len = size_of_encoded_value (DW_EH_PE_absptr);
ptrdiff_t offset;
break;
case DW_EH_PE_pcrel:
base = bfd_get_section_vma (unit->bfd, unit->dwarf_frame_section);
- base += (buf - unit->dwarf_frame_buffer);
+ base += ((char *) buf - unit->dwarf_frame_buffer);
break;
case DW_EH_PE_datarel:
base = unit->dbase;
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;
+ offset = (char *) buf - unit->dwarf_frame_buffer;
if ((offset % ptr_len) != 0)
{
*bytes_read_ptr = ptr_len - (offset % ptr_len);
internal_error (__FILE__, __LINE__, "Invalid or unsupported encoding");
}
- if ((encoding & 0x0f) == 0x00)
+ if ((encoding & 0x07) == 0x00)
encoding |= encoding_for_size (ptr_len);
switch (encoding & 0x0f)
{
+ case DW_EH_PE_uleb128:
+ {
+ ULONGEST value;
+ unsigned char *end_buf = buf + (sizeof (value) + 1) * 8 / 7;
+ *bytes_read_ptr += read_uleb128 (buf, end_buf, &value) - buf;
+ return base + value;
+ }
case DW_EH_PE_udata2:
*bytes_read_ptr += 2;
return (base + bfd_get_16 (unit->abfd, (bfd_byte *) buf));
case DW_EH_PE_udata8:
*bytes_read_ptr += 8;
return (base + bfd_get_64 (unit->abfd, (bfd_byte *) buf));
+ case DW_EH_PE_sleb128:
+ {
+ LONGEST value;
+ char *end_buf = buf + (sizeof (value) + 1) * 8 / 7;
+ *bytes_read_ptr += read_sleb128 (buf, end_buf, &value) - buf;
+ return base + value;
+ }
case DW_EH_PE_sdata2:
*bytes_read_ptr += 2;
return (base + bfd_get_signed_16 (unit->abfd, (bfd_byte *) buf));
/* 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;
cie->cie_pointer = cie_pointer;
/* The encoding for FDE's in a normal .debug_frame section
- depends on the target address size as specified in the
- Compilation Unit Header. */
- cie->encoding = encoding_for_size (unit->addr_size);
+ depends on the target address size. */
+ cie->encoding = DW_EH_PE_absptr;
/* Check version number. */
- if (read_1_byte (unit->abfd, buf) != DW_CIE_VERSION)
+ cie_version = read_1_byte (unit->abfd, buf);
+ if (cie_version != 1 && cie_version != 3)
return NULL;
buf += 1;
read_signed_leb128 (unit->abfd, buf, &bytes_read);
buf += bytes_read;
- cie->return_address_register = read_1_byte (unit->abfd, buf);
- buf += 1;
+ 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->saw_z_augmentation = (*augmentation == 'z');
if (cie->saw_z_augmentation)
/* "P" indicates a personality routine in the CIE augmentation. */
else if (*augmentation == 'P')
{
- /* Skip. */
- buf += size_of_encoded_value (*buf++);
+ /* Skip. Avoid indirection since we throw away the result. */
+ unsigned char encoding = (*buf++) & ~DW_EH_PE_indirect;
+ read_encoded_value (unit, encoding, buf, &bytes_read);
+ buf += bytes_read;
augmentation++;
}
/* 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;
unit.dwarf_frame_buffer = dwarf2_read_section (objfile,
dwarf_eh_frame_section);
- unit.dwarf_frame_size
- = bfd_get_section_size_before_reloc (dwarf_eh_frame_section);
+ unit.dwarf_frame_size = bfd_get_section_size (dwarf_eh_frame_section);
unit.dwarf_frame_section = dwarf_eh_frame_section;
/* FIXME: kettenis/20030602: This is the DW_EH_PE_datarel base
unit.cie = NULL;
unit.dwarf_frame_buffer = dwarf2_read_section (objfile,
dwarf_frame_section);
- unit.dwarf_frame_size
- = bfd_get_section_size_before_reloc (dwarf_frame_section);
+ unit.dwarf_frame_size = bfd_get_section_size (dwarf_frame_section);
unit.dwarf_frame_section = dwarf_frame_section;
frame_ptr = unit.dwarf_frame_buffer;
void
_initialize_dwarf2_frame (void)
{
- dwarf2_frame_data = register_gdbarch_data (dwarf2_frame_init);
+ dwarf2_frame_data = gdbarch_data_register_pre_init (dwarf2_frame_init);
dwarf2_frame_objfile_data = register_objfile_data ();
}