aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2003-02-28 17:47:43 +0000
committerAndrew Cagney <cagney@redhat.com>2003-02-28 17:47:43 +0000
commit08a617dae28e205427036f542e07aef63c51c914 (patch)
tree23848a8da57b2e6c88c14518b580f22cbe05dd62 /gdb
parent4224873a5a61550c3fbdd2aed7b3882ec04928ef (diff)
downloadgdb-08a617dae28e205427036f542e07aef63c51c914.zip
gdb-08a617dae28e205427036f542e07aef63c51c914.tar.gz
gdb-08a617dae28e205427036f542e07aef63c51c914.tar.bz2
2003-02-28 Andrew Cagney <cagney@redhat.com>
* regcache.c (register_size): New function. * regcache.h (register_size): Declare * d10v-tdep.c: Use register_size instead of REGISTER_RAW_SIZE, use max_register_size instead of MAX_REGISTER_RAW_SIZE.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/d10v-tdep.c15
-rw-r--r--gdb/regcache.c12
-rw-r--r--gdb/regcache.h26
4 files changed, 53 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 3efe544..07f4fba 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2003-02-28 Andrew Cagney <cagney@redhat.com>
+
+ * regcache.c (register_size): New function.
+ * regcache.h (register_size): Declare
+ * d10v-tdep.c: Use register_size instead of REGISTER_RAW_SIZE, use
+ max_register_size instead of MAX_REGISTER_RAW_SIZE.
+
2003-02-28 David Carlton <carlton@math.stanford.edu>
* linespec.c (decode_compound): Extract code into find_method.
diff --git a/gdb/d10v-tdep.c b/gdb/d10v-tdep.c
index e2a0c80..da491b7 100644
--- a/gdb/d10v-tdep.c
+++ b/gdb/d10v-tdep.c
@@ -789,7 +789,7 @@ d10v_frame_unwind_cache (struct frame_info *fi,
{
CORE_ADDR return_pc
= read_memory_unsigned_integer (info->saved_regs[LR_REGNUM],
- REGISTER_RAW_SIZE (LR_REGNUM));
+ register_size (current_gdbarch, LR_REGNUM));
info->return_pc = d10v_make_iaddr (return_pc);
}
else
@@ -889,7 +889,7 @@ d10v_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
int i;
fprintf_filtered (file, " ");
frame_register_read (frame, a, num);
- for (i = 0; i < MAX_REGISTER_RAW_SIZE; i++)
+ for (i = 0; i < max_register_size (current_gdbarch); i++)
{
fprintf_filtered (file, "%02x", (num[i] & 0xff));
}
@@ -1078,7 +1078,7 @@ d10v_extract_return_value (struct type *type, struct regcache *regcache,
printf("RET: TYPE=%d len=%d r%d=0x%x\n", TYPE_CODE (type),
TYPE_LENGTH (type), RET1_REGNUM - R0_REGNUM,
(int) extract_unsigned_integer (regbuf + REGISTER_BYTE(RET1_REGNUM),
- REGISTER_RAW_SIZE (RET1_REGNUM)));
+ register_size (current_gdbarch, RET1_REGNUM)));
#endif
if (TYPE_LENGTH (type) == 1)
{
@@ -1464,7 +1464,7 @@ d10v_frame_id_unwind (struct frame_info *frame,
}
addr = read_memory_unsigned_integer (info->saved_regs[FP_REGNUM],
- REGISTER_RAW_SIZE (FP_REGNUM));
+ register_size (current_gdbarch, FP_REGNUM));
if (addr == 0)
return;
@@ -1495,7 +1495,7 @@ saved_regs_unwinder (struct frame_info *frame,
*addrp = 0;
*realnump = -1;
if (bufferp != NULL)
- store_address (bufferp, REGISTER_RAW_SIZE (regnum),
+ store_address (bufferp, register_size (current_gdbarch, regnum),
saved_regs[regnum]);
}
else
@@ -1510,7 +1510,7 @@ saved_regs_unwinder (struct frame_info *frame,
{
/* Read the value in from memory. */
read_memory (saved_regs[regnum], bufferp,
- REGISTER_RAW_SIZE (regnum));
+ register_size (current_gdbarch, regnum));
}
}
return;
@@ -1566,7 +1566,8 @@ d10v_frame_pop (struct frame_info *fi, void **unwind_cache,
frame_unwind_register (fi, LR_REGNUM, raw_buffer);
regcache_cooked_write (regcache, PC_REGNUM, raw_buffer);
- store_unsigned_integer (raw_buffer, REGISTER_RAW_SIZE (SP_REGNUM),
+ store_unsigned_integer (raw_buffer,
+ register_size (current_gdbarch, SP_REGNUM),
fp + info->size);
regcache_cooked_write (regcache, SP_REGNUM, raw_buffer);
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 1bbdb61..b84020e 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -285,6 +285,18 @@ max_register_size (struct gdbarch *gdbarch)
return descr->max_register_size;
}
+int
+register_size (struct gdbarch *gdbarch, int regnum)
+{
+ struct regcache_descr *descr = regcache_descr (gdbarch);
+ int size;
+ gdb_assert (regnum >= 0 && regnum < (NUM_REGS + NUM_PSEUDO_REGS));
+ size = descr->sizeof_register[regnum];
+ gdb_assert (size == REGISTER_RAW_SIZE (regnum)); /* OK */
+ gdb_assert (size == REGISTER_RAW_SIZE (regnum)); /* OK */
+ return size;
+}
+
/* The register cache for storing raw register values. */
struct regcache
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 8dfd2e9..ee10505 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -129,6 +129,32 @@ extern struct type *register_type (struct gdbarch *gdbarch, int regnum);
extern int max_register_size (struct gdbarch *gdbarch);
+/* Return the size of register REGNUM. All registers should have only
+ one size.
+
+ FIXME: cagney/2003-02-28:
+
+ Unfortunatly, thanks to some legacy architectures, this doesn't
+ hold. A register's cooked (nee virtual) and raw size can differ
+ (see MIPS). Such architectures should be using different register
+ numbers for the different sized views of identical registers.
+
+ Anyway, the up-shot is that, until that mess is fixed, core code
+ can end up being very confused - should the RAW or VIRTUAL size be
+ used? As a rule of thumb, use REGISTER_VIRTUAL_SIZE in cooked
+ code, but with the comment:
+
+ OK: REGISTER_VIRTUAL_SIZE
+
+ or just
+
+ OK
+
+ appended to the end of the line. */
+
+extern int register_size (struct gdbarch *gdbarch, int regnum);
+
+
/* Save/restore a register cache. The registers saved/restored is
determined by the save_reggroup and restore_reggroup (although you
can't restore a register that wasn't saved as well :-). You can