This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfc] [02/12] Get rid of current_gdbarch in arm-tdep.c
- From: Markus Deuling <deuling at de dot ibm dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>, Ulrich Weigand <uweigand at de dot ibm dot com>
- Date: Fri, 03 Aug 2007 14:10:02 +0200
- Subject: [rfc] [02/12] Get rid of current_gdbarch in arm-tdep.c
Hi,
this patch gets rid of some of the current_gdbarch's in arm-tdep.c
Is this ok to commit?
ChangeLog:
* arm-tdep.c (arm_scan_prologue, arm_make_prologue_cache)
(thumb_get_next_pc, arm_get_next_pc, arm_extract_return_value)
(arm_store_return_value): Use FRAME or REGCACHE to recognize current
architecture.
(arm_push_dummy_call, arm_dump_tdep): Replace current_gdbarch by
gdbarch.
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
diff -urpN src/gdb/arm-tdep.c dev/gdb/arm-tdep.c
--- src/gdb/arm-tdep.c 2007-06-20 05:30:29.000000000 +0200
+++ dev/gdb/arm-tdep.c 2007-08-02 09:51:04.000000000 +0200
@@ -650,8 +650,10 @@ thumb_scan_prologue (CORE_ADDR prev_pc,
*/
static void
-arm_scan_prologue (struct frame_info *next_frame, struct arm_prologue_cache *cache)
+arm_scan_prologue (struct frame_info *next_frame,
+ struct arm_prologue_cache *cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (next_frame);
int regno, sp_offset, fp_offset, ip_offset;
CORE_ADDR prologue_start, prologue_end, current_pc;
CORE_ADDR prev_pc = frame_pc_unwind (next_frame);
@@ -725,7 +727,7 @@ arm_scan_prologue (struct frame_info *ne
else
{
prologue_start = gdbarch_addr_bits_remove
- (current_gdbarch, return_value) - 8;
+ (gdbarch, return_value) - 8;
prologue_end = prologue_start + 64; /* See above. */
}
}
@@ -834,14 +836,14 @@ arm_scan_prologue (struct frame_info *ne
sp_offset -= imm;
}
else if ((insn & 0xffff7fff) == 0xed6d0103 /* stfe f?, [sp, -#c]! */
- && gdbarch_tdep (current_gdbarch)->have_fpa_registers)
+ && gdbarch_tdep (gdbarch)->have_fpa_registers)
{
sp_offset -= 12;
regno = ARM_F0_REGNUM + ((insn >> 12) & 0x07);
cache->saved_regs[regno].addr = sp_offset;
}
else if ((insn & 0xffbf0fff) == 0xec2d0200 /* sfmfd f0, 4, [sp!] */
- && gdbarch_tdep (current_gdbarch)->have_fpa_registers)
+ && gdbarch_tdep (gdbarch)->have_fpa_registers)
{
int n_saved_fp_regs;
unsigned int fp_start_reg, fp_bound_reg;
@@ -909,7 +911,7 @@ arm_make_prologue_cache (struct frame_in
/* Calculate actual addresses of saved registers using offsets
determined by arm_scan_prologue. */
- for (reg = 0; reg < gdbarch_num_regs (current_gdbarch); reg++)
+ for (reg = 0; reg < gdbarch_num_regs (get_frame_arch (next_frame)); reg++)
if (trad_frame_addr_p (cache->saved_regs, reg))
cache->saved_regs[reg].addr += cache->prev_sp;
@@ -1212,7 +1214,7 @@ arm_push_dummy_call (struct gdbarch *gdb
{
if (arm_debug)
fprintf_unfiltered (gdb_stdlog, "struct return in %s = 0x%s\n",
- gdbarch_register_name (current_gdbarch, argreg),
+ gdbarch_register_name (gdbarch, argreg),
paddr (struct_addr));
regcache_cooked_write_unsigned (regcache, argreg, struct_addr);
argreg++;
@@ -1289,13 +1291,13 @@ arm_push_dummy_call (struct gdbarch *gdb
/* The argument is being passed in a general purpose
register. */
CORE_ADDR regval = extract_unsigned_integer (val, partial_len);
- if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
regval <<= (INT_REGISTER_SIZE - partial_len) * 8;
if (arm_debug)
fprintf_unfiltered (gdb_stdlog, "arg %d in %s = 0x%s\n",
argnum,
gdbarch_register_name
- (current_gdbarch, argreg),
+ (gdbarch, argreg),
phex (regval, INT_REGISTER_SIZE));
regcache_cooked_write_unsigned (regcache, argreg, regval);
argreg++;
@@ -1613,6 +1615,7 @@ bitcount (unsigned long val)
static CORE_ADDR
thumb_get_next_pc (struct frame_info *frame, CORE_ADDR pc)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
unsigned long pc_val = ((unsigned long) pc) + 4; /* PC after prefetch */
unsigned short inst1 = read_memory_unsigned_integer (pc, 2);
CORE_ADDR nextpc = pc + 2; /* default is next instruction */
@@ -1627,7 +1630,7 @@ thumb_get_next_pc (struct frame_info *fr
offset = bitcount (bits (inst1, 0, 7)) * INT_REGISTER_SIZE;
sp = get_frame_register_unsigned (frame, ARM_SP_REGNUM);
nextpc = (CORE_ADDR) read_memory_unsigned_integer (sp + offset, 4);
- nextpc = gdbarch_addr_bits_remove (current_gdbarch, nextpc);
+ nextpc = gdbarch_addr_bits_remove (gdbarch, nextpc);
if (nextpc == pc)
error (_("Infinite loop detected"));
}
@@ -1658,7 +1661,7 @@ thumb_get_next_pc (struct frame_info *fr
else
nextpc = get_frame_register_unsigned (frame, bits (inst1, 3, 6));
- nextpc = gdbarch_addr_bits_remove (current_gdbarch, nextpc);
+ nextpc = gdbarch_addr_bits_remove (gdbarch, nextpc);
if (nextpc == pc)
error (_("Infinite loop detected"));
}
@@ -1669,6 +1672,7 @@ thumb_get_next_pc (struct frame_info *fr
static CORE_ADDR
arm_get_next_pc (struct frame_info *frame, CORE_ADDR pc)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
unsigned long pc_val;
unsigned long this_instr;
unsigned long status;
@@ -1710,7 +1714,7 @@ arm_get_next_pc (struct frame_info *fram
result = (rn == 15) ? pc_val + 8
: get_frame_register_unsigned (frame, rn);
nextpc = (CORE_ADDR) gdbarch_addr_bits_remove
- (current_gdbarch, result);
+ (gdbarch, result);
if (nextpc == pc)
error (_("Infinite loop detected"));
@@ -1793,7 +1797,7 @@ arm_get_next_pc (struct frame_info *fram
break;
}
nextpc = (CORE_ADDR) gdbarch_addr_bits_remove
- (current_gdbarch, result);
+ (gdbarch, result);
if (nextpc == pc)
error (_("Infinite loop detected"));
@@ -1837,7 +1841,7 @@ arm_get_next_pc (struct frame_info *fram
nextpc = (CORE_ADDR) read_memory_integer ((CORE_ADDR) base,
4);
- nextpc = gdbarch_addr_bits_remove (current_gdbarch, nextpc);
+ nextpc = gdbarch_addr_bits_remove (gdbarch, nextpc);
if (nextpc == pc)
error (_("Infinite loop detected"));
@@ -1876,7 +1880,7 @@ arm_get_next_pc (struct frame_info *fram
4);
}
nextpc = gdbarch_addr_bits_remove
- (current_gdbarch, nextpc);
+ (gdbarch, nextpc);
if (nextpc == pc)
error (_("Infinite loop detected"));
}
@@ -1892,7 +1896,7 @@ arm_get_next_pc (struct frame_info *fram
if (bits (this_instr, 28, 31) == INST_NV)
nextpc |= bit (this_instr, 24) << 1;
- nextpc = gdbarch_addr_bits_remove (current_gdbarch, nextpc);
+ nextpc = gdbarch_addr_bits_remove (gdbarch, nextpc);
if (nextpc == pc)
error (_("Infinite loop detected"));
break;
@@ -2049,7 +2053,7 @@ arm_extract_return_value (struct type *t
{
if (TYPE_CODE_FLT == TYPE_CODE (type))
{
- switch (gdbarch_tdep (current_gdbarch)->fp_model)
+ switch (gdbarch_tdep (get_regcache_arch (regs))->fp_model)
{
case ARM_FLOAT_FPA:
{
@@ -2238,7 +2242,7 @@ arm_store_return_value (struct type *typ
{
char buf[MAX_REGISTER_SIZE];
- switch (gdbarch_tdep (current_gdbarch)->fp_model)
+ switch (gdbarch_tdep (get_regcache_arch (regs))->fp_model)
{
case ARM_FLOAT_FPA:
@@ -3029,9 +3033,9 @@ arm_gdbarch_init (struct gdbarch_info in
}
static void
-arm_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file)
+arm_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
if (tdep == NULL)
return;