aboutsummaryrefslogtreecommitdiff
path: root/gdb/sh-tdep.c
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2002-08-02 14:48:19 +0000
committerAndrew Cagney <cagney@redhat.com>2002-08-02 14:48:19 +0000
commitd8124050fd13563f995362c89e3ac581ec282678 (patch)
treec895c4e09fb8ea98d0b85a1eff02744709afbb4c /gdb/sh-tdep.c
parentfd512f5c737a73747fd7c6017efb47c543d4c9f9 (diff)
downloadgdb-d8124050fd13563f995362c89e3ac581ec282678.zip
gdb-d8124050fd13563f995362c89e3ac581ec282678.tar.gz
gdb-d8124050fd13563f995362c89e3ac581ec282678.tar.bz2
2002-08-02 Andrew Cagney <cagney@redhat.com>
* gdbarch.sh (pseudo_register_read, pseudo_register_write): Replace the architecture methods register_read and register_write. * gdbarch.h, gdbarch.c: Regenerate. * regcache.c (init_regcache_descr): Update. (read_register_gen): Update. (write_register_gen): Update. (supply_register): Update comment. * sh-tdep.c (sh_gdbarch_init): Update. (sh_pseudo_register_read, sh64_pseudo_register_read): Add `regcache' and `gdbarch' parameters. Make `buffer' a void pointer. Update code. (sh_pseudo_register_write, sh64_pseudo_register_write): Add `regcache' and `gdbarch' parameters. Make `buffer' a constant void pointer. Update code. (sh64_register_write): Delete. (sh4_register_read): Delete. (sh64_register_read): Delete. (sh4_register_write): Delete. (sh_sh4_register_convert_to_raw): Make `from' parameter a constant void pointer, `to' parameter a void pointer. (sh_sh64_register_convert_to_raw): Ditto.
Diffstat (limited to 'gdb/sh-tdep.c')
-rw-r--r--gdb/sh-tdep.c148
1 files changed, 54 insertions, 94 deletions
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 5beea29..67ebbf3 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -3331,7 +3331,7 @@ sh_sh64_register_convert_to_virtual (int regnum, struct type *type,
static void
sh_sh4_register_convert_to_raw (struct type *type, int regnum,
- char *from, char *to)
+ const void *from, void *to)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
@@ -3347,7 +3347,7 @@ sh_sh4_register_convert_to_raw (struct type *type, int regnum,
void
sh_sh64_register_convert_to_raw (struct type *type, int regnum,
- char *from, char *to)
+ const void *from, void *to)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
@@ -3371,11 +3371,12 @@ sh_sh64_register_convert_to_raw (struct type *type, int regnum,
}
void
-sh_pseudo_register_read (int reg_nr, char *buffer)
+sh_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
+ int reg_nr, void *buffer)
{
int base_regnum, portion;
char *temp_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE);
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
if (reg_nr >= tdep->DR0_REGNUM
&& reg_nr <= tdep->DR_LAST_REGNUM)
@@ -3385,7 +3386,7 @@ sh_pseudo_register_read (int reg_nr, char *buffer)
/* Build the value in the provided buffer. */
/* Read the real regs for which this one is an alias. */
for (portion = 0; portion < 2; portion++)
- regcache_raw_read (current_regcache, base_regnum + portion,
+ regcache_raw_read (regcache, base_regnum + portion,
(temp_buffer
+ REGISTER_RAW_SIZE (base_regnum) * portion));
/* We must pay attention to the endiannes. */
@@ -3400,30 +3401,21 @@ sh_pseudo_register_read (int reg_nr, char *buffer)
/* Read the real regs for which this one is an alias. */
for (portion = 0; portion < 4; portion++)
- regcache_raw_read (current_regcache, base_regnum + portion,
- buffer + REGISTER_RAW_SIZE (base_regnum) * portion);
+ regcache_raw_read (regcache, base_regnum + portion,
+ ((char *) buffer
+ + REGISTER_RAW_SIZE (base_regnum) * portion));
}
}
static void
-sh4_register_read (struct gdbarch *gdbarch, int reg_nr, char *buffer)
-{
- if (reg_nr >= 0 && reg_nr < gdbarch_tdep (current_gdbarch)->DR0_REGNUM)
- /* It is a regular register. */
- regcache_raw_read (current_regcache, reg_nr, buffer);
- else
- /* It is a pseudo register and we need to construct its value */
- sh_pseudo_register_read (reg_nr, buffer);
-}
-
-static void
-sh64_pseudo_register_read (int reg_nr, char *buffer)
+sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
+ int reg_nr, void *buffer)
{
int base_regnum;
int portion;
int offset = 0;
char *temp_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE);
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
if (reg_nr >= tdep->DR0_REGNUM
&& reg_nr <= tdep->DR_LAST_REGNUM)
@@ -3434,7 +3426,7 @@ sh64_pseudo_register_read (int reg_nr, char *buffer)
/* DR regs are double precision registers obtained by
concatenating 2 single precision floating point registers. */
for (portion = 0; portion < 2; portion++)
- regcache_raw_read (current_regcache, base_regnum + portion,
+ regcache_raw_read (regcache, base_regnum + portion,
(temp_buffer
+ REGISTER_RAW_SIZE (base_regnum) * portion));
@@ -3453,8 +3445,8 @@ sh64_pseudo_register_read (int reg_nr, char *buffer)
/* FPP regs are pairs of single precision registers obtained by
concatenating 2 single precision floating point registers. */
for (portion = 0; portion < 2; portion++)
- regcache_raw_read (current_regcache, base_regnum + portion,
- (buffer
+ regcache_raw_read (regcache, base_regnum + portion,
+ ((char *) buffer
+ REGISTER_RAW_SIZE (base_regnum) * portion));
}
@@ -3467,8 +3459,8 @@ sh64_pseudo_register_read (int reg_nr, char *buffer)
/* FV regs are vectors of single precision registers obtained by
concatenating 4 single precision floating point registers. */
for (portion = 0; portion < 4; portion++)
- regcache_raw_read (current_regcache, base_regnum + portion,
- (buffer
+ regcache_raw_read (regcache, base_regnum + portion,
+ ((char *) buffer
+ REGISTER_RAW_SIZE (base_regnum) * portion));
}
@@ -3479,7 +3471,7 @@ sh64_pseudo_register_read (int reg_nr, char *buffer)
base_regnum = sh64_compact_reg_base_num (reg_nr);
/* Build the value in the provided buffer. */
- regcache_raw_read (current_regcache, base_regnum, temp_buffer);
+ regcache_raw_read (regcache, base_regnum, temp_buffer);
if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
offset = 4;
memcpy (buffer, temp_buffer + offset, 4); /* get LOWER 32 bits only????*/
@@ -3493,7 +3485,7 @@ sh64_pseudo_register_read (int reg_nr, char *buffer)
/* Build the value in the provided buffer. */
/* Floating point registers map 1-1 to the media fp regs,
they have the same size and endienness. */
- regcache_raw_read (current_regcache, base_regnum, buffer);
+ regcache_raw_read (regcache, base_regnum, buffer);
}
else if (reg_nr >= tdep->DR0_C_REGNUM
@@ -3504,7 +3496,7 @@ sh64_pseudo_register_read (int reg_nr, char *buffer)
/* DR_C regs are double precision registers obtained by
concatenating 2 single precision floating point registers. */
for (portion = 0; portion < 2; portion++)
- regcache_raw_read (current_regcache, base_regnum + portion,
+ regcache_raw_read (regcache, base_regnum + portion,
(temp_buffer
+ REGISTER_RAW_SIZE (base_regnum) * portion));
@@ -3522,8 +3514,8 @@ sh64_pseudo_register_read (int reg_nr, char *buffer)
/* FV_C regs are vectors of single precision registers obtained by
concatenating 4 single precision floating point registers. */
for (portion = 0; portion < 4; portion++)
- regcache_raw_read (current_regcache, base_regnum + portion,
- (buffer
+ regcache_raw_read (regcache, base_regnum + portion,
+ ((char *) buffer
+ REGISTER_RAW_SIZE (base_regnum) * portion));
}
@@ -3555,11 +3547,11 @@ sh64_pseudo_register_read (int reg_nr, char *buffer)
*/
/* *INDENT-ON* */
/* Get FPSCR into a local buffer */
- regcache_raw_read (current_regcache, fpscr_base_regnum, temp_buffer);
+ regcache_raw_read (regcache, fpscr_base_regnum, temp_buffer);
/* Get value as an int. */
fpscr_value = extract_unsigned_integer (temp_buffer, 4);
/* Get SR into a local buffer */
- regcache_raw_read (current_regcache, sr_base_regnum, temp_buffer);
+ regcache_raw_read (regcache, sr_base_regnum, temp_buffer);
/* Get value as an int. */
sr_value = extract_unsigned_integer (temp_buffer, 4);
/* Build the new value. */
@@ -3577,28 +3569,17 @@ sh64_pseudo_register_read (int reg_nr, char *buffer)
/* FPUL_C register is floating point register 32,
same size, same endianness. */
- regcache_raw_read (current_regcache, base_regnum, buffer);
+ regcache_raw_read (regcache, base_regnum, buffer);
}
}
-static void
-sh64_register_read (struct gdbarch *gdbarch, int reg_nr, char *buffer)
-{
-
- if (reg_nr >= 0 && reg_nr < gdbarch_tdep (current_gdbarch)->DR0_REGNUM)
- /* It is a regular register. */
- regcache_raw_read (current_regcache, reg_nr, buffer);
- else
- /* It is a pseudo register and we need to construct its value */
- sh64_pseudo_register_read (reg_nr, buffer);
-}
-
void
-sh_pseudo_register_write (int reg_nr, char *buffer)
+sh_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
+ int reg_nr, const void *buffer)
{
int base_regnum, portion;
char *temp_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE);
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
if (reg_nr >= tdep->DR0_REGNUM
&& reg_nr <= tdep->DR_LAST_REGNUM)
@@ -3611,7 +3592,7 @@ sh_pseudo_register_write (int reg_nr, char *buffer)
/* Write the real regs for which this one is an alias. */
for (portion = 0; portion < 2; portion++)
- regcache_raw_write (current_regcache, base_regnum + portion,
+ regcache_raw_write (regcache, base_regnum + portion,
(temp_buffer
+ REGISTER_RAW_SIZE (base_regnum) * portion));
}
@@ -3622,30 +3603,20 @@ sh_pseudo_register_write (int reg_nr, char *buffer)
/* Write the real regs for which this one is an alias. */
for (portion = 0; portion < 4; portion++)
- regcache_raw_write (current_regcache, base_regnum + portion,
- (buffer
+ regcache_raw_write (regcache, base_regnum + portion,
+ ((char *) buffer
+ REGISTER_RAW_SIZE (base_regnum) * portion));
}
}
-static void
-sh4_register_write (struct gdbarch *gdbarch, int reg_nr, char *buffer)
-{
- if (reg_nr >= 0 && reg_nr < gdbarch_tdep (current_gdbarch)->DR0_REGNUM)
- /* It is a regular register. */
- regcache_raw_write (current_regcache, reg_nr, buffer);
- else
- /* It is a pseudo register and we need to construct its value */
- sh_pseudo_register_write (reg_nr, buffer);
-}
-
void
-sh64_pseudo_register_write (int reg_nr, char *buffer)
+sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
+ int reg_nr, const void *buffer)
{
int base_regnum, portion;
int offset;
char *temp_buffer = (char*) alloca (MAX_REGISTER_RAW_SIZE);
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
if (reg_nr >= tdep->DR0_REGNUM
&& reg_nr <= tdep->DR_LAST_REGNUM)
@@ -3658,7 +3629,7 @@ sh64_pseudo_register_write (int reg_nr, char *buffer)
/* Write the real regs for which this one is an alias. */
for (portion = 0; portion < 2; portion++)
- regcache_raw_write (current_regcache, base_regnum + portion,
+ regcache_raw_write (regcache, base_regnum + portion,
(temp_buffer
+ REGISTER_RAW_SIZE (base_regnum) * portion));
}
@@ -3670,8 +3641,8 @@ sh64_pseudo_register_write (int reg_nr, char *buffer)
/* Write the real regs for which this one is an alias. */
for (portion = 0; portion < 2; portion++)
- regcache_raw_write (current_regcache, base_regnum + portion,
- (buffer
+ regcache_raw_write (regcache, base_regnum + portion,
+ ((char *) buffer
+ REGISTER_RAW_SIZE (base_regnum) * portion));
}
@@ -3682,8 +3653,8 @@ sh64_pseudo_register_write (int reg_nr, char *buffer)
/* Write the real regs for which this one is an alias. */
for (portion = 0; portion < 4; portion++)
- regcache_raw_write (current_regcache, base_regnum + portion,
- (buffer
+ regcache_raw_write (regcache, base_regnum + portion,
+ ((char *) buffer
+ REGISTER_RAW_SIZE (base_regnum) * portion));
}
@@ -3701,10 +3672,10 @@ sh64_pseudo_register_write (int reg_nr, char *buffer)
/* Let's read the value of the base register into a temporary
buffer, so that overwriting the last four bytes with the new
value of the pseudo will leave the upper 4 bytes unchanged. */
- regcache_raw_read (current_regcache, base_regnum, temp_buffer);
+ regcache_raw_read (regcache, base_regnum, temp_buffer);
/* Write as an 8 byte quantity */
memcpy (temp_buffer + offset, buffer, 4);
- regcache_raw_write (current_regcache, base_regnum, temp_buffer);
+ regcache_raw_write (regcache, base_regnum, temp_buffer);
}
/* sh floating point compact pseudo registers. 1-to-1 with a shmedia
@@ -3713,7 +3684,7 @@ sh64_pseudo_register_write (int reg_nr, char *buffer)
&& reg_nr <= tdep->FP_LAST_C_REGNUM)
{
base_regnum = sh64_compact_reg_base_num (reg_nr);
- regcache_raw_write (current_regcache, base_regnum, buffer);
+ regcache_raw_write (regcache, base_regnum, buffer);
}
else if (reg_nr >= tdep->DR0_C_REGNUM
@@ -3726,7 +3697,7 @@ sh64_pseudo_register_write (int reg_nr, char *buffer)
sh_sh64_register_convert_to_raw (REGISTER_VIRTUAL_TYPE (reg_nr), reg_nr,
buffer, temp_buffer);
- regcache_raw_write (current_regcache, base_regnum + portion,
+ regcache_raw_write (regcache, base_regnum + portion,
(temp_buffer
+ REGISTER_RAW_SIZE (base_regnum) * portion));
}
@@ -3739,8 +3710,8 @@ sh64_pseudo_register_write (int reg_nr, char *buffer)
for (portion = 0; portion < 4; portion++)
{
- regcache_raw_write (current_regcache, base_regnum + portion,
- (buffer
+ regcache_raw_write (regcache, base_regnum + portion,
+ ((char *) buffer
+ REGISTER_RAW_SIZE (base_regnum) * portion));
}
}
@@ -3783,39 +3754,28 @@ sh64_pseudo_register_write (int reg_nr, char *buffer)
fpscr_value = fpscr_c_value & fpscr_mask;
sr_value = (fpscr_value & sr_mask) >> 6;
- regcache_raw_read (current_regcache, fpscr_base_regnum, temp_buffer);
+ regcache_raw_read (regcache, fpscr_base_regnum, temp_buffer);
old_fpscr_value = extract_unsigned_integer (temp_buffer, 4);
old_fpscr_value &= 0xfffc0002;
fpscr_value |= old_fpscr_value;
store_unsigned_integer (temp_buffer, 4, fpscr_value);
- regcache_raw_write (current_regcache, fpscr_base_regnum, temp_buffer);
+ regcache_raw_write (regcache, fpscr_base_regnum, temp_buffer);
- regcache_raw_read (current_regcache, sr_base_regnum, temp_buffer);
+ regcache_raw_read (regcache, sr_base_regnum, temp_buffer);
old_sr_value = extract_unsigned_integer (temp_buffer, 4);
old_sr_value &= 0xffff8fff;
sr_value |= old_sr_value;
store_unsigned_integer (temp_buffer, 4, sr_value);
- regcache_raw_write (current_regcache, sr_base_regnum, temp_buffer);
+ regcache_raw_write (regcache, sr_base_regnum, temp_buffer);
}
else if (reg_nr == tdep->FPUL_C_REGNUM)
{
base_regnum = sh64_compact_reg_base_num (reg_nr);
- regcache_raw_write (current_regcache, base_regnum, buffer);
+ regcache_raw_write (regcache, base_regnum, buffer);
}
}
-static void
-sh64_register_write (struct gdbarch *gdbarch, int reg_nr, char *buffer)
-{
- if (reg_nr >= 0 && reg_nr < gdbarch_tdep (current_gdbarch)->DR0_REGNUM)
- /* It is a regular register. */
- regcache_raw_write (current_regcache, reg_nr, buffer);
- else
- /* It is a pseudo register and we need to construct its value */
- sh64_pseudo_register_write (reg_nr, buffer);
-}
-
/* Floating point vector of 4 float registers. */
static void
do_fv_register_info (int fv_regnum)
@@ -4448,8 +4408,8 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_num_pseudo_regs (gdbarch, 12);
set_gdbarch_max_register_raw_size (gdbarch, 4 * 4);
set_gdbarch_max_register_virtual_size (gdbarch, 4 * 4);
- set_gdbarch_register_read (gdbarch, sh4_register_read);
- set_gdbarch_register_write (gdbarch, sh4_register_write);
+ set_gdbarch_pseudo_register_read (gdbarch, sh_pseudo_register_read);
+ set_gdbarch_pseudo_register_write (gdbarch, sh_pseudo_register_write);
tdep->FPUL_REGNUM = 23;
tdep->FPSCR_REGNUM = 24;
tdep->FP_LAST_REGNUM = 40;
@@ -4540,8 +4500,8 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* Or should that go in the virtual_size? */
/*set_gdbarch_max_register_virtual_size (gdbarch, 8);*/
set_gdbarch_max_register_virtual_size (gdbarch, 4 * 4);
- set_gdbarch_register_read (gdbarch, sh64_register_read);
- set_gdbarch_register_write (gdbarch, sh64_register_write);
+ set_gdbarch_pseudo_register_read (gdbarch, sh64_pseudo_register_read);
+ set_gdbarch_pseudo_register_write (gdbarch, sh64_pseudo_register_write);
set_gdbarch_do_registers_info (gdbarch, sh64_do_registers_info);
set_gdbarch_frame_init_saved_regs (gdbarch, sh64_nofp_frame_init_saved_regs);