2007-10-10 Markus Deuling <deuling@de.ibm.com>

* rs6000-nat.c (fetch_register, store_register)
	(rs6000_fetch_inferior_registers, rs6000_store_inferior_registers): Use
	get_regcache_arch to get at the current architecture by regcache.

	* rs6000-tdep.c (rs6000_push_dummy_call, rs6000_return_value)
	(rs6000_register_reggroup_p, e500_move_ev_registe, rs6000_unwind_pc)
	(rs6000_unwind_dummy_id, rs6000_frame_cache, rs6000_dump_tdep): Replace
	current_gdbarch by gdbarch.
	(rs6000_skip_trampoline_code, rs6000_register_to_value)
	(rs6000_value_to_register): Use get_frame_arch to get at the current
	architecture by frame_info.
This commit is contained in:
Ulrich Weigand 2007-10-10 17:06:30 +00:00
parent e6d4f032a5
commit 8b164abbfd
3 changed files with 53 additions and 34 deletions

View file

@ -1,3 +1,17 @@
2007-10-10 Markus Deuling <deuling@de.ibm.com>
* rs6000-nat.c (fetch_register, store_register)
(rs6000_fetch_inferior_registers, rs6000_store_inferior_registers): Use
get_regcache_arch to get at the current architecture by regcache.
* rs6000-tdep.c (rs6000_push_dummy_call, rs6000_return_value)
(rs6000_register_reggroup_p, e500_move_ev_registe, rs6000_unwind_pc)
(rs6000_unwind_dummy_id, rs6000_frame_cache, rs6000_dump_tdep): Replace
current_gdbarch by gdbarch.
(rs6000_skip_trampoline_code, rs6000_register_to_value)
(rs6000_value_to_register): Use get_frame_arch to get at the current
architecture by frame_info.
2007-10-10 Markus Deuling <deuling@de.ibm.com> 2007-10-10 Markus Deuling <deuling@de.ibm.com>
* sparc-tdep.c (sparc_supply_rwindow, sparc_collect_rwindow): Use * sparc-tdep.c (sparc_supply_rwindow, sparc_collect_rwindow): Use

View file

