* [patch/rfc] Add frame_read_signed/unsigned_register(); convert h8300 to print_registers_info()
@ 2002-10-22 20:00 Andrew Cagney
2002-10-23 8:21 ` Daniel Jacobowitz
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Andrew Cagney @ 2002-10-22 20:00 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1010 bytes --]
Hmm,
(I think I might split this in two)
The attached adds the methods:
+extern void frame_read_signed_register (struct frame_info *frame,
+ int regnum, LONGEST *val);
+extern void frame_read_unsigned_register (struct frame_info *frame,
+ int regnum, ULONGEST *val);
These correspond to the frame_unwind_XXXX methods() except that they
return the value of a register in THIS frame rather than the value of
the register in the PREVIOUS frame.
They are simply convenience functions to make it easier to obtain a
specified frame's register value.
Thoughts?
--
The h8300-tdep.c target's ``info registers'' routines are then updated
so that:
- Use the frame_read_XXX_register() instead of read_register().
`info registers' displays the registers of the selected frame and not
the inner most frame.
- Implement the current print_registers_info() interface
Not sure how to test it though. Anyone want to try this?
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 7994 bytes --]
2002-10-22 Andrew Cagney <cagney@redhat.com>
* frame.c (frame_read_unsigned_register): New function.
(frame_read_signed_register): New function.
* frame.h (frame_read_unsigned_register): Declare.
(frame_read_signed_register): Declare.
* h8300-tdep.c: Include "gdb_assert.h".
(h8300_print_register): Add gdbarch, file and frame parameters.
Use frame_read_unsigned_register to read the register's value.
Use fprintf_filtered to display output.
(h8300_print_registers_info): Replace h8300_do_registers_info.
(h8300_gdbarch_init): Set print_registers_info.
Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.18
diff -u -r1.18 frame.c
--- frame.c 25 Sep 2002 20:30:37 -0000 1.18
+++ frame.c 23 Oct 2002 02:43:21 -0000
@@ -153,6 +153,20 @@
}
void
+frame_read_unsigned_register (struct frame_info *frame, int regnum,
+ ULONGEST *val)
+{
+ frame_unwind_unsigned_register (get_next_frame (frame), regnum, val);
+}
+
+void
+frame_read_signed_register (struct frame_info *frame, int regnum,
+ LONGEST *val)
+{
+ frame_unwind_signed_register (get_next_frame (frame), regnum, val);
+}
+
+void
generic_unwind_get_saved_register (char *raw_buffer,
int *optimizedp,
CORE_ADDR *addrp,
Index: frame.h
===================================================================
RCS file: /cvs/src/src/gdb/frame.h,v
retrieving revision 1.26
diff -u -r1.26 frame.h
--- frame.h 2 Oct 2002 21:33:58 -0000 1.26
+++ frame.h 23 Oct 2002 02:43:21 -0000
@@ -365,6 +366,17 @@
register could not be found. */
extern int frame_register_read (struct frame_info *frame, int regnum,
void *buf);
+
+/* Return the value of register REGNUM in FRAME. The value is
+ obtained by unwinding the register from the next inner most frame.
+ These are wrapper functions to the call ``frame_unwind_X_register
+ (get_next_frame (FRAME), ...)''. */
+/* NOTE: cagney/2002-09-13: Return void as one day these functions may
+ be changed to return an indication that the read succeeded. */
+extern void frame_read_signed_register (struct frame_info *frame,
+ int regnum, LONGEST *val);
+extern void frame_read_unsigned_register (struct frame_info *frame,
+ int regnum, ULONGEST *val);
/* Map between a frame register number and its name. A frame register
space is a superset of the cooked register space --- it also
Index: h8300-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/h8300-tdep.c,v
retrieving revision 1.21
diff -u -r1.21 h8300-tdep.c
--- h8300-tdep.c 20 Sep 2002 14:22:44 -0000 1.21
+++ h8300-tdep.c 23 Oct 2002 02:43:21 -0000
@@ -34,6 +34,7 @@
#include "gdbcore.h"
#include "objfiles.h"
#include "gdbcmd.h"
+#include "gdb_assert.h"
/* Extra info which is saved in each frame_info. */
struct frame_extra_info
@@ -864,28 +865,38 @@
}
static void
-h8300_print_register (int regno)
+h8300_print_register (struct gdbarch *gdbarch, struct ui_file *file,
+ struct frame_info *frame, int regno)
{
- long val = read_register (regno);
+ ULONGEST rval;
+ long val;
const char *name = h8300_register_name (regno);
if (!name || !*name)
return;
- printf_filtered ("%-14s ", name);
+ /* FIXME: cagney/2002-10-22: The code below assumes that VAL is at
+ least 4 bytes (32 bits) in size and hence is large enough to hold
+ the largest h8300 register. Should instead be using ULONGEST and
+ the phex() functions. */
+ gdb_assert (sizeof (val) >= 4);
+ frame_read_unsigned_register (frame, regno, &rval);
+ val = rval;
+
+ fprintf_filtered (file, "%-14s ", name);
if (h8300hmode)
{
if (val)
- printf_filtered ("0x%08lx %-8ld", val, val);
+ fprintf_filtered (file, "0x%08lx %-8ld", val, val);
else
- printf_filtered ("0x%-8lx %-8ld", val, val);
+ fprintf_filtered (file, "0x%-8lx %-8ld", val, val);
}
else
{
if (val)
- printf_filtered ("0x%04lx %-4ld", val, val);
+ fprintf_filtered (file, "0x%04lx %-4ld", val, val);
else
- printf_filtered ("0x%-4lx %-4ld", val, val);
+ fprintf_filtered (file, "0x%-4lx %-4ld", val, val);
}
if (regno == E_CCR_REGNUM)
{
@@ -895,39 +906,39 @@
unsigned char l;
frame_register_read (selected_frame, regno, b);
l = b[REGISTER_VIRTUAL_SIZE (E_CCR_REGNUM) - 1];
- printf_unfiltered ("\t");
- printf_unfiltered ("I-%d ", (l & 0x80) != 0);
- printf_unfiltered ("UI-%d ", (l & 0x40) != 0);
- printf_unfiltered ("H-%d ", (l & 0x20) != 0);
- printf_unfiltered ("U-%d ", (l & 0x10) != 0);
+ fprintf_filtered (file, "\t");
+ fprintf_filtered (file, "I-%d ", (l & 0x80) != 0);
+ fprintf_filtered (file, "UI-%d ", (l & 0x40) != 0);
+ fprintf_filtered (file, "H-%d ", (l & 0x20) != 0);
+ fprintf_filtered (file, "U-%d ", (l & 0x10) != 0);
N = (l & 0x8) != 0;
Z = (l & 0x4) != 0;
V = (l & 0x2) != 0;
C = (l & 0x1) != 0;
- printf_unfiltered ("N-%d ", N);
- printf_unfiltered ("Z-%d ", Z);
- printf_unfiltered ("V-%d ", V);
- printf_unfiltered ("C-%d ", C);
+ fprintf_filtered (file, "N-%d ", N);
+ fprintf_filtered (file, "Z-%d ", Z);
+ fprintf_filtered (file, "V-%d ", V);
+ fprintf_filtered (file, "C-%d ", C);
if ((C | Z) == 0)
- printf_unfiltered ("u> ");
+ fprintf_filtered (file, "u> ");
if ((C | Z) == 1)
- printf_unfiltered ("u<= ");
+ fprintf_filtered (file, "u<= ");
if ((C == 0))
- printf_unfiltered ("u>= ");
+ fprintf_filtered (file, "u>= ");
if (C == 1)
- printf_unfiltered ("u< ");
+ fprintf_filtered (file, "u< ");
if (Z == 0)
- printf_unfiltered ("!= ");
+ fprintf_filtered (file, "!= ");
if (Z == 1)
- printf_unfiltered ("== ");
+ fprintf_filtered (file, "== ");
if ((N ^ V) == 0)
- printf_unfiltered (">= ");
+ fprintf_filtered (file, ">= ");
if ((N ^ V) == 1)
- printf_unfiltered ("< ");
+ fprintf_filtered (file, "< ");
if ((Z | (N ^ V)) == 0)
- printf_unfiltered ("> ");
+ fprintf_filtered (file, "> ");
if ((Z | (N ^ V)) == 1)
- printf_unfiltered ("<= ");
+ fprintf_filtered (file, "<= ");
}
else if (regno == E_EXR_REGNUM && h8300smode)
{
@@ -936,23 +947,24 @@
unsigned char l;
frame_register_read (selected_frame, regno, b);
l = b[REGISTER_VIRTUAL_SIZE (E_EXR_REGNUM) - 1];
- printf_unfiltered ("\t");
- printf_unfiltered ("T-%d - - - ", (l & 0x80) != 0);
- printf_unfiltered ("I2-%d ", (l & 4) != 0);
- printf_unfiltered ("I1-%d ", (l & 2) != 0);
- printf_unfiltered ("I0-%d", (l & 1) != 0);
+ fprintf_filtered (file, "\t");
+ fprintf_filtered (file, "T-%d - - - ", (l & 0x80) != 0);
+ fprintf_filtered (file, "I2-%d ", (l & 4) != 0);
+ fprintf_filtered (file, "I1-%d ", (l & 2) != 0);
+ fprintf_filtered (file, "I0-%d", (l & 1) != 0);
}
- printf_filtered ("\n");
+ fprintf_filtered (file, "\n");
}
static void
-h8300_do_registers_info (int regno, int cpregs)
+h8300_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
+ struct frame_info *frame, int regno, int cpregs)
{
if (regno < 0)
for (regno = 0; regno < E_NUM_REGS; ++regno)
- h8300_print_register (regno);
+ h8300_print_register (gdbarch, file, frame, regno);
else
- h8300_print_register (regno);
+ h8300_print_register (gdbarch, file, frame, regno);
}
static CORE_ADDR
@@ -1085,7 +1097,7 @@
set_gdbarch_register_virtual_size (gdbarch, h8300_register_raw_size);
set_gdbarch_max_register_virtual_size (gdbarch, h8300h_reg_size);
set_gdbarch_register_virtual_type (gdbarch, h8300_register_virtual_type);
- set_gdbarch_do_registers_info (gdbarch, h8300_do_registers_info);
+ set_gdbarch_print_registers_info (gdbarch, h8300_print_registers_info);
set_gdbarch_print_float_info (gdbarch, h8300_print_float_info);
/*
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [patch/rfc] Add frame_read_signed/unsigned_register(); convert h8300 to print_registers_info()
2002-10-22 20:00 [patch/rfc] Add frame_read_signed/unsigned_register(); convert h8300 to print_registers_info() Andrew Cagney
@ 2002-10-23 8:21 ` Daniel Jacobowitz
2002-10-23 9:48 ` NULL selected/current frame; Was: " Andrew Cagney
2002-10-31 12:11 ` [patch/rfc] Add frame_read_signed/unsigned_register() Andrew Cagney
2002-10-31 12:24 ` [patch] Convert h8300 to print_registers_info() Andrew Cagney
2 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2002-10-23 8:21 UTC (permalink / raw)
To: gdb-patches
On Tue, Oct 22, 2002 at 11:00:09PM -0400, Andrew Cagney wrote:
> Hmm,
>
> (I think I might split this in two)
Looks like a good idea.
>
> The attached adds the methods:
>
> +extern void frame_read_signed_register (struct frame_info *frame,
> + int regnum, LONGEST *val);
> +extern void frame_read_unsigned_register (struct frame_info *frame,
> + int regnum, ULONGEST *val);
>
> These correspond to the frame_unwind_XXXX methods() except that they
> return the value of a register in THIS frame rather than the value of
> the register in the PREVIOUS frame.
>
> They are simply convenience functions to make it easier to obtain a
> specified frame's register value.
>
> Thoughts?
I think it's a great idea. One thought...
> void
> +frame_read_unsigned_register (struct frame_info *frame, int regnum,
> + ULONGEST *val)
> +{
> + frame_unwind_unsigned_register (get_next_frame (frame), regnum, val);
> +}
So, the register belonging to this frame. That means the register
which would be in the hardware registers if this frame were current,
right? Should we allow NULL to imply the current frame?
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 6+ messages in thread* NULL selected/current frame; Was: [patch/rfc] Add frame_read_signed/unsigned_register(); convert h8300 to print_registers_info()
2002-10-23 8:21 ` Daniel Jacobowitz
@ 2002-10-23 9:48 ` Andrew Cagney
2002-10-23 9:50 ` Daniel Jacobowitz
0 siblings, 1 reply; 6+ messages in thread
From: Andrew Cagney @ 2002-10-23 9:48 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
>> void
>> +frame_read_unsigned_register (struct frame_info *frame, int regnum,
>> + ULONGEST *val)
>> +{
>> + frame_unwind_unsigned_register (get_next_frame (frame), regnum, val);
>> +}
>
>
> So, the register belonging to this frame.
Yes. The old roughly equivalent function was get_saved_register.
> That means the register
> which would be in the hardware registers if this frame were current,
> right?
To be pedantic, no. A frame's registers are ALWAYS found by unwinding
get_next_frame(FRAME). It just so happens that registers unwound from
get_next_frame(current_frame) come from the register cache.
The difference is subtle but important. current_frame isn't the special
case, get_next_frame(current_frame) is. Unfortunatly much of the GDB
code treated ``current_frame'' as special creating unnecessary
complexity and ongoing confusion. Per generic_unwind_get_saved_register():
/* Reached the the bottom (youngest, inner most) of the frame chain
(youngest, inner most) frame, go direct to the hardware register
cache (do not pass go, do not try to cache the value, ...). The
unwound value would have been cached in frame->next but that
doesn't exist. This doesn't matter as the hardware register
cache is stopping any unnecessary accesses to the target. */
/* NOTE: cagney/2002-04-14: It would be nice if, instead of a
special case, there was always an inner frame dedicated to the
hardware registers. Unfortunatly, there is too much unwind code
around that looks up/down the frame chain while making the
assumption that each frame level is using the same unwind code. */
> Should we allow NULL to imply the current frame?
Definitly no :-)
There is a bit of dogma here - there is always a frame. The above
should not be called with NULL. Code that calls this checks that
selected_frame != NULL. I'll add a ``gdb_assert (frame != NULL)'' and a
comment to that effect.
As for get_next_frame(FRAME), if that returns NULL, we've fallen off the
inner most frame and should get the register value from the register
cache. (Oh, while get_next_frame(current_frame) will always return
NULL, there may come a time when current_frame->next does not :-).
enjoy,
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: NULL selected/current frame; Was: [patch/rfc] Add frame_read_signed/unsigned_register(); convert h8300 to print_registers_info()
2002-10-23 9:48 ` NULL selected/current frame; Was: " Andrew Cagney
@ 2002-10-23 9:50 ` Daniel Jacobowitz
0 siblings, 0 replies; 6+ messages in thread
From: Daniel Jacobowitz @ 2002-10-23 9:50 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
On Wed, Oct 23, 2002 at 12:47:57PM -0400, Andrew Cagney wrote:
>
> >> void
> >>+frame_read_unsigned_register (struct frame_info *frame, int regnum,
> >>+ ULONGEST *val)
> >>+{
> >>+ frame_unwind_unsigned_register (get_next_frame (frame), regnum, val);
> >>+}
> >
> >
> >So, the register belonging to this frame.
>
> Yes. The old roughly equivalent function was get_saved_register.
>
> >That means the register
> >which would be in the hardware registers if this frame were current,
> >right?
>
> To be pedantic, no. A frame's registers are ALWAYS found by unwinding
> get_next_frame(FRAME). It just so happens that registers unwound from
> get_next_frame(current_frame) come from the register cache.
>
> The difference is subtle but important. current_frame isn't the special
> case, get_next_frame(current_frame) is. Unfortunatly much of the GDB
> code treated ``current_frame'' as special creating unnecessary
> complexity and ongoing confusion. Per generic_unwind_get_saved_register():
>
> /* Reached the the bottom (youngest, inner most) of the frame chain
> (youngest, inner most) frame, go direct to the hardware register
> cache (do not pass go, do not try to cache the value, ...). The
> unwound value would have been cached in frame->next but that
> doesn't exist. This doesn't matter as the hardware register
> cache is stopping any unnecessary accesses to the target. */
>
> /* NOTE: cagney/2002-04-14: It would be nice if, instead of a
> special case, there was always an inner frame dedicated to the
> hardware registers. Unfortunatly, there is too much unwind code
> around that looks up/down the frame chain while making the
> assumption that each frame level is using the same unwind code. */
>
> >Should we allow NULL to imply the current frame?
>
> Definitly no :-)
>
> There is a bit of dogma here - there is always a frame. The above
> should not be called with NULL. Code that calls this checks that
> selected_frame != NULL. I'll add a ``gdb_assert (frame != NULL)'' and a
> comment to that effect.
>
> As for get_next_frame(FRAME), if that returns NULL, we've fallen off the
> inner most frame and should get the register value from the register
> cache. (Oh, while get_next_frame(current_frame) will always return
> NULL, there may come a time when current_frame->next does not :-).
OK, I see where you're going, vis some of the comments about a "frame"
for the hardware registers. I can buy that. I like these new
functions...
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch/rfc] Add frame_read_signed/unsigned_register()
2002-10-22 20:00 [patch/rfc] Add frame_read_signed/unsigned_register(); convert h8300 to print_registers_info() Andrew Cagney
2002-10-23 8:21 ` Daniel Jacobowitz
@ 2002-10-31 12:11 ` Andrew Cagney
2002-10-31 12:24 ` [patch] Convert h8300 to print_registers_info() Andrew Cagney
2 siblings, 0 replies; 6+ messages in thread
From: Andrew Cagney @ 2002-10-31 12:11 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 795 bytes --]
> Hmm,
>
> (I think I might split this in two)
>
> The attached adds the methods:
>
> +extern void frame_read_signed_register (struct frame_info *frame,
> + int regnum, LONGEST *val);
> +extern void frame_read_unsigned_register (struct frame_info *frame,
> + int regnum, ULONGEST *val);
>
> These correspond to the frame_unwind_XXXX methods() except that they return the value of a register in THIS frame rather than the value of the register in the PREVIOUS frame.
>
> They are simply convenience functions to make it easier to obtain a specified frame's register value.
>
> Thoughts?
I've checked in the attatched. The additional comment and assertion
should address the questions DanielJ raised.
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 3213 bytes --]
2002-10-31 Andrew Cagney <cagney@redhat.com>
* frame.c (frame_read_unsigned_register): New function.
(frame_read_signed_register): New function.
* frame.h (frame_read_unsigned_register): Declare.
(frame_read_signed_register): Declare.
Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.18
diff -u -r1.18 frame.c
--- frame.c 25 Sep 2002 20:30:37 -0000 1.18
+++ frame.c 31 Oct 2002 19:53:11 -0000
@@ -153,6 +153,40 @@
}
void
+frame_read_unsigned_register (struct frame_info *frame, int regnum,
+ ULONGEST *val)
+{
+ /* NOTE: cagney/2002-10-31: There is a bit of dogma here - there is
+ always a frame. Both this, and the equivalent
+ frame_read_signed_register() function, can only be called with a
+ valid frame. If, for some reason, this function is called
+ without a frame then the problem isn't here, but rather in the
+ caller. It should of first created a frame and then passed that
+ in. */
+ /* NOTE: cagney/2002-10-31: As a side bar, keep in mind that the
+ ``current_frame'' should not be treated as a special case. While
+ ``get_next_frame (current_frame) == NULL'' currently holds, it
+ should, as far as possible, not be relied upon. In the future,
+ ``get_next_frame (current_frame)'' may instead simply return a
+ normal frame object that simply always gets register values from
+ the register cache. Consequently, frame code should try to avoid
+ tests like ``if get_next_frame() == NULL'' and instead just rely
+ on recursive frame calls (like the below code) when manipulating
+ a frame chain. */
+ gdb_assert (frame != NULL);
+ frame_unwind_unsigned_register (get_next_frame (frame), regnum, val);
+}
+
+void
+frame_read_signed_register (struct frame_info *frame, int regnum,
+ LONGEST *val)
+{
+ /* See note in frame_read_unsigned_register(). */
+ gdb_assert (frame != NULL);
+ frame_unwind_signed_register (get_next_frame (frame), regnum, val);
+}
+
+void
generic_unwind_get_saved_register (char *raw_buffer,
int *optimizedp,
CORE_ADDR *addrp,
Index: frame.h
===================================================================
RCS file: /cvs/src/src/gdb/frame.h,v
retrieving revision 1.26
diff -u -r1.26 frame.h
--- frame.h 2 Oct 2002 21:33:58 -0000 1.26
+++ frame.h 31 Oct 2002 19:53:11 -0000
@@ -366,6 +366,16 @@
extern int frame_register_read (struct frame_info *frame, int regnum,
void *buf);
+/* Return the value of register REGNUM that belongs to FRAME. The
+ value is obtained by unwinding the register from the next / more
+ inner frame. */
+/* NOTE: cagney/2002-09-13: Return void as one day these functions may
+ be changed to return an indication that the read succeeded. */
+extern void frame_read_signed_register (struct frame_info *frame,
+ int regnum, LONGEST *val);
+extern void frame_read_unsigned_register (struct frame_info *frame,
+ int regnum, ULONGEST *val);
+
/* Map between a frame register number and its name. A frame register
space is a superset of the cooked register space --- it also
includes builtin registers. */
^ permalink raw reply [flat|nested] 6+ messages in thread* [patch] Convert h8300 to print_registers_info()
2002-10-22 20:00 [patch/rfc] Add frame_read_signed/unsigned_register(); convert h8300 to print_registers_info() Andrew Cagney
2002-10-23 8:21 ` Daniel Jacobowitz
2002-10-31 12:11 ` [patch/rfc] Add frame_read_signed/unsigned_register() Andrew Cagney
@ 2002-10-31 12:24 ` Andrew Cagney
2 siblings, 0 replies; 6+ messages in thread
From: Andrew Cagney @ 2002-10-31 12:24 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 511 bytes --]
> The h8300-tdep.c target's ``info registers'' routines are then updated so that:
>
> - Use the frame_read_XXX_register() instead of read_register().
> `info registers' displays the registers of the selected frame and not the inner most frame.
>
> - Implement the current print_registers_info() interface
>
> Not sure how to test it though. Anyone want to try this?
FYI, I've checked in the attached. It turns out that:
(gdb) target sim
(gdb) frame 0
(gdb) info registers
lets you test it.
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 5939 bytes --]
2002-10-31 Andrew Cagney <cagney@redhat.com>
* h8300-tdep.c: Include "gdb_assert.h".
(h8300_print_register): Add gdbarch, file and frame parameters.
Use frame_read_unsigned_register to read the register's value.
Use fprintf_filtered to display output.
(h8300_print_registers_info): Replace h8300_do_registers_info.
(h8300_gdbarch_init): Set print_registers_info.
Index: h8300-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/h8300-tdep.c,v
retrieving revision 1.22
diff -u -r1.22 h8300-tdep.c
--- h8300-tdep.c 26 Oct 2002 17:19:27 -0000 1.22
+++ h8300-tdep.c 31 Oct 2002 20:18:30 -0000
@@ -34,6 +34,7 @@
#include "gdbcore.h"
#include "objfiles.h"
#include "gdbcmd.h"
+#include "gdb_assert.h"
/* Extra info which is saved in each frame_info. */
struct frame_extra_info
@@ -864,28 +865,38 @@
}
static void
-h8300_print_register (int regno)
+h8300_print_register (struct gdbarch *gdbarch, struct ui_file *file,
+ struct frame_info *frame, int regno)
{
- long val = read_register (regno);
+ ULONGEST rval;
+ long val;
const char *name = h8300_register_name (regno);
if (!name || !*name)
return;
- printf_filtered ("%-14s ", name);
+ /* FIXME: cagney/2002-10-22: The code below assumes that VAL is at
+ least 4 bytes (32 bits) in size and hence is large enough to hold
+ the largest h8300 register. Should instead be using ULONGEST and
+ the phex() functions. */
+ gdb_assert (sizeof (val) >= 4);
+ frame_read_unsigned_register (frame, regno, &rval);
+ val = rval;
+
+ fprintf_filtered (file, "%-14s ", name);
if (h8300hmode)
{
if (val)
- printf_filtered ("0x%08lx %-8ld", val, val);
+ fprintf_filtered (file, "0x%08lx %-8ld", val, val);
else
- printf_filtered ("0x%-8lx %-8ld", val, val);
+ fprintf_filtered (file, "0x%-8lx %-8ld", val, val);
}
else
{
if (val)
- printf_filtered ("0x%04lx %-4ld", val, val);
+ fprintf_filtered (file, "0x%04lx %-4ld", val, val);
else
- printf_filtered ("0x%-4lx %-4ld", val, val);
+ fprintf_filtered (file, "0x%-4lx %-4ld", val, val);
}
if (regno == E_CCR_REGNUM)
{
@@ -895,39 +906,39 @@
unsigned char l;
frame_register_read (selected_frame, regno, b);
l = b[REGISTER_VIRTUAL_SIZE (E_CCR_REGNUM) - 1];
- printf_unfiltered ("\t");
- printf_unfiltered ("I-%d ", (l & 0x80) != 0);
- printf_unfiltered ("UI-%d ", (l & 0x40) != 0);
- printf_unfiltered ("H-%d ", (l & 0x20) != 0);
- printf_unfiltered ("U-%d ", (l & 0x10) != 0);
+ fprintf_filtered (file, "\t");
+ fprintf_filtered (file, "I-%d ", (l & 0x80) != 0);
+ fprintf_filtered (file, "UI-%d ", (l & 0x40) != 0);
+ fprintf_filtered (file, "H-%d ", (l & 0x20) != 0);
+ fprintf_filtered (file, "U-%d ", (l & 0x10) != 0);
N = (l & 0x8) != 0;
Z = (l & 0x4) != 0;
V = (l & 0x2) != 0;
C = (l & 0x1) != 0;
- printf_unfiltered ("N-%d ", N);
- printf_unfiltered ("Z-%d ", Z);
- printf_unfiltered ("V-%d ", V);
- printf_unfiltered ("C-%d ", C);
+ fprintf_filtered (file, "N-%d ", N);
+ fprintf_filtered (file, "Z-%d ", Z);
+ fprintf_filtered (file, "V-%d ", V);
+ fprintf_filtered (file, "C-%d ", C);
if ((C | Z) == 0)
- printf_unfiltered ("u> ");
+ fprintf_filtered (file, "u> ");
if ((C | Z) == 1)
- printf_unfiltered ("u<= ");
+ fprintf_filtered (file, "u<= ");
if ((C == 0))
- printf_unfiltered ("u>= ");
+ fprintf_filtered (file, "u>= ");
if (C == 1)
- printf_unfiltered ("u< ");
+ fprintf_filtered (file, "u< ");
if (Z == 0)
- printf_unfiltered ("!= ");
+ fprintf_filtered (file, "!= ");
if (Z == 1)
- printf_unfiltered ("== ");
+ fprintf_filtered (file, "== ");
if ((N ^ V) == 0)
- printf_unfiltered (">= ");
+ fprintf_filtered (file, ">= ");
if ((N ^ V) == 1)
- printf_unfiltered ("< ");
+ fprintf_filtered (file, "< ");
if ((Z | (N ^ V)) == 0)
- printf_unfiltered ("> ");
+ fprintf_filtered (file, "> ");
if ((Z | (N ^ V)) == 1)
- printf_unfiltered ("<= ");
+ fprintf_filtered (file, "<= ");
}
else if (regno == E_EXR_REGNUM && h8300smode)
{
@@ -936,23 +947,24 @@
unsigned char l;
frame_register_read (selected_frame, regno, b);
l = b[REGISTER_VIRTUAL_SIZE (E_EXR_REGNUM) - 1];
- printf_unfiltered ("\t");
- printf_unfiltered ("T-%d - - - ", (l & 0x80) != 0);
- printf_unfiltered ("I2-%d ", (l & 4) != 0);
- printf_unfiltered ("I1-%d ", (l & 2) != 0);
- printf_unfiltered ("I0-%d", (l & 1) != 0);
+ fprintf_filtered (file, "\t");
+ fprintf_filtered (file, "T-%d - - - ", (l & 0x80) != 0);
+ fprintf_filtered (file, "I2-%d ", (l & 4) != 0);
+ fprintf_filtered (file, "I1-%d ", (l & 2) != 0);
+ fprintf_filtered (file, "I0-%d", (l & 1) != 0);
}
- printf_filtered ("\n");
+ fprintf_filtered (file, "\n");
}
static void
-h8300_do_registers_info (int regno, int cpregs)
+h8300_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
+ struct frame_info *frame, int regno, int cpregs)
{
if (regno < 0)
for (regno = 0; regno < E_NUM_REGS; ++regno)
- h8300_print_register (regno);
+ h8300_print_register (gdbarch, file, frame, regno);
else
- h8300_print_register (regno);
+ h8300_print_register (gdbarch, file, frame, regno);
}
static CORE_ADDR
@@ -1085,7 +1097,7 @@
set_gdbarch_register_virtual_size (gdbarch, h8300_register_raw_size);
set_gdbarch_max_register_virtual_size (gdbarch, h8300h_reg_size);
set_gdbarch_register_virtual_type (gdbarch, h8300_register_virtual_type);
- set_gdbarch_deprecated_do_registers_info (gdbarch, h8300_do_registers_info);
+ set_gdbarch_print_registers_info (gdbarch, h8300_print_registers_info);
set_gdbarch_print_float_info (gdbarch, h8300_print_float_info);
/*
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2002-10-31 20:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-22 20:00 [patch/rfc] Add frame_read_signed/unsigned_register(); convert h8300 to print_registers_info() Andrew Cagney
2002-10-23 8:21 ` Daniel Jacobowitz
2002-10-23 9:48 ` NULL selected/current frame; Was: " Andrew Cagney
2002-10-23 9:50 ` Daniel Jacobowitz
2002-10-31 12:11 ` [patch/rfc] Add frame_read_signed/unsigned_register() Andrew Cagney
2002-10-31 12:24 ` [patch] Convert h8300 to print_registers_info() Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox