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.
This commit is contained in:
parent
04ec7890fc
commit
f7b7ed97a2
13 changed files with 366 additions and 409 deletions
|
@ -1079,11 +1079,11 @@ struct m32c_pv_state
|
|||
static int
|
||||
m32c_pv_push (struct m32c_pv_state *state, pv_t value, int size)
|
||||
{
|
||||
if (pv_area_store_would_trash (state->stack, state->sp))
|
||||
if (state->stack->store_would_trash (state->sp))
|
||||
return 1;
|
||||
|
||||
state->sp = pv_add_constant (state->sp, -size);
|
||||
pv_area_store (state->stack, state->sp, size, value);
|
||||
state->stack->store (state->sp, size, value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1114,7 +1114,7 @@ static pv_t
|
|||
m32c_srcdest_fetch (struct m32c_pv_state *state, struct srcdest loc, int size)
|
||||
{
|
||||
if (loc.kind == srcdest_mem)
|
||||
return pv_area_fetch (state->stack, loc.addr, size);
|
||||
return state->stack->fetch (loc.addr, size);
|
||||
else if (loc.kind == srcdest_partial_reg)
|
||||
return pv_unknown ();
|
||||
else
|
||||
|
@ -1131,9 +1131,9 @@ m32c_srcdest_store (struct m32c_pv_state *state, struct srcdest loc,
|
|||
{
|
||||
if (loc.kind == srcdest_mem)
|
||||
{
|
||||
if (pv_area_store_would_trash (state->stack, loc.addr))
|
||||
if (state->stack->store_would_trash (loc.addr))
|
||||
return 1;
|
||||
pv_area_store (state->stack, loc.addr, size, value);
|
||||
state->stack->store (loc.addr, size, value);
|
||||
}
|
||||
else if (loc.kind == srcdest_partial_reg)
|
||||
*loc.reg = pv_unknown ();
|
||||
|
@ -1350,7 +1350,7 @@ m32c_pv_enter (struct m32c_pv_state *state, int size)
|
|||
/* If simulating this store would require us to forget
|
||||
everything we know about the stack frame in the name of
|
||||
accuracy, it would be better to just quit now. */
|
||||
if (pv_area_store_would_trash (state->stack, state->sp))
|
||||
if (state->stack->store_would_trash (state->sp))
|
||||
return 1;
|
||||
|
||||
if (m32c_pv_push (state, state->fb, tdep->push_addr_bytes))
|
||||
|
@ -1441,7 +1441,7 @@ m32c_is_arg_spill (struct m32c_pv_state *st,
|
|||
return (m32c_is_arg_reg (st, value)
|
||||
&& loc.kind == srcdest_mem
|
||||
&& pv_is_register (loc.addr, tdep->sp->num)
|
||||
&& ! pv_area_find_reg (st->stack, st->arch, value.reg, 0));
|
||||
&& ! st->stack->find_reg (st->arch, value.reg, 0));
|
||||
}
|
||||
|
||||
/* Return non-zero if a store of VALUE to LOC is probably
|
||||
|
@ -1462,7 +1462,7 @@ m32c_is_struct_return (struct m32c_pv_state *st,
|
|||
struct gdbarch_tdep *tdep = gdbarch_tdep (st->arch);
|
||||
|
||||
return (m32c_is_1st_arg_reg (st, value)
|
||||
&& !pv_area_find_reg (st->stack, st->arch, value.reg, 0)
|
||||
&& !st->stack->find_reg (st->arch, value.reg, 0)
|
||||
&& loc.kind == srcdest_reg
|
||||
&& (pv_is_register (*loc.reg, tdep->a0->num)
|
||||
|| pv_is_register (*loc.reg, tdep->a1->num)));
|
||||
|
@ -1493,7 +1493,7 @@ m32c_pushm_is_reg_save (struct m32c_pv_state *st, int src)
|
|||
|
||||
|
||||
/* Function for finding saved registers in a 'struct pv_area'; we pass
|
||||
this to pv_area_scan.
|
||||
this to pv_area::scan.
|
||||
|
||||
If VALUE is a saved register, ADDR says it was saved at a constant
|
||||
offset from the frame base, and SIZE indicates that the whole
|
||||
|
@ -1546,7 +1546,6 @@ m32c_analyze_prologue (struct gdbarch *arch,
|
|||
struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
|
||||
unsigned long mach = gdbarch_bfd_arch_info (arch)->mach;
|
||||
CORE_ADDR after_last_frame_related_insn;
|
||||
struct cleanup *back_to;
|
||||
struct m32c_pv_state st;
|
||||
|
||||
st.arch = arch;
|
||||
|
@ -1560,8 +1559,8 @@ m32c_analyze_prologue (struct gdbarch *arch,
|
|||
st.fb = pv_register (tdep->fb->num, 0);
|
||||
st.sp = pv_register (tdep->sp->num, 0);
|
||||
st.pc = pv_register (tdep->pc->num, 0);
|
||||
st.stack = make_pv_area (tdep->sp->num, gdbarch_addr_bit (arch));
|
||||
back_to = make_cleanup_free_pv_area (st.stack);
|
||||
pv_area stack (tdep->sp->num, gdbarch_addr_bit (arch));
|
||||
st.stack = &stack;
|
||||
|
||||
/* Record that the call instruction has saved the return address on
|
||||
the stack. */
|
||||
|
@ -1812,11 +1811,9 @@ m32c_analyze_prologue (struct gdbarch *arch,
|
|||
prologue->kind = prologue_first_frame;
|
||||
|
||||
/* Record where all the registers were saved. */
|
||||
pv_area_scan (st.stack, check_for_saved, (void *) prologue);
|
||||
st.stack->scan (check_for_saved, (void *) prologue);
|
||||
|
||||
prologue->prologue_end = after_last_frame_related_insn;
|
||||
|
||||
do_cleanups (back_to);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue