diff options
author | Tom Tromey <tom@tromey.com> | 2017-10-07 18:23:36 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-10-12 15:39:24 -0600 |
commit | f7b7ed97a23e2bf4a2ec27bef0fe0af55a080a94 (patch) | |
tree | acc18cc6b1f6d80ac75fa05c72204683b2940b03 /gdb/mn10300-tdep.c | |
parent | 04ec7890fccfa5ddd9cc92961a4df58957ca181b (diff) | |
download | gdb-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/mn10300-tdep.c')
-rw-r--r-- | gdb/mn10300-tdep.c | 128 |
1 files changed, 58 insertions, 70 deletions
diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c index 7b21e4f..eadbbb3 100644 --- a/gdb/mn10300-tdep.c +++ b/gdb/mn10300-tdep.c @@ -337,7 +337,7 @@ static void push_reg (pv_t *regs, struct pv_area *stack, int regnum) { regs[E_SP_REGNUM] = pv_add_constant (regs[E_SP_REGNUM], -4); - pv_area_store (stack, regs[E_SP_REGNUM], 4, regs[regnum]); + stack->store (regs[E_SP_REGNUM], 4, regs[regnum]); } /* Translate an "r" register number extracted from an instruction encoding @@ -356,7 +356,7 @@ translate_rreg (int rreg) return E_E0_REGNUM + rreg; } -/* Find saved registers in a 'struct pv_area'; we pass this to pv_area_scan. +/* Find saved registers in a 'struct pv_area'; we pass 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 @@ -386,8 +386,6 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc; int rn; pv_t regs[MN10300_MAX_NUM_REGS]; - struct pv_area *stack; - struct cleanup *back_to; CORE_ADDR after_last_frame_setup_insn = start_pc; int am33_mode = AM33_MODE (gdbarch); @@ -399,16 +397,15 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, regs[rn] = pv_register (rn, 0); result->reg_offset[rn] = 1; } - stack = make_pv_area (E_SP_REGNUM, gdbarch_addr_bit (gdbarch)); - back_to = make_cleanup_free_pv_area (stack); + pv_area stack (E_SP_REGNUM, gdbarch_addr_bit (gdbarch)); - /* The typical call instruction will have saved the return address on the - stack. Space for the return address has already been preallocated in - the caller's frame. It's possible, such as when using -mrelax with gcc - that other registers were saved as well. If this happens, we really - have no chance of deciphering the frame. DWARF info can save the day - when this happens. */ - pv_area_store (stack, regs[E_SP_REGNUM], 4, regs[E_PC_REGNUM]); + /* The typical call instruction will have saved the return address on the + stack. Space for the return address has already been preallocated in + the caller's frame. It's possible, such as when using -mrelax with gcc + that other registers were saved as well. If this happens, we really + have no chance of deciphering the frame. DWARF info can save the day + when this happens. */ + stack.store (regs[E_SP_REGNUM], 4, regs[E_PC_REGNUM]); pc = start_pc; while (pc < limit_pc) @@ -432,42 +429,42 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, if ((save_mask & movm_exreg0_bit) && am33_mode) { - push_reg (regs, stack, E_E2_REGNUM); - push_reg (regs, stack, E_E3_REGNUM); + push_reg (regs, &stack, E_E2_REGNUM); + push_reg (regs, &stack, E_E3_REGNUM); } if ((save_mask & movm_exreg1_bit) && am33_mode) { - push_reg (regs, stack, E_E4_REGNUM); - push_reg (regs, stack, E_E5_REGNUM); - push_reg (regs, stack, E_E6_REGNUM); - push_reg (regs, stack, E_E7_REGNUM); + push_reg (regs, &stack, E_E4_REGNUM); + push_reg (regs, &stack, E_E5_REGNUM); + push_reg (regs, &stack, E_E6_REGNUM); + push_reg (regs, &stack, E_E7_REGNUM); } if ((save_mask & movm_exother_bit) && am33_mode) { - push_reg (regs, stack, E_E0_REGNUM); - push_reg (regs, stack, E_E1_REGNUM); - push_reg (regs, stack, E_MDRQ_REGNUM); - push_reg (regs, stack, E_MCRH_REGNUM); - push_reg (regs, stack, E_MCRL_REGNUM); - push_reg (regs, stack, E_MCVF_REGNUM); + push_reg (regs, &stack, E_E0_REGNUM); + push_reg (regs, &stack, E_E1_REGNUM); + push_reg (regs, &stack, E_MDRQ_REGNUM); + push_reg (regs, &stack, E_MCRH_REGNUM); + push_reg (regs, &stack, E_MCRL_REGNUM); + push_reg (regs, &stack, E_MCVF_REGNUM); } if (save_mask & movm_d2_bit) - push_reg (regs, stack, E_D2_REGNUM); + push_reg (regs, &stack, E_D2_REGNUM); if (save_mask & movm_d3_bit) - push_reg (regs, stack, E_D3_REGNUM); + push_reg (regs, &stack, E_D3_REGNUM); if (save_mask & movm_a2_bit) - push_reg (regs, stack, E_A2_REGNUM); + push_reg (regs, &stack, E_A2_REGNUM); if (save_mask & movm_a3_bit) - push_reg (regs, stack, E_A3_REGNUM); + push_reg (regs, &stack, E_A3_REGNUM); if (save_mask & movm_other_bit) { - push_reg (regs, stack, E_D0_REGNUM); - push_reg (regs, stack, E_D1_REGNUM); - push_reg (regs, stack, E_A0_REGNUM); - push_reg (regs, stack, E_A1_REGNUM); - push_reg (regs, stack, E_MDR_REGNUM); - push_reg (regs, stack, E_LIR_REGNUM); - push_reg (regs, stack, E_LAR_REGNUM); + push_reg (regs, &stack, E_D0_REGNUM); + push_reg (regs, &stack, E_D1_REGNUM); + push_reg (regs, &stack, E_A0_REGNUM); + push_reg (regs, &stack, E_A1_REGNUM); + push_reg (regs, &stack, E_MDR_REGNUM); + push_reg (regs, &stack, E_LIR_REGNUM); + push_reg (regs, &stack, E_LAR_REGNUM); /* The `other' bit leaves a blank area of four bytes at the beginning of its block of saved registers, making it 32 bytes long in total. */ @@ -653,8 +650,8 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, rN = buf[0] & 0x0f; fsM = (Y << 4) | sM; - pv_area_store (stack, regs[translate_rreg (rN)], 4, - regs[E_FS0_REGNUM + fsM]); + stack.store (regs[translate_rreg (rN)], 4, + regs[E_FS0_REGNUM + fsM]); pc += 3; } @@ -673,8 +670,8 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, sM = (buf[0] & 0xf0) >> 4; fsM = (Y << 4) | sM; - pv_area_store (stack, regs[E_SP_REGNUM], 4, - regs[E_FS0_REGNUM + fsM]); + stack.store (regs[E_SP_REGNUM], 4, + regs[E_FS0_REGNUM + fsM]); pc += 3; } @@ -695,10 +692,9 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, Z = (buf[1] & 0x02) >> 1; fsM = (Z << 4) | sM; - pv_area_store (stack, - pv_add (regs[translate_rreg (rN)], - regs[translate_rreg (rI)]), - 4, regs[E_FS0_REGNUM + fsM]); + stack.store (pv_add (regs[translate_rreg (rN)], + regs[translate_rreg (rI)]), + 4, regs[E_FS0_REGNUM + fsM]); pc += 4; } @@ -720,9 +716,8 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, fsM = (Y << 4) | sM; d8 = extract_signed_integer (&buf[1], 1, byte_order); - pv_area_store (stack, - pv_add_constant (regs[translate_rreg (rN)], d8), - 4, regs[E_FS0_REGNUM + fsM]); + stack.store (pv_add_constant (regs[translate_rreg (rN)], d8), + 4, regs[E_FS0_REGNUM + fsM]); pc += 4; } @@ -744,9 +739,8 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, fsM = (Y << 4) | sM; d24 = extract_signed_integer (&buf[1], 3, byte_order); - pv_area_store (stack, - pv_add_constant (regs[translate_rreg (rN)], d24), - 4, regs[E_FS0_REGNUM + fsM]); + stack.store (pv_add_constant (regs[translate_rreg (rN)], d24), + 4, regs[E_FS0_REGNUM + fsM]); pc += 6; } @@ -768,9 +762,8 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, fsM = (Y << 4) | sM; d32 = extract_signed_integer (&buf[1], 4, byte_order); - pv_area_store (stack, - pv_add_constant (regs[translate_rreg (rN)], d32), - 4, regs[E_FS0_REGNUM + fsM]); + stack.store (pv_add_constant (regs[translate_rreg (rN)], d32), + 4, regs[E_FS0_REGNUM + fsM]); pc += 7; } @@ -791,9 +784,8 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, fsM = (Y << 4) | sM; d8 = extract_signed_integer (&buf[1], 1, byte_order); - pv_area_store (stack, - pv_add_constant (regs[E_SP_REGNUM], d8), - 4, regs[E_FS0_REGNUM + fsM]); + stack.store (pv_add_constant (regs[E_SP_REGNUM], d8), + 4, regs[E_FS0_REGNUM + fsM]); pc += 4; } @@ -814,9 +806,8 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, fsM = (Y << 4) | sM; d24 = extract_signed_integer (&buf[1], 3, byte_order); - pv_area_store (stack, - pv_add_constant (regs[E_SP_REGNUM], d24), - 4, regs[E_FS0_REGNUM + fsM]); + stack.store (pv_add_constant (regs[E_SP_REGNUM], d24), + 4, regs[E_FS0_REGNUM + fsM]); pc += 6; } @@ -837,9 +828,8 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, fsM = (Y << 4) | sM; d32 = extract_signed_integer (&buf[1], 4, byte_order); - pv_area_store (stack, - pv_add_constant (regs[E_SP_REGNUM], d32), - 4, regs[E_FS0_REGNUM + fsM]); + stack.store (pv_add_constant (regs[E_SP_REGNUM], d32), + 4, regs[E_FS0_REGNUM + fsM]); pc += 7; } @@ -861,8 +851,8 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, rN_regnum = translate_rreg (rN); - pv_area_store (stack, regs[rN_regnum], 4, - regs[E_FS0_REGNUM + fsM]); + stack.store (regs[rN_regnum], 4, + regs[E_FS0_REGNUM + fsM]); regs[rN_regnum] = pv_add_constant (regs[rN_regnum], 4); pc += 3; @@ -887,7 +877,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, rN_regnum = translate_rreg (rN); - pv_area_store (stack, regs[rN_regnum], 4, regs[E_FS0_REGNUM + fsM]); + stack.store (regs[rN_regnum], 4, regs[E_FS0_REGNUM + fsM]); regs[rN_regnum] = pv_add_constant (regs[rN_regnum], imm8); pc += 4; @@ -912,7 +902,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, rN_regnum = translate_rreg (rN); - pv_area_store (stack, regs[rN_regnum], 4, regs[E_FS0_REGNUM + fsM]); + stack.store (regs[rN_regnum], 4, regs[E_FS0_REGNUM + fsM]); regs[rN_regnum] = pv_add_constant (regs[rN_regnum], imm24); pc += 6; @@ -937,7 +927,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, rN_regnum = translate_rreg (rN); - pv_area_store (stack, regs[rN_regnum], 4, regs[E_FS0_REGNUM + fsM]); + stack.store (regs[rN_regnum], 4, regs[E_FS0_REGNUM + fsM]); regs[rN_regnum] = pv_add_constant (regs[rN_regnum], imm32); pc += 7; @@ -1044,11 +1034,9 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch, } /* Record where all the registers were saved. */ - pv_area_scan (stack, check_for_saved, (void *) result); + stack.scan (check_for_saved, (void *) result); result->prologue_end = after_last_frame_setup_insn; - - do_cleanups (back_to); } /* Function: skip_prologue |