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

* sh64-tdep.c (sh64_push_dummy_call, sh64_register_type)
	(sh64_pseudo_register_read, sh64_pseudo_register_write)
	(sh64_do_fp_register, sh64_do_pseudo_register, sh64_do_register)
	(sh64_print_register, sh64_media_print_registers_info)
	(sh64_compact_print_registers_info, sh64_unwind_sp)
	(sh64_unwind_pc): Replace current_gdbarch by gdbarch.
	(sh64_show_media_regs, sh64_show_compact_regs, sh64_frame_cache)
	(sh64_frame_prev_register): Use FRAME to recognize current
	architecture.
This commit is contained in:
Ulrich Weigand 2007-10-08 12:57:04 +00:00
parent b47193f79e
commit 586435019e
2 changed files with 77 additions and 60 deletions

View File

@ -1,3 +1,15 @@
2007-10-08 Markus Deuling <deuling@de.ibm.com>
* sh64-tdep.c (sh64_push_dummy_call, sh64_register_type)
(sh64_pseudo_register_read, sh64_pseudo_register_write)
(sh64_do_fp_register, sh64_do_pseudo_register, sh64_do_register)
(sh64_print_register, sh64_media_print_registers_info)
(sh64_compact_print_registers_info, sh64_unwind_sp)
(sh64_unwind_pc): Replace current_gdbarch by gdbarch.
(sh64_show_media_regs, sh64_show_compact_regs, sh64_frame_cache)
(sh64_frame_prev_register): Use FRAME to recognize current
architecture.
2007-10-08 Markus Deuling <deuling@de.ibm.com>
* sh-tdep.c (sh_push_dummy_call_fpu, sh_push_dummy_call_nofpu)

View File

@ -1074,7 +1074,7 @@ sh64_push_dummy_call (struct gdbarch *gdbarch,
in eight registers available. Loop thru args from first to last. */
int_argreg = ARG0_REGNUM;
float_argreg = gdbarch_fp0_regnum (current_gdbarch);
float_argreg = gdbarch_fp0_regnum (gdbarch);
double_argreg = DR0_REGNUM;
for (argnum = 0, stack_offset = 0; argnum < nargs; argnum++)
@ -1085,12 +1085,12 @@ sh64_push_dummy_call (struct gdbarch *gdbarch,
if (TYPE_CODE (type) != TYPE_CODE_FLT)
{
argreg_size = register_size (current_gdbarch, int_argreg);
argreg_size = register_size (gdbarch, int_argreg);
if (len < argreg_size)
{
/* value gets right-justified in the register or stack word */
if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
memcpy (valbuf + argreg_size - len,
(char *) value_contents (args[argnum]), len);
else
@ -1144,7 +1144,7 @@ sh64_push_dummy_call (struct gdbarch *gdbarch,
{
/* Goes in FR0...FR11 */
regcache_cooked_write (regcache,
gdbarch_fp0_regnum (current_gdbarch)
gdbarch_fp0_regnum (gdbarch)
+ float_arg_index,
val);
fp_args[float_arg_index] = 1;
@ -1190,7 +1190,7 @@ sh64_push_dummy_call (struct gdbarch *gdbarch,
/* Update stack pointer. */
regcache_cooked_write_unsigned (regcache,
gdbarch_sp_regnum (current_gdbarch), sp);
gdbarch_sp_regnum (gdbarch), sp);
return sp;
}
@ -1316,12 +1316,13 @@ sh64_return_value (struct gdbarch *gdbarch, struct type *type,
static void
sh64_show_media_regs (struct frame_info *frame)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
int i;
printf_filtered
("PC=%s SR=%016llx \n",
paddr (get_frame_register_unsigned (frame,
gdbarch_pc_regnum (current_gdbarch))),
gdbarch_pc_regnum (gdbarch))),
(long long) get_frame_register_unsigned (frame, SR_REGNUM));
printf_filtered
@ -1348,26 +1349,27 @@ sh64_show_media_regs (struct frame_info *frame)
("FR%d-FR%d %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
i, i + 7,
(long) get_frame_register_unsigned
(frame, gdbarch_fp0_regnum (current_gdbarch) + i + 0),
(frame, gdbarch_fp0_regnum (gdbarch) + i + 0),
(long) get_frame_register_unsigned
(frame, gdbarch_fp0_regnum (current_gdbarch) + i + 1),
(frame, gdbarch_fp0_regnum (gdbarch) + i + 1),
(long) get_frame_register_unsigned
(frame, gdbarch_fp0_regnum (current_gdbarch) + i + 2),
(frame, gdbarch_fp0_regnum (gdbarch) + i + 2),
(long) get_frame_register_unsigned
(frame, gdbarch_fp0_regnum (current_gdbarch) + i + 3),
(frame, gdbarch_fp0_regnum (gdbarch) + i + 3),
(long) get_frame_register_unsigned
(frame, gdbarch_fp0_regnum (current_gdbarch) + i + 4),
(frame, gdbarch_fp0_regnum (gdbarch) + i + 4),
(long) get_frame_register_unsigned
(frame, gdbarch_fp0_regnum (current_gdbarch) + i + 5),
(frame, gdbarch_fp0_regnum (gdbarch) + i + 5),
(long) get_frame_register_unsigned
(frame, gdbarch_fp0_regnum (current_gdbarch) + i + 6),
(frame, gdbarch_fp0_regnum (gdbarch) + i + 6),
(long) get_frame_register_unsigned
(frame, gdbarch_fp0_regnum (current_gdbarch) + i + 7));
(frame, gdbarch_fp0_regnum (gdbarch) + i + 7));
}
static void
sh64_show_compact_regs (struct frame_info *frame)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
int i;
printf_filtered
@ -1402,21 +1404,21 @@ sh64_show_compact_regs (struct frame_info *frame)
("FR%d-FR%d %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
i, i + 7,
(long) get_frame_register_unsigned
(frame, gdbarch_fp0_regnum (current_gdbarch) + i + 0),
(frame, gdbarch_fp0_regnum (gdbarch) + i + 0),
(long) get_frame_register_unsigned
(frame, gdbarch_fp0_regnum (current_gdbarch) + i + 1),
(frame, gdbarch_fp0_regnum (gdbarch) + i + 1),
(long) get_frame_register_unsigned
(frame, gdbarch_fp0_regnum (current_gdbarch) + i + 2),
(frame, gdbarch_fp0_regnum (gdbarch) + i + 2),
(long) get_frame_register_unsigned
(frame, gdbarch_fp0_regnum (current_gdbarch) + i + 3),
(frame, gdbarch_fp0_regnum (gdbarch) + i + 3),
(long) get_frame_register_unsigned
(frame, gdbarch_fp0_regnum (current_gdbarch) + i + 4),
(frame, gdbarch_fp0_regnum (gdbarch) + i + 4),
(long) get_frame_register_unsigned
(frame, gdbarch_fp0_regnum (current_gdbarch) + i + 5),
(frame, gdbarch_fp0_regnum (gdbarch) + i + 5),
(long) get_frame_register_unsigned
(frame, gdbarch_fp0_regnum (current_gdbarch) + i + 6),
(frame, gdbarch_fp0_regnum (gdbarch) + i + 6),
(long) get_frame_register_unsigned
(frame, gdbarch_fp0_regnum (current_gdbarch) + i + 7));
(frame, gdbarch_fp0_regnum (gdbarch) + i + 7));
}
/* FIXME!!! This only shows the registers for shmedia, excluding the
@ -1512,7 +1514,7 @@ sh64_build_float_register_type (int high)
static struct type *
sh64_register_type (struct gdbarch *gdbarch, int reg_nr)
{
if ((reg_nr >= gdbarch_fp0_regnum (current_gdbarch)
if ((reg_nr >= gdbarch_fp0_regnum (gdbarch)
&& reg_nr <= FP_LAST_REGNUM)
|| (reg_nr >= FP0_C_REGNUM
&& reg_nr <= FP_LAST_C_REGNUM))
@ -1653,7 +1655,7 @@ sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
/* Build the value in the provided buffer. */
regcache_raw_read (regcache, base_regnum, temp_buffer);
if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
offset = 4;
memcpy (buffer, temp_buffer + offset, 4); /* get LOWER 32 bits only????*/
}
@ -1813,7 +1815,7 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
{
base_regnum = sh64_compact_reg_base_num (reg_nr);
/* reg_nr is 32 bit here, and base_regnum is 64 bits. */
if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
offset = 4;
else
offset = 0;
@ -1984,20 +1986,20 @@ sh64_do_fp_register (struct gdbarch *gdbarch, struct ui_file *file,
raw_buffer = (unsigned char *) alloca
(register_size (gdbarch,
gdbarch_fp0_regnum
(current_gdbarch)));
(gdbarch)));
/* Get the data in raw format. */
if (!frame_register_read (frame, regnum, raw_buffer))
error ("can't read register %d (%s)",
regnum, gdbarch_register_name (current_gdbarch, regnum));
regnum, gdbarch_register_name (gdbarch, regnum));
/* Get the register as a number */
flt = unpack_double (builtin_type_float, raw_buffer, &inv);
/* Print the name and some spaces. */
fputs_filtered (gdbarch_register_name (current_gdbarch, regnum), file);
fputs_filtered (gdbarch_register_name (gdbarch, regnum), file);
print_spaces_filtered (15 - strlen (gdbarch_register_name
(current_gdbarch, regnum)), file);
(gdbarch, regnum)), file);
/* Print the value. */
if (inv)
@ -2009,7 +2011,7 @@ sh64_do_fp_register (struct gdbarch *gdbarch, struct ui_file *file,
fprintf_filtered (file, "\t(raw 0x");
for (j = 0; j < register_size (gdbarch, regnum); j++)
{
int idx = gdbarch_byte_order (current_gdbarch)
int idx = gdbarch_byte_order (gdbarch)
== BFD_ENDIAN_BIG ? j : register_size
(gdbarch, regnum) - 1 - j;
fprintf_filtered (file, "%02x", raw_buffer[idx]);
@ -2024,8 +2026,8 @@ sh64_do_pseudo_register (struct gdbarch *gdbarch, struct ui_file *file,
{
/* All the sh64-compact mode registers are pseudo registers. */
if (regnum < gdbarch_num_regs (current_gdbarch)
|| regnum >= gdbarch_num_regs (current_gdbarch)
if (regnum < gdbarch_num_regs (gdbarch)
|| regnum >= gdbarch_num_regs (gdbarch)
+ NUM_PSEUDO_REGS_SH_MEDIA
+ NUM_PSEUDO_REGS_SH_COMPACT)
internal_error (__FILE__, __LINE__,
@ -2096,9 +2098,9 @@ sh64_do_register (struct gdbarch *gdbarch, struct ui_file *file,
{
unsigned char raw_buffer[MAX_REGISTER_SIZE];
fputs_filtered (gdbarch_register_name (current_gdbarch, regnum), file);
fputs_filtered (gdbarch_register_name (gdbarch, regnum), file);
print_spaces_filtered (15 - strlen (gdbarch_register_name
(current_gdbarch, regnum)), file);
(gdbarch, regnum)), file);
/* Get the data in raw format. */
if (!frame_register_read (frame, regnum, raw_buffer))
@ -2116,12 +2118,12 @@ static void
sh64_print_register (struct gdbarch *gdbarch, struct ui_file *file,
struct frame_info *frame, int regnum)
{
if (regnum < 0 || regnum >= gdbarch_num_regs (current_gdbarch)
+ gdbarch_num_pseudo_regs (current_gdbarch))
if (regnum < 0 || regnum >= gdbarch_num_regs (gdbarch)
+ gdbarch_num_pseudo_regs (gdbarch))
internal_error (__FILE__, __LINE__,
_("Invalid register number %d\n"), regnum);
else if (regnum >= 0 && regnum < gdbarch_num_regs (current_gdbarch))
else if (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch))
{
if (TYPE_CODE (register_type (gdbarch, regnum)) == TYPE_CODE_FLT)
sh64_do_fp_register (gdbarch, file, frame, regnum); /* FP regs */
@ -2129,8 +2131,8 @@ sh64_print_register (struct gdbarch *gdbarch, struct ui_file *file,
sh64_do_register (gdbarch, file, frame, regnum);
}
else if (regnum < gdbarch_num_regs (current_gdbarch)
+ gdbarch_num_pseudo_regs (current_gdbarch))
else if (regnum < gdbarch_num_regs (gdbarch)
+ gdbarch_num_pseudo_regs (gdbarch))
sh64_do_pseudo_register (gdbarch, file, frame, regnum);
}
@ -2141,7 +2143,7 @@ sh64_media_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
{
if (regnum != -1) /* do one specified register */
{
if (*(gdbarch_register_name (current_gdbarch, regnum)) == '\0')
if (*(gdbarch_register_name (gdbarch, regnum)) == '\0')
error ("Not a valid register for the current processor type");
sh64_print_register (gdbarch, file, frame, regnum);
@ -2150,12 +2152,12 @@ sh64_media_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
/* do all (or most) registers */
{
regnum = 0;
while (regnum < gdbarch_num_regs (current_gdbarch))
while (regnum < gdbarch_num_regs (gdbarch))
{
/* If the register name is empty, it is undefined for this
processor, so don't display anything. */
if (gdbarch_register_name (current_gdbarch, regnum) == NULL
|| *(gdbarch_register_name (current_gdbarch, regnum)) == '\0')
if (gdbarch_register_name (gdbarch, regnum) == NULL
|| *(gdbarch_register_name (gdbarch, regnum)) == '\0')
{
regnum++;
continue;
@ -2171,7 +2173,7 @@ sh64_media_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
regnum ++;
}
else
regnum += FP_LAST_REGNUM - gdbarch_fp0_regnum (current_gdbarch);
regnum += FP_LAST_REGNUM - gdbarch_fp0_regnum (gdbarch);
/* skip FP regs */
}
else
@ -2182,8 +2184,8 @@ sh64_media_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
}
if (fpregs)
while (regnum < gdbarch_num_regs (current_gdbarch)
+ gdbarch_num_pseudo_regs (current_gdbarch))
while (regnum < gdbarch_num_regs (gdbarch)
+ gdbarch_num_pseudo_regs (gdbarch))
{
sh64_do_pseudo_register (gdbarch, file, frame, regnum);
regnum++;
@ -2199,7 +2201,7 @@ sh64_compact_print_registers_info (struct gdbarch *gdbarch,
{
if (regnum != -1) /* do one specified register */
{
if (*(gdbarch_register_name (current_gdbarch, regnum)) == '\0')
if (*(gdbarch_register_name (gdbarch, regnum)) == '\0')
error ("Not a valid register for the current processor type");
if (regnum >= 0 && regnum < R0_C_REGNUM)
@ -2211,8 +2213,8 @@ sh64_compact_print_registers_info (struct gdbarch *gdbarch,
/* do all compact registers */
{
regnum = R0_C_REGNUM;
while (regnum < gdbarch_num_regs (current_gdbarch)
+ gdbarch_num_pseudo_regs (current_gdbarch))
while (regnum < gdbarch_num_regs (gdbarch)
+ gdbarch_num_pseudo_regs (gdbarch))
{
sh64_do_pseudo_register (gdbarch, file, frame, regnum);
regnum++;
@ -2260,6 +2262,7 @@ sh64_alloc_frame_cache (void)
static struct sh64_frame_cache *
sh64_frame_cache (struct frame_info *next_frame, void **this_cache)
{
struct gdbarch *gdbarch;
struct sh64_frame_cache *cache;
CORE_ADDR current_pc;
int i;
@ -2267,6 +2270,7 @@ sh64_frame_cache (struct frame_info *next_frame, void **this_cache)
if (*this_cache)
return *this_cache;
gdbarch = get_frame_arch (next_frame);
cache = sh64_alloc_frame_cache ();
*this_cache = cache;
@ -2284,7 +2288,7 @@ sh64_frame_cache (struct frame_info *next_frame, void **this_cache)
cache->pc = frame_func_unwind (next_frame, NORMAL_FRAME);
if (cache->pc != 0)
sh64_analyze_prologue (current_gdbarch, cache, cache->pc, current_pc);
sh64_analyze_prologue (gdbarch, cache, cache->pc, current_pc);
if (!cache->uses_fp)
{
@ -2296,7 +2300,7 @@ sh64_frame_cache (struct frame_info *next_frame, void **this_cache)
frame by looking at the stack pointer. For truly "frameless"
functions this might work too. */
cache->base = frame_unwind_register_unsigned
(next_frame, gdbarch_sp_regnum (current_gdbarch));
(next_frame, gdbarch_sp_regnum (gdbarch));
}
/* Now that we have the base address for the stack frame we can
@ -2319,10 +2323,11 @@ sh64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
int *realnump, gdb_byte *valuep)
{
struct sh64_frame_cache *cache = sh64_frame_cache (next_frame, this_cache);
struct gdbarch *gdbarch = get_frame_arch (next_frame);
gdb_assert (regnum >= 0);
if (regnum == gdbarch_sp_regnum (current_gdbarch) && cache->saved_sp)
if (regnum == gdbarch_sp_regnum (gdbarch) && cache->saved_sp)
{
*optimizedp = 0;
*lvalp = not_lval;
@ -2332,8 +2337,8 @@ sh64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
{
/* Store the value. */
store_unsigned_integer (valuep,
register_size (current_gdbarch,
gdbarch_sp_regnum (current_gdbarch)),
register_size (gdbarch,
gdbarch_sp_regnum (gdbarch)),
cache->saved_sp);
}
return;
@ -2342,19 +2347,19 @@ sh64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
/* The PC of the previous frame is stored in the PR register of
the current frame. Frob regnum so that we pull the value from
the correct place. */
if (regnum == gdbarch_pc_regnum (current_gdbarch))
if (regnum == gdbarch_pc_regnum (gdbarch))
regnum = PR_REGNUM;
if (regnum < SIM_SH64_NR_REGS && cache->saved_regs[regnum] != -1)
{
int reg_size = register_size (current_gdbarch, regnum);
int reg_size = register_size (gdbarch, regnum);
int size;
*optimizedp = 0;
*lvalp = lval_memory;
*addrp = cache->saved_regs[regnum];
*realnump = -1;
if (gdbarch_tdep (current_gdbarch)->sh_abi == SH_ABI_32
if (gdbarch_tdep (gdbarch)->sh_abi == SH_ABI_32
&& (regnum == MEDIA_FP_REGNUM || regnum == PR_REGNUM))
size = 4;
else
@ -2362,7 +2367,7 @@ sh64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
if (valuep)
{
memset (valuep, 0, reg_size);
if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE)
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
read_memory (*addrp, valuep, size);
else
read_memory (*addrp, (char *) valuep + reg_size - size, size);
@ -2407,14 +2412,14 @@ static CORE_ADDR
sh64_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
{
return frame_unwind_register_unsigned (next_frame,
gdbarch_sp_regnum (current_gdbarch));
gdbarch_sp_regnum (gdbarch));
}
static CORE_ADDR
sh64_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
{
return frame_unwind_register_unsigned (next_frame,
gdbarch_pc_regnum (current_gdbarch));
gdbarch_pc_regnum (gdbarch));
}
static struct frame_id