From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11657 invoked by alias); 31 Oct 2002 20:11:59 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 11621 invoked from network); 31 Oct 2002 20:11:58 -0000 Received: from unknown (HELO localhost.redhat.com) (216.138.202.10) by sources.redhat.com with SMTP; 31 Oct 2002 20:11:58 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 2D08C3C9D for ; Thu, 31 Oct 2002 15:11:56 -0500 (EST) Message-ID: <3DC18E8C.7040300@redhat.com> Date: Thu, 31 Oct 2002 12:11:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.0) Gecko/20020824 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [patch/rfc] Add frame_read_signed/unsigned_register() References: <3DB610B9.5040906@redhat.com> Content-Type: multipart/mixed; boundary="------------030409060102090409060504" X-SW-Source: 2002-10/txt/msg00608.txt.bz2 This is a multi-part message in MIME format. --------------030409060102090409060504 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 795 > 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 --------------030409060102090409060504 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 3213 2002-10-31 Andrew Cagney * 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. */ --------------030409060102090409060504--