@ -211,6 +211,7 @@ rs6000_ptrace64 (int req, int id, long long addr, int data, void *buf)
static void static void
fetch_register (struct regcache *regcache, int regno) fetch_register (struct regcache *regcache, int regno)
{ {
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int addr[MAX_REGISTER_SIZE]; int addr[MAX_REGISTER_SIZE];
int nr, isfloat; int nr, isfloat;
@ -226,7 +227,7 @@ fetch_register (struct regcache *regcache, int regno)
/* Bogus register number. */ /* Bogus register number. */
else if (nr < 0) else if (nr < 0)
{ {
if (regno >= gdbarch_num_regs (current_gdbarch)) if (regno >= gdbarch_num_regs (gdbarch))
fprintf_unfiltered (gdb_stderr, fprintf_unfiltered (gdb_stderr,
"gdb error: register no %d not implemented.\n", "gdb error: register no %d not implemented.\n",
regno); regno);
@ -244,7 +245,7 @@ fetch_register (struct regcache *regcache, int regno)
even if the register is really only 32 bits. */ even if the register is really only 32 bits. */
long long buf; long long buf;
rs6000_ptrace64 (PT_READ_GPR, PIDGET (inferior_ptid), nr, 0, &buf); rs6000_ptrace64 (PT_READ_GPR, PIDGET (inferior_ptid), nr, 0, &buf);
if (register_size (current_gdbarch, regno) == 8) if (register_size (gdbarch, regno) == 8)
memcpy (addr, &buf, 8); memcpy (addr, &buf, 8);
else else
*addr = buf; *addr = buf;
@ -268,6 +269,7 @@ fetch_register (struct regcache *regcache, int regno)
static void static void
store_register (const struct regcache *regcache, int regno) store_register (const struct regcache *regcache, int regno)
{ {
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int addr[MAX_REGISTER_SIZE]; int addr[MAX_REGISTER_SIZE];
int nr, isfloat; int nr, isfloat;
@ -286,7 +288,7 @@ store_register (const struct regcache *regcache, int regno)
/* Bogus register number. */ /* Bogus register number. */
else if (nr < 0) else if (nr < 0)
{ {
if (regno >= gdbarch_num_regs (current_gdbarch)) if (regno >= gdbarch_num_regs (gdbarch))
fprintf_unfiltered (gdb_stderr, fprintf_unfiltered (gdb_stderr,
"gdb error: register no %d not implemented.\n", "gdb error: register no %d not implemented.\n",
regno); regno);
@ -295,7 +297,7 @@ store_register (const struct regcache *regcache, int regno)
/* Fixed-point registers. */ /* Fixed-point registers. */
else else
{ {
if (regno == gdbarch_sp_regnum (current_gdbarch)) if (regno == gdbarch_sp_regnum (gdbarch))
/* Execute one dummy instruction (which is a breakpoint) in inferior /* Execute one dummy instruction (which is a breakpoint) in inferior
process to give kernel a chance to do internal housekeeping. process to give kernel a chance to do internal housekeeping.
Otherwise the following ptrace(2) calls will mess up user stack Otherwise the following ptrace(2) calls will mess up user stack
@ -313,7 +315,7 @@ store_register (const struct regcache *regcache, int regno)
/* PT_WRITE_GPR requires the buffer parameter to point to an 8-byte /* PT_WRITE_GPR requires the buffer parameter to point to an 8-byte
area, even if the register is really only 32 bits. */ area, even if the register is really only 32 bits. */
long long buf; long long buf;
if (register_size (current_gdbarch, regno) == 8) if (register_size (gdbarch, regno) == 8)
memcpy (&buf, addr, 8); memcpy (&buf, addr, 8);
else else
buf = *addr; buf = *addr;
@ -334,12 +336,13 @@ store_register (const struct regcache *regcache, int regno)
static void static void
rs6000_fetch_inferior_registers (struct regcache *regcache, int regno) rs6000_fetch_inferior_registers (struct regcache *regcache, int regno)
{ {
struct gdbarch *gdbarch = get_regcache_arch (regcache);
if (regno != -1) if (regno != -1)
fetch_register (regcache, regno); fetch_register (regcache, regno);
else else
{ {
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
/* Read 32 general purpose registers. */ /* Read 32 general purpose registers. */
for (regno = tdep->ppc_gp0_regnum; for (regno = tdep->ppc_gp0_regnum;
@ -355,7 +358,7 @@ rs6000_fetch_inferior_registers (struct regcache *regcache, int regno)
fetch_register (regcache, tdep->ppc_fp0_regnum + regno); fetch_register (regcache, tdep->ppc_fp0_regnum + regno);
/* Read special registers. */ /* Read special registers. */
fetch_register (regcache, gdbarch_pc_regnum (current_gdbarch)); fetch_register (regcache, gdbarch_pc_regnum (gdbarch));
fetch_register (regcache, tdep->ppc_ps_regnum); fetch_register (regcache, tdep->ppc_ps_regnum);
fetch_register (regcache, tdep->ppc_cr_regnum); fetch_register (regcache, tdep->ppc_cr_regnum);
fetch_register (regcache, tdep->ppc_lr_regnum); fetch_register (regcache, tdep->ppc_lr_regnum);
@ -375,12 +378,13 @@ rs6000_fetch_inferior_registers (struct regcache *regcache, int regno)
static void static void
rs6000_store_inferior_registers (struct regcache *regcache, int regno) rs6000_store_inferior_registers (struct regcache *regcache, int regno)
{ {
struct gdbarch *gdbarch = get_regcache_arch (regcache);
if (regno != -1) if (regno != -1)
store_register (regcache, regno); store_register (regcache, regno);
else else
{ {
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
/* Write general purpose registers first. */ /* Write general purpose registers first. */
for (regno = tdep->ppc_gp0_regnum; for (regno = tdep->ppc_gp0_regnum;
@ -396,7 +400,7 @@ rs6000_store_inferior_registers (struct regcache *regcache, int regno)
store_register (regcache, tdep->ppc_fp0_regnum + regno); store_register (regcache, tdep->ppc_fp0_regnum + regno);
/* Write special registers. */ /* Write special registers. */
store_register (regcache, gdbarch_pc_regnum (current_gdbarch)); store_register (regcache, gdbarch_pc_regnum (gdbarch));
store_register (regcache, tdep->ppc_ps_regnum); store_register (regcache, tdep->ppc_ps_regnum);
store_register (regcache, tdep->ppc_cr_regnum); store_register (regcache, tdep->ppc_cr_regnum);
store_register (regcache, tdep->ppc_lr_regnum); store_register (regcache, tdep->ppc_lr_regnum);

View file

@ -1682,14 +1682,14 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
int nargs, struct value **args, CORE_ADDR sp, int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr) int struct_return, CORE_ADDR struct_addr)
{ {
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
int ii; int ii;
int len = 0; int len = 0;
int argno; /* current argument number */ int argno; /* current argument number */
int argbytes; /* current argument byte */ int argbytes; /* current argument byte */
gdb_byte tmp_buffer[50]; gdb_byte tmp_buffer[50];
int f_argno = 0; /* current floating point argno */ int f_argno = 0; /* current floating point argno */
int wordsize = gdbarch_tdep (current_gdbarch)->wordsize; int wordsize = gdbarch_tdep (gdbarch)->wordsize;
CORE_ADDR func_addr = find_function_addr (function, NULL); CORE_ADDR func_addr = find_function_addr (function, NULL);
struct value *arg = 0; struct value *arg = 0;
@ -1700,7 +1700,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* The calling convention this function implements assumes the /* The calling convention this function implements assumes the
processor has floating-point registers. We shouldn't be using it processor has floating-point registers. We shouldn't be using it
on PPC variants that lack them. */ on PPC variants that lack them. */
gdb_assert (ppc_floating_point_unit_p (current_gdbarch)); gdb_assert (ppc_floating_point_unit_p (gdbarch));
/* The first eight words of ther arguments are passed in registers. /* The first eight words of ther arguments are passed in registers.
Copy them appropriately. */ Copy them appropriately. */
@ -1738,7 +1738,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
for (argno = 0, argbytes = 0; argno < nargs && ii < 8; ++ii) for (argno = 0, argbytes = 0; argno < nargs && ii < 8; ++ii)
{ {
int reg_size = register_size (current_gdbarch, ii + 3); int reg_size = register_size (gdbarch, ii + 3);
arg = args[argno]; arg = args[argno];
type = check_typedef (value_type (arg)); type = check_typedef (value_type (arg));
@ -1785,7 +1785,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
else else
{ {
/* Argument can fit in one register. No problem. */ /* Argument can fit in one register. No problem. */
int adj = gdbarch_byte_order (current_gdbarch) int adj = gdbarch_byte_order (gdbarch)
== BFD_ENDIAN_BIG ? reg_size - len : 0; == BFD_ENDIAN_BIG ? reg_size - len : 0;
gdb_byte word[MAX_REGISTER_SIZE]; gdb_byte word[MAX_REGISTER_SIZE];
@ -1799,7 +1799,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
ran_out_of_registers_for_arguments: ran_out_of_registers_for_arguments:
regcache_cooked_read_unsigned (regcache, regcache_cooked_read_unsigned (regcache,
gdbarch_sp_regnum (current_gdbarch), gdbarch_sp_regnum (gdbarch),
&saved_sp); &saved_sp);
/* Location for 8 parameters are always reserved. */ /* Location for 8 parameters are always reserved. */
@ -1843,7 +1843,7 @@ ran_out_of_registers_for_arguments:
else. */ else. */
regcache_raw_write_signed (regcache, regcache_raw_write_signed (regcache,
gdbarch_sp_regnum (current_gdbarch), sp); gdbarch_sp_regnum (gdbarch), sp);
/* If the last argument copied into the registers didn't fit there /* If the last argument copied into the registers didn't fit there
completely, push the rest of it into stack. */ completely, push the rest of it into stack. */
@ -1890,7 +1890,7 @@ ran_out_of_registers_for_arguments:
Not doing this can lead to conflicts with the kernel which thinks Not doing this can lead to conflicts with the kernel which thinks
that it still has control over this not-yet-allocated stack that it still has control over this not-yet-allocated stack
region. */ region. */
regcache_raw_write_signed (regcache, gdbarch_sp_regnum (current_gdbarch), sp); regcache_raw_write_signed (regcache, gdbarch_sp_regnum (gdbarch), sp);
/* Set back chain properly. */ /* Set back chain properly. */
store_unsigned_integer (tmp_buffer, wordsize, saved_sp); store_unsigned_integer (tmp_buffer, wordsize, saved_sp);
@ -1917,13 +1917,13 @@ rs6000_return_value (struct gdbarch *gdbarch, struct type *valtype,
struct regcache *regcache, gdb_byte *readbuf, struct regcache *regcache, gdb_byte *readbuf,
const gdb_byte *writebuf) const gdb_byte *writebuf)
{ {
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
gdb_byte buf[8]; gdb_byte buf[8];
/* The calling convention this function implements assumes the /* The calling convention this function implements assumes the
processor has floating-point registers. We shouldn't be using it processor has floating-point registers. We shouldn't be using it
on PowerPC variants that lack them. */ on PowerPC variants that lack them. */
gdb_assert (ppc_floating_point_unit_p (current_gdbarch)); gdb_assert (ppc_floating_point_unit_p (gdbarch));
/* AltiVec extension: Functions that declare a vector data type as a /* AltiVec extension: Functions that declare a vector data type as a
return value place that return value in VR2. */ return value place that return value in VR2. */
@ -2124,7 +2124,8 @@ rs6000_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
return 0; return 0;
} }
ii = get_frame_register_unsigned (frame, 11); /* r11 holds destination addr */ ii = get_frame_register_unsigned (frame, 11); /* r11 holds destination addr */
pc = read_memory_addr (ii, gdbarch_tdep (current_gdbarch)->wordsize); /* (r11) value */ pc = read_memory_addr (ii,
gdbarch_tdep (get_frame_arch (frame))->wordsize); /* (r11) value */
return pc; return pc;
} }
@ -2279,8 +2280,8 @@ rs6000_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
int vector_p; int vector_p;
int general_p; int general_p;
if (gdbarch_register_name (current_gdbarch, regnum) == NULL if (gdbarch_register_name (gdbarch, regnum) == NULL
|| *gdbarch_register_name (current_gdbarch, regnum) == '\0') || *gdbarch_register_name (gdbarch, regnum) == '\0')
return 0; return 0;
if (group == all_reggroup) if (group == all_reggroup)
return 1; return 1;
@ -2314,7 +2315,7 @@ rs6000_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
|| regnum == tdep->ppc_lr_regnum || regnum == tdep->ppc_lr_regnum
|| regnum == tdep->ppc_ctr_regnum || regnum == tdep->ppc_ctr_regnum
|| regnum == tdep->ppc_xer_regnum || regnum == tdep->ppc_xer_regnum
|| regnum == gdbarch_pc_regnum (current_gdbarch)); || regnum == gdbarch_pc_regnum (gdbarch));
if (group == general_reggroup) if (group == general_reggroup)
return general_p; return general_p;
@ -2343,7 +2344,7 @@ rs6000_register_to_value (struct frame_info *frame,
struct type *type, struct type *type,
gdb_byte *to) gdb_byte *to)
{ {
const struct reg *reg = gdbarch_tdep (current_gdbarch)->regs + regnum; const struct reg *reg = gdbarch_tdep (get_frame_arch (frame))->regs + regnum;
gdb_byte from[MAX_REGISTER_SIZE]; gdb_byte from[MAX_REGISTER_SIZE];
gdb_assert (reg->fpr); gdb_assert (reg->fpr);
@ -2359,7 +2360,7 @@ rs6000_value_to_register (struct frame_info *frame,
struct type *type, struct type *type,
const gdb_byte *from) const gdb_byte *from)
{ {
const struct reg *reg = gdbarch_tdep (current_gdbarch)->regs + regnum; const struct reg *reg = gdbarch_tdep (get_frame_arch (frame))->regs + regnum;
gdb_byte to[MAX_REGISTER_SIZE]; gdb_byte to[MAX_REGISTER_SIZE];
gdb_assert (reg->fpr); gdb_assert (reg->fpr);
@ -2408,7 +2409,7 @@ e500_move_ev_register (void (*move) (struct regcache *regcache,
reg_index = ev_reg - tdep->ppc_ev0_regnum; reg_index = ev_reg - tdep->ppc_ev0_regnum;
if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG)
{ {
move (regcache, tdep->ppc_ev0_upper_regnum + reg_index, byte_buffer); move (regcache, tdep->ppc_ev0_upper_regnum + reg_index, byte_buffer);
move (regcache, tdep->ppc_gp0_regnum + reg_index, byte_buffer + 4); move (regcache, tdep->ppc_gp0_regnum + reg_index, byte_buffer + 4);
@ -3224,14 +3225,14 @@ static CORE_ADDR
rs6000_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) rs6000_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
{ {
return frame_unwind_register_unsigned (next_frame, return frame_unwind_register_unsigned (next_frame,
gdbarch_pc_regnum (current_gdbarch)); gdbarch_pc_regnum (gdbarch));
} }
static struct frame_id static struct frame_id
rs6000_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame) rs6000_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame)
{ {
return frame_id_build (frame_unwind_register_unsigned return frame_id_build (frame_unwind_register_unsigned
(next_frame, gdbarch_sp_regnum (current_gdbarch)), (next_frame, gdbarch_sp_regnum (gdbarch)),
frame_pc_unwind (next_frame)); frame_pc_unwind (next_frame));
} }
@ -3270,7 +3271,7 @@ rs6000_frame_cache (struct frame_info *next_frame, void **this_cache)
the mean time, the address of the prev frame is used as the the mean time, the address of the prev frame is used as the
base address of this frame. */ base address of this frame. */
cache->base = frame_unwind_register_unsigned cache->base = frame_unwind_register_unsigned
(next_frame, gdbarch_sp_regnum (current_gdbarch)); (next_frame, gdbarch_sp_regnum (gdbarch));
/* If the function appears to be frameless, check a couple of likely /* If the function appears to be frameless, check a couple of likely
indicators that we have simply failed to find the frame setup. indicators that we have simply failed to find the frame setup.
@ -3309,7 +3310,7 @@ rs6000_frame_cache (struct frame_info *next_frame, void **this_cache)
cache->base = read_memory_addr (cache->base, wordsize); cache->base = read_memory_addr (cache->base, wordsize);
trad_frame_set_value (cache->saved_regs, trad_frame_set_value (cache->saved_regs,
gdbarch_sp_regnum (current_gdbarch), cache->base); gdbarch_sp_regnum (gdbarch), cache->base);
/* if != -1, fdata.saved_fpr is the smallest number of saved_fpr. /* if != -1, fdata.saved_fpr is the smallest number of saved_fpr.
All fpr's from saved_fpr to fp31 are saved. */ All fpr's from saved_fpr to fp31 are saved. */
@ -3388,7 +3389,7 @@ rs6000_frame_cache (struct frame_info *next_frame, void **this_cache)
if (fdata.lr_offset != 0) if (fdata.lr_offset != 0)
cache->saved_regs[tdep->ppc_lr_regnum].addr = cache->base + fdata.lr_offset; cache->saved_regs[tdep->ppc_lr_regnum].addr = cache->base + fdata.lr_offset;
/* The PC is found in the link register. */ /* The PC is found in the link register. */
cache->saved_regs[gdbarch_pc_regnum (current_gdbarch)] = cache->saved_regs[gdbarch_pc_regnum (gdbarch)] =
cache->saved_regs[tdep->ppc_lr_regnum]; cache->saved_regs[tdep->ppc_lr_regnum];
/* If != 0, fdata.vrsave_offset is the offset from the frame that /* If != 0, fdata.vrsave_offset is the offset from the frame that
@ -3400,7 +3401,7 @@ rs6000_frame_cache (struct frame_info *next_frame, void **this_cache)
/* If no alloca register used, then fi->frame is the value of the /* If no alloca register used, then fi->frame is the value of the
%sp for this frame, and it is good enough. */ %sp for this frame, and it is good enough. */
cache->initial_sp = frame_unwind_register_unsigned cache->initial_sp = frame_unwind_register_unsigned
(next_frame, gdbarch_sp_regnum (current_gdbarch)); (next_frame, gdbarch_sp_regnum (gdbarch));
else else
cache->initial_sp = frame_unwind_register_unsigned (next_frame, cache->initial_sp = frame_unwind_register_unsigned (next_frame,
fdata.alloca_reg); fdata.alloca_reg);
@ -3814,9 +3815,9 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
} }
static void static void
rs6000_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file) rs6000_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) if (tdep == NULL)
return; return;