2002-10-31 Andrew Cagney <cagney@redhat.com>
authorAndrew Cagney <cagney@redhat.com>
Thu, 31 Oct 2002 20:14:33 +0000 (20:14 +0000)
committerAndrew Cagney <cagney@redhat.com>
Thu, 31 Oct 2002 20:14:33 +0000 (20:14 +0000)
* 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.

gdb/ChangeLog
gdb/frame.c
gdb/frame.h

index 1a9f050..5318c8a 100644 (file)
@@ -1,5 +1,12 @@
 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.
+
+2002-10-31  Andrew Cagney  <cagney@redhat.com>
+
        * h8500-tdep.c (h8500_print_registers_info): New static function,
        clone of infcmd.c's default_print_registers_info.
        (h8500_do_registers_info): New funtion.
index 1ad3b09..9a5914c 100644 (file)
@@ -153,6 +153,40 @@ frame_unwind_unsigned_register (struct frame_info *frame, int regnum,
 }
 
 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 849566b..12c8149 100644 (file)
@@ -366,6 +366,16 @@ extern void get_saved_register (char *raw_buffer, int *optimized,
 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.  */