aboutsummaryrefslogtreecommitdiff
path: root/gdb/sh-tdep.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/sh-tdep.c')
-rw-r--r--gdb/sh-tdep.c225
1 files changed, 122 insertions, 103 deletions
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 49df334..72c6cbd 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -1,25 +1,26 @@
/* Target-dependent code for Hitachi Super-H, for GDB.
Copyright 1993, 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
-This file is part of GDB.
+ This file is part of GDB.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
/*
- Contributed by Steve Chamberlain
- sac@cygnus.com
+ Contributed by Steve Chamberlain
+ sac@cygnus.com
*/
#include "defs.h"
@@ -37,7 +38,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* A set of original names, to be used when restoring back to generic
registers from a specific set. */
-
/* *INDENT-OFF* */
static char *sh_generic_reg_names[] = {
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
@@ -88,25 +88,44 @@ static char *sh3e_reg_names[] = {
};
/* *INDENT-ON* */
+
+
char **sh_register_names = sh_generic_reg_names;
-struct {
- char **regnames;
- int mach;
-} sh_processor_type_table[] = {
- { sh_reg_names, bfd_mach_sh },
- { sh3_reg_names, bfd_mach_sh3 },
- { sh3e_reg_names, bfd_mach_sh3e },
- { sh3e_reg_names, bfd_mach_sh4 },
- { NULL, 0 }
+struct
+ {
+ char **regnames;
+ int mach;
+ }
+sh_processor_type_table[] =
+{
+ {
+ sh_reg_names, bfd_mach_sh
+ }
+ ,
+ {
+ sh3_reg_names, bfd_mach_sh3
+ }
+ ,
+ {
+ sh3e_reg_names, bfd_mach_sh3e
+ }
+ ,
+ {
+ sh3e_reg_names, bfd_mach_sh4
+ }
+ ,
+ {
+ NULL, 0
+ }
};
/* Prologue looks like
- [mov.l <regs>,@-r15]...
- [sts.l pr,@-r15]
- [mov.l r14,@-r15]
- [mov r15,r14]
-*/
+ [mov.l <regs>,@-r15]...
+ [sts.l pr,@-r15]
+ [mov.l r14,@-r15]
+ [mov r15,r14]
+ */
#define IS_STS(x) ((x) == 0x4f22)
#define IS_PUSH(x) (((x) & 0xff0f) == 0x2f06)
@@ -203,14 +222,14 @@ sh_find_callers_reg (fi, regnum)
for (; fi; fi = fi->next)
if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
/* When the caller requests PR from the dummy frame, we return PC because
- that's where the previous routine appears to have done a call from. */
+ that's where the previous routine appears to have done a call from. */
return generic_read_register_dummy (fi->pc, fi->frame, regnum);
- else
+ else
{
- FRAME_FIND_SAVED_REGS(fi, fsr);
+ FRAME_FIND_SAVED_REGS (fi, fsr);
if (fsr.regs[regnum] != 0)
- return read_memory_integer (fsr.regs[regnum],
- REGISTER_RAW_SIZE(regnum));
+ return read_memory_integer (fsr.regs[regnum],
+ REGISTER_RAW_SIZE (regnum));
}
return read_register (regnum);
}
@@ -234,14 +253,14 @@ sh_frame_find_saved_regs (fi, fsr)
int opc;
int insn;
int r3_val = 0;
- char * dummy_regs = generic_find_dummy_frame (fi->pc, fi->frame);
+ char *dummy_regs = generic_find_dummy_frame (fi->pc, fi->frame);
if (dummy_regs)
{
/* DANGER! This is ONLY going to work if the char buffer format of
- the saved registers is byte-for-byte identical to the
- CORE_ADDR regs[NUM_REGS] format used by struct frame_saved_regs! */
- memcpy (&fsr->regs, dummy_regs, sizeof(fsr));
+ the saved registers is byte-for-byte identical to the
+ CORE_ADDR regs[NUM_REGS] format used by struct frame_saved_regs! */
+ memcpy (&fsr->regs, dummy_regs, sizeof (fsr));
return;
}
@@ -368,10 +387,10 @@ sh_init_extra_frame_info (fromleaf, fi)
if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
{
/* We need to setup fi->frame here because run_stack_dummy gets it wrong
- by assuming it's always FP. */
- fi->frame = generic_read_register_dummy (fi->pc, fi->frame,
- SP_REGNUM);
- fi->return_pc = generic_read_register_dummy (fi->pc, fi->frame,
+ by assuming it's always FP. */
+ fi->frame = generic_read_register_dummy (fi->pc, fi->frame,
+ SP_REGNUM);
+ fi->return_pc = generic_read_register_dummy (fi->pc, fi->frame,
PC_REGNUM);
fi->f_offset = -(CALL_DUMMY_LENGTH + 4);
fi->leaf_function = 0;
@@ -398,18 +417,18 @@ sh_pop_frame ()
if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
generic_pop_dummy_frame ();
else
- {
- fp = FRAME_FP (frame);
- get_frame_saved_regs (frame, &fsr);
+ {
+ fp = FRAME_FP (frame);
+ get_frame_saved_regs (frame, &fsr);
- /* Copy regs from where they were saved in the frame */
- for (regnum = 0; regnum < NUM_REGS; regnum++)
- if (fsr.regs[regnum])
- write_register (regnum, read_memory_integer (fsr.regs[regnum], 4));
+ /* Copy regs from where they were saved in the frame */
+ for (regnum = 0; regnum < NUM_REGS; regnum++)
+ if (fsr.regs[regnum])
+ write_register (regnum, read_memory_integer (fsr.regs[regnum], 4));
- write_register (PC_REGNUM, frame->return_pc);
- write_register (SP_REGNUM, fp + 4);
- }
+ write_register (PC_REGNUM, frame->return_pc);
+ write_register (SP_REGNUM, fp + 4);
+ }
flush_cached_frames ();
}
@@ -446,7 +465,7 @@ sh_pop_frame ()
bug. Arguments of these odd sizes are left-justified within the
word (as opposed to arguments smaller than 4 bytes, which are
right-justified).
-
+
If the function is to return an aggregate type such as a struct, it
is either returned in the normal return value register R0 (if its
@@ -481,13 +500,13 @@ sh_push_arguments (nargs, args, sp, struct_return, struct_addr)
/* The "struct return pointer" pseudo-argument has its own dedicated
register */
if (struct_return)
- write_register (STRUCT_RETURN_REGNUM, struct_addr);
+ write_register (STRUCT_RETURN_REGNUM, struct_addr);
/* Now make sure there's space on the stack */
for (argnum = 0, stack_alloc = 0;
argnum < nargs; argnum++)
- stack_alloc += ((TYPE_LENGTH(VALUE_TYPE(args[argnum])) + 3) & ~3);
- sp -= stack_alloc; /* make room on stack for args */
+ stack_alloc += ((TYPE_LENGTH (VALUE_TYPE (args[argnum])) + 3) & ~3);
+ sp -= stack_alloc; /* make room on stack for args */
/* Now load as many as possible of the first arguments into
@@ -498,25 +517,25 @@ sh_push_arguments (nargs, args, sp, struct_return, struct_addr)
for (argnum = 0, stack_offset = 0; argnum < nargs; argnum++)
{
type = VALUE_TYPE (args[argnum]);
- len = TYPE_LENGTH (type);
- memset(valbuf, 0, sizeof(valbuf));
+ len = TYPE_LENGTH (type);
+ memset (valbuf, 0, sizeof (valbuf));
if (len < 4)
- { /* value gets right-justified in the register or stack word */
- memcpy(valbuf + (4 - len),
- (char *) VALUE_CONTENTS (args[argnum]), len);
- val = valbuf;
- }
+ { /* value gets right-justified in the register or stack word */
+ memcpy (valbuf + (4 - len),
+ (char *) VALUE_CONTENTS (args[argnum]), len);
+ val = valbuf;
+ }
else
- val = (char *) VALUE_CONTENTS (args[argnum]);
+ val = (char *) VALUE_CONTENTS (args[argnum]);
if (len > 4 && (len & 3) != 0)
- odd_sized_struct = 1; /* such structs go entirely on stack */
- else
+ odd_sized_struct = 1; /* such structs go entirely on stack */
+ else
odd_sized_struct = 0;
while (len > 0)
{
if (argreg > ARGLAST_REGNUM || odd_sized_struct)
- { /* must go on the stack */
+ { /* must go on the stack */
write_memory (sp + stack_offset, val, 4);
stack_offset += 4;
}
@@ -524,15 +543,15 @@ sh_push_arguments (nargs, args, sp, struct_return, struct_addr)
That's because some *&^%$ things get passed on the stack
AND in the registers! */
if (argreg <= ARGLAST_REGNUM)
- { /* there's room in a register */
- regval = extract_address (val, REGISTER_RAW_SIZE(argreg));
+ { /* there's room in a register */
+ regval = extract_address (val, REGISTER_RAW_SIZE (argreg));
write_register (argreg++, regval);
}
/* Store the value 4 bytes at a time. This means that things
larger than 4 bytes may go partly in registers and partly
on the stack. */
- len -= REGISTER_RAW_SIZE(argreg);
- val += REGISTER_RAW_SIZE(argreg);
+ len -= REGISTER_RAW_SIZE (argreg);
+ val += REGISTER_RAW_SIZE (argreg);
}
}
return sp;
@@ -558,12 +577,12 @@ sh_push_return_address (pc, sp)
it into a register using PC-relative addressing. This function
expects the CALL_DUMMY to look like this:
- mov.w @(2,PC), R8
- jsr @R8
- nop
- trap
- <destination>
- */
+ mov.w @(2,PC), R8
+ jsr @R8
+ nop
+ trap
+ <destination>
+ */
#if 0
void
@@ -629,19 +648,19 @@ sh_show_regs (args, from_tty)
read_register (MACL_REGNUM));
printf_filtered ("GBR=%08x VBR=%08x",
- read_register (GBR_REGNUM),
- read_register (VBR_REGNUM));
+ read_register (GBR_REGNUM),
+ read_register (VBR_REGNUM));
if (cpu == bfd_mach_sh3 || cpu == bfd_mach_sh3e)
{
printf_filtered (" SSR=%08x SPC=%08x",
- read_register (SSR_REGNUM),
- read_register (SPC_REGNUM));
+ read_register (SSR_REGNUM),
+ read_register (SPC_REGNUM));
if (cpu == bfd_mach_sh3e)
- {
- printf_filtered (" FPUL=%08x FPSCR=%08x",
- read_register (FPUL_REGNUM),
- read_register (FPSCR_REGNUM));
- }
+ {
+ printf_filtered (" FPUL=%08x FPSCR=%08x",
+ read_register (FPUL_REGNUM),
+ read_register (FPSCR_REGNUM));
+ }
}
printf_filtered ("\nR0-R7 %08x %08x %08x %08x %08x %08x %08x %08x\n",
@@ -665,23 +684,23 @@ sh_show_regs (args, from_tty)
if (cpu == bfd_mach_sh3e)
{
printf_filtered ("FP0-FP7 %08x %08x %08x %08x %08x %08x %08x %08x\n",
- read_register (FP0_REGNUM + 0),
- read_register (FP0_REGNUM + 1),
- read_register (FP0_REGNUM + 2),
- read_register (FP0_REGNUM + 3),
- read_register (FP0_REGNUM + 4),
- read_register (FP0_REGNUM + 5),
- read_register (FP0_REGNUM + 6),
- read_register (FP0_REGNUM + 7));
+ read_register (FP0_REGNUM + 0),
+ read_register (FP0_REGNUM + 1),
+ read_register (FP0_REGNUM + 2),
+ read_register (FP0_REGNUM + 3),
+ read_register (FP0_REGNUM + 4),
+ read_register (FP0_REGNUM + 5),
+ read_register (FP0_REGNUM + 6),
+ read_register (FP0_REGNUM + 7));
printf_filtered ("FP8-FP15 %08x %08x %08x %08x %08x %08x %08x %08x\n",
- read_register (FP0_REGNUM + 8),
- read_register (FP0_REGNUM + 9),
- read_register (FP0_REGNUM + 10),
- read_register (FP0_REGNUM + 11),
- read_register (FP0_REGNUM + 12),
- read_register (FP0_REGNUM + 13),
- read_register (FP0_REGNUM + 14),
- read_register (FP0_REGNUM + 15));
+ read_register (FP0_REGNUM + 8),
+ read_register (FP0_REGNUM + 9),
+ read_register (FP0_REGNUM + 10),
+ read_register (FP0_REGNUM + 11),
+ read_register (FP0_REGNUM + 12),
+ read_register (FP0_REGNUM + 13),
+ read_register (FP0_REGNUM + 14),
+ read_register (FP0_REGNUM + 15));
}
}
@@ -695,7 +714,7 @@ sh_extract_return_value (type, regbuf, valbuf)
void *regbuf;
void *valbuf;
{
- int len = TYPE_LENGTH(type);
+ int len = TYPE_LENGTH (type);
if (len <= 4)
memcpy (valbuf, ((char *) regbuf) + 4 - len, len);