/* Frame unwinder for frames with DWARF Call Frame Information.
- Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
Contributed by Mark Kettenis.
_("Support for DW_OP_GNU_push_tls_address is unimplemented"));
}
+/* Execute the required actions for both the DW_CFA_restore and
+DW_CFA_restore_extended instructions. */
+static void
+dwarf2_restore_rule (struct gdbarch *gdbarch, ULONGEST reg_num,
+ struct dwarf2_frame_state *fs, int eh_frame_p)
+{
+ ULONGEST reg;
+
+ gdb_assert (fs->initial.reg);
+ reg = dwarf2_frame_adjust_regnum (gdbarch, reg_num, eh_frame_p);
+ dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
+
+ /* Check if this register was explicitly initialized in the
+ CIE initial instructions. If not, default the rule to
+ UNSPECIFIED. */
+ if (reg < fs->initial.num_regs)
+ fs->regs.reg[reg] = fs->initial.reg[reg];
+ else
+ fs->regs.reg[reg].how = DWARF2_FRAME_REG_UNSPECIFIED;
+
+ if (fs->regs.reg[reg].how == DWARF2_FRAME_REG_UNSPECIFIED)
+ complaint (&symfile_complaints, _("\
+incomplete CFI data; DW_CFA_restore unspecified\n\
+register %s (#%d) at 0x%s"),
+ gdbarch_register_name
+ (gdbarch, gdbarch_dwarf2_reg_to_regnum (gdbarch, reg)),
+ gdbarch_dwarf2_reg_to_regnum (gdbarch, reg),
+ paddr (fs->pc));
+}
+
static CORE_ADDR
execute_stack_op (gdb_byte *exp, ULONGEST len,
struct frame_info *next_frame, CORE_ADDR initial)
}
else if ((insn & 0xc0) == DW_CFA_restore)
{
- gdb_assert (fs->initial.reg);
reg = insn & 0x3f;
- reg = dwarf2_frame_adjust_regnum (gdbarch, reg, eh_frame_p);
- dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
- if (reg < fs->initial.num_regs)
- fs->regs.reg[reg] = fs->initial.reg[reg];
- else
- fs->regs.reg[reg].how = DWARF2_FRAME_REG_UNSPECIFIED;
-
- if (fs->regs.reg[reg].how == DWARF2_FRAME_REG_UNSPECIFIED)
- complaint (&symfile_complaints, _("\
-incomplete CFI data; DW_CFA_restore unspecified\n\
-register %s (#%d) at 0x%s"),
- gdbarch_register_name
- (gdbarch, gdbarch_dwarf2_reg_to_regnum (gdbarch, reg)),
- gdbarch_dwarf2_reg_to_regnum (gdbarch, reg),
- paddr (fs->pc));
+ dwarf2_restore_rule (gdbarch, reg, fs, eh_frame_p);
}
else
{
break;
case DW_CFA_restore_extended:
- gdb_assert (fs->initial.reg);
insn_ptr = read_uleb128 (insn_ptr, insn_end, ®);
- reg = dwarf2_frame_adjust_regnum (gdbarch, reg, eh_frame_p);
- dwarf2_frame_state_alloc_regs (&fs->regs, reg + 1);
- fs->regs.reg[reg] = fs->initial.reg[reg];
+ dwarf2_restore_rule (gdbarch, reg, fs, eh_frame_p);
break;
case DW_CFA_undefined: