aboutsummaryrefslogtreecommitdiff
path: root/gdb/arm-tdep.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-10-07 18:23:36 -0600
committerTom Tromey <tom@tromey.com>2017-10-12 15:39:24 -0600
commitf7b7ed97a23e2bf4a2ec27bef0fe0af55a080a94 (patch)
treeacc18cc6b1f6d80ac75fa05c72204683b2940b03 /gdb/arm-tdep.c
parent04ec7890fccfa5ddd9cc92961a4df58957ca181b (diff)
downloadgdb-f7b7ed97a23e2bf4a2ec27bef0fe0af55a080a94.zip
gdb-f7b7ed97a23e2bf4a2ec27bef0fe0af55a080a94.tar.gz
gdb-f7b7ed97a23e2bf4a2ec27bef0fe0af55a080a94.tar.bz2
C++-ify prologue-value's pv_area
This patch is an initial C++-ification of pv_area, from prologue-value. It turns pv_area into a class with a constructor and destructor; renames the data members; and changes various functions to be member functions. This allows the removal of make_cleanup_free_pv_area. gdb/ChangeLog 2017-10-12 Tom Tromey <tom@tromey.com> * s390-linux-tdep.c (s390_store, s390_load) (s390_check_for_saved, s390_analyze_prologue): Update. * rx-tdep.c (check_for_saved, rx_analyze_prologue): Update. * rl78-tdep.c (rl78_analyze_prologue, check_for_saved): Update. * prologue-value.h (class pv_area): Move from prologue-value.c. Change names of members. Add constructor, destructor, member functions. (make_pv_area, free_pv_area, make_cleanup_free_pv_area) (pv_area_store, pv_area_fetch, pv_area_store_would_trash) (pv_area_fetch, pv_area_scan): Don't declare. * prologue-value.c (struct pv_area::area_entry): Now member of pv_area. (struct pv_area): Move to prologue-value.h. (pv_area::pv_area): Rename from make_pv_area. (pv_area::~pv_area): Rename from free_pv_area. (do_free_pv_area_cleanup, make_cleanup_free_pv_area): Remove. (clear_entries, find_entry, overlaps, store_would_trash, store) (fetch, find_reg, scan): Now member of pv_area. Remove "area" argument. Update. * msp430-tdep.c (check_for_saved, msp430_analyze_prologue): Update. * mn10300-tdep.c (push_reg, check_for_saved) (mn10300_analyze_prologue): Update. * mep-tdep.c (is_arg_spill, check_for_saved) (mep_analyze_prologue): Update. * m32c-tdep.c (m32c_pv_push, m32c_srcdest_fetch) (m32c_srcdest_store, m32c_pv_enter, m32c_is_arg_spill) (m32c_is_struct_return, m32c_analyze_prologue): Update. * arm-tdep.c (thumb_analyze_prologue, arm_analyze_prologue): Update. * arc-tdep.c (arc_is_in_prologue, arc_analyze_prologue): Update. * aarch64-tdep.c (aarch64_analyze_prologue): Update.
Diffstat (limited to 'gdb/arm-tdep.c')
-rw-r--r--gdb/arm-tdep.c73
1 files changed, 31 insertions, 42 deletions
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index f760b61..960696d 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -647,15 +647,12 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
int i;
pv_t regs[16];
- struct pv_area *stack;
- struct cleanup *back_to;
CORE_ADDR offset;
CORE_ADDR unrecognized_pc = 0;
for (i = 0; i < 16; i++)
regs[i] = pv_register (i, 0);
- stack = make_pv_area (ARM_SP_REGNUM, gdbarch_addr_bit (gdbarch));
- back_to = make_cleanup_free_pv_area (stack);
+ pv_area stack (ARM_SP_REGNUM, gdbarch_addr_bit (gdbarch));
while (start < limit)
{
@@ -668,7 +665,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
int regno;
int mask;
- if (pv_area_store_would_trash (stack, regs[ARM_SP_REGNUM]))
+ if (stack.store_would_trash (regs[ARM_SP_REGNUM]))
break;
/* Bits 0-7 contain a mask for registers R0-R7. Bit 8 says
@@ -681,7 +678,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
{
regs[ARM_SP_REGNUM] = pv_add_constant (regs[ARM_SP_REGNUM],
-4);
- pv_area_store (stack, regs[ARM_SP_REGNUM], 4, regs[regno]);
+ stack.store (regs[ARM_SP_REGNUM], 4, regs[regno]);
}
}
else if ((insn & 0xff80) == 0xb080) /* sub sp, #imm */
@@ -735,10 +732,10 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
offset = (insn & 0xff) << 2;
addr = pv_add_constant (regs[ARM_SP_REGNUM], offset);
- if (pv_area_store_would_trash (stack, addr))
+ if (stack.store_would_trash (addr))
break;
- pv_area_store (stack, addr, 4, regs[regno]);
+ stack.store (addr, 4, regs[regno]);
}
else if ((insn & 0xf800) == 0x6000) /* str rd, [rn, #off] */
{
@@ -749,10 +746,10 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
offset = bits (insn, 6, 10) << 2;
addr = pv_add_constant (regs[rn], offset);
- if (pv_area_store_would_trash (stack, addr))
+ if (stack.store_would_trash (addr))
break;
- pv_area_store (stack, addr, 4, regs[rd]);
+ stack.store (addr, 4, regs[rd]);
}
else if (((insn & 0xf800) == 0x7000 /* strb Rd, [Rn, #off] */
|| (insn & 0xf800) == 0x8000) /* strh Rd, [Rn, #off] */
@@ -828,7 +825,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
pv_t addr = regs[bits (insn, 0, 3)];
int regno;
- if (pv_area_store_would_trash (stack, addr))
+ if (stack.store_would_trash (addr))
break;
/* Calculate offsets of saved registers. */
@@ -836,7 +833,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
if (inst2 & (1 << regno))
{
addr = pv_add_constant (addr, -4);
- pv_area_store (stack, addr, 4, regs[regno]);
+ stack.store (addr, 4, regs[regno]);
}
if (insn & 0x0020)
@@ -857,12 +854,12 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
else
addr = pv_add_constant (addr, -offset);
- if (pv_area_store_would_trash (stack, addr))
+ if (stack.store_would_trash (addr))
break;
- pv_area_store (stack, addr, 4, regs[regno1]);
- pv_area_store (stack, pv_add_constant (addr, 4),
- 4, regs[regno2]);
+ stack.store (addr, 4, regs[regno1]);
+ stack.store (pv_add_constant (addr, 4),
+ 4, regs[regno2]);
if (insn & 0x0020)
regs[bits (insn, 0, 3)] = addr;
@@ -881,10 +878,10 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
else
addr = pv_add_constant (addr, -offset);
- if (pv_area_store_would_trash (stack, addr))
+ if (stack.store_would_trash (addr))
break;
- pv_area_store (stack, addr, 4, regs[regno]);
+ stack.store (addr, 4, regs[regno]);
if (inst2 & 0x0100)
regs[bits (insn, 0, 3)] = addr;
@@ -899,10 +896,10 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
offset = inst2 & 0xfff;
addr = pv_add_constant (regs[bits (insn, 0, 3)], offset);
- if (pv_area_store_would_trash (stack, addr))
+ if (stack.store_would_trash (addr))
break;
- pv_area_store (stack, addr, 4, regs[regno]);
+ stack.store (addr, 4, regs[regno]);
}
else if ((insn & 0xffd0) == 0xf880 /* str{bh}.w Rt,[Rn,#imm] */
@@ -1085,10 +1082,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
unrecognized_pc = start;
if (cache == NULL)
- {
- do_cleanups (back_to);
- return unrecognized_pc;
- }
+ return unrecognized_pc;
if (pv_is_register (regs[ARM_FP_REGNUM], ARM_SP_REGNUM))
{
@@ -1110,10 +1104,9 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
}
for (i = 0; i < 16; i++)
- if (pv_area_find_reg (stack, gdbarch, i, &offset))
+ if (stack.find_reg (gdbarch, i, &offset))
cache->saved_regs[i].addr = offset;
- do_cleanups (back_to);
return unrecognized_pc;
}
@@ -1489,8 +1482,6 @@ arm_analyze_prologue (struct gdbarch *gdbarch,
int regno;
CORE_ADDR offset, current_pc;
pv_t regs[ARM_FPS_REGNUM];
- struct pv_area *stack;
- struct cleanup *back_to;
CORE_ADDR unrecognized_pc = 0;
/* Search the prologue looking for instructions that set up the
@@ -1505,8 +1496,7 @@ arm_analyze_prologue (struct gdbarch *gdbarch,
for (regno = 0; regno < ARM_FPS_REGNUM; regno++)
regs[regno] = pv_register (regno, 0);
- stack = make_pv_area (ARM_SP_REGNUM, gdbarch_addr_bit (gdbarch));
- back_to = make_cleanup_free_pv_area (stack);
+ pv_area stack (ARM_SP_REGNUM, gdbarch_addr_bit (gdbarch));
for (current_pc = prologue_start;
current_pc < prologue_end;
@@ -1543,11 +1533,11 @@ arm_analyze_prologue (struct gdbarch *gdbarch,
else if ((insn & 0xffff0fff) == 0xe52d0004) /* str Rd,
[sp, #-4]! */
{
- if (pv_area_store_would_trash (stack, regs[ARM_SP_REGNUM]))
+ if (stack.store_would_trash (regs[ARM_SP_REGNUM]))
break;
regs[ARM_SP_REGNUM] = pv_add_constant (regs[ARM_SP_REGNUM], -4);
- pv_area_store (stack, regs[ARM_SP_REGNUM], 4,
- regs[bits (insn, 12, 15)]);
+ stack.store (regs[ARM_SP_REGNUM], 4,
+ regs[bits (insn, 12, 15)]);
continue;
}
else if ((insn & 0xffff0000) == 0xe92d0000)
@@ -1557,7 +1547,7 @@ arm_analyze_prologue (struct gdbarch *gdbarch,
{
int mask = insn & 0xffff;
- if (pv_area_store_would_trash (stack, regs[ARM_SP_REGNUM]))
+ if (stack.store_would_trash (regs[ARM_SP_REGNUM]))
break;
/* Calculate offsets of saved registers. */
@@ -1566,7 +1556,7 @@ arm_analyze_prologue (struct gdbarch *gdbarch,
{
regs[ARM_SP_REGNUM]
= pv_add_constant (regs[ARM_SP_REGNUM], -4);
- pv_area_store (stack, regs[ARM_SP_REGNUM], 4, regs[regno]);
+ stack.store (regs[ARM_SP_REGNUM], 4, regs[regno]);
}
}
else if ((insn & 0xffff0000) == 0xe54b0000 /* strb rx,[r11,#-n] */
@@ -1608,12 +1598,12 @@ arm_analyze_prologue (struct gdbarch *gdbarch,
[sp, -#c]! */
&& gdbarch_tdep (gdbarch)->have_fpa_registers)
{
- if (pv_area_store_would_trash (stack, regs[ARM_SP_REGNUM]))
+ if (stack.store_would_trash (regs[ARM_SP_REGNUM]))
break;
regs[ARM_SP_REGNUM] = pv_add_constant (regs[ARM_SP_REGNUM], -12);
regno = ARM_F0_REGNUM + ((insn >> 12) & 0x07);
- pv_area_store (stack, regs[ARM_SP_REGNUM], 12, regs[regno]);
+ stack.store (regs[ARM_SP_REGNUM], 12, regs[regno]);
}
else if ((insn & 0xffbf0fff) == 0xec2d0200 /* sfmfd f0, 4,
[sp!] */
@@ -1622,7 +1612,7 @@ arm_analyze_prologue (struct gdbarch *gdbarch,
int n_saved_fp_regs;
unsigned int fp_start_reg, fp_bound_reg;
- if (pv_area_store_would_trash (stack, regs[ARM_SP_REGNUM]))
+ if (stack.store_would_trash (regs[ARM_SP_REGNUM]))
break;
if ((insn & 0x800) == 0x800) /* N0 is set */
@@ -1645,8 +1635,8 @@ arm_analyze_prologue (struct gdbarch *gdbarch,
for (; fp_start_reg < fp_bound_reg; fp_start_reg++)
{
regs[ARM_SP_REGNUM] = pv_add_constant (regs[ARM_SP_REGNUM], -12);
- pv_area_store (stack, regs[ARM_SP_REGNUM], 12,
- regs[fp_start_reg++]);
+ stack.store (regs[ARM_SP_REGNUM], 12,
+ regs[fp_start_reg++]);
}
}
else if ((insn & 0xff000000) == 0xeb000000 && cache == NULL) /* bl */
@@ -1726,7 +1716,7 @@ arm_analyze_prologue (struct gdbarch *gdbarch,
cache->framesize = framesize;
for (regno = 0; regno < ARM_FPS_REGNUM; regno++)
- if (pv_area_find_reg (stack, gdbarch, regno, &offset))
+ if (stack.find_reg (gdbarch, regno, &offset))
cache->saved_regs[regno].addr = offset;
}
@@ -1734,7 +1724,6 @@ arm_analyze_prologue (struct gdbarch *gdbarch,
fprintf_unfiltered (gdb_stdlog, "Prologue scan stopped at %s\n",
paddress (gdbarch, unrecognized_pc));
- do_cleanups (back_to);
return unrecognized_pc;
}