[patch/rfc] Add frame_register(); GET_SAVED_REGISTER() is a predicate

Andrew Cagney ac131313@redhat.com
Fri Nov 1 15:48:00 GMT 2002


Hello,

The attached patch adds a new function:

+/* Return the value of the register in this FRAME.  Convenience
+   function that is equivalent to frame_register_unwind
+   (get_next_frame (FRAME), ...).  If VALUEP is NULL, don't
+   fetch/compute the value.  */
+
+extern void frame_register (struct frame_info *frame, int regnum,
+                           int *optimizedp, enum lval_type *lvalp,
+                           CORE_ADDR *addrp, int *realnump,
+                           void *valuep);
+

This function is very like the existing frame_register_unwind() only it 
returns the value of REGNUM that belongs to FRAME and not the value that 
belongs to FRAME's caller.  Further, consistent with 
frame_register_unwind (and unlike get_saved_register()), it returns the 
registers actual location (register number) in REALNUM while 
GET_SAVED_REGISTER() was returning the register's offset (in the 
registers[] array).

The patch then modifies frame.c and valops.c to use the new function.

The reason for changing the existing GET_SAVED_REGISTER() to a predicate 
method is a bit nasty.  When a target architecture provides a 
GET_SAVED_REGISTER() method, the frame_register() function has no direct 
way of obtaining the register's REALNUM and hence is forced to compute 
that value using a simple lookup.   If an architecture does not provide 
GET_SAVED_REGISTER(), frame_register() can bypass all that mess and call 
the unwind code directly.

The valops.c change is even more, er, ammusing.  If you look at the 
patch as it stands, it should cause GDB to abort.  It turns out though, 
that GDB's testsuite contains no test to exercise those code paths and, 
consequently, that part of the change is very un tested.  I'm going to 
separate out the valops.c part of the change for the moment.

I'll look to commit the gdbarch and frame.[ch] parts in a few days.

Andrew
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: diffs
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20021101/35ebad5e/attachment.ksh>


More information about the Gdb-patches mailing list