From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10518 invoked by alias); 9 Jul 2003 20:04:04 -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 10507 invoked from network); 9 Jul 2003 20:04:03 -0000 Received: from unknown (HELO localhost.redhat.com) (66.187.230.200) by sources.redhat.com with SMTP; 9 Jul 2003 20:04:03 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 10CEB2B5F for ; Wed, 9 Jul 2003 16:04:03 -0400 (EDT) Message-ID: <3F0C7533.4090003@redhat.com> Date: Wed, 09 Jul 2003 20:04:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030223 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [patch, rfc] frame attribute - FRAME_IS_CALLER Content-Type: multipart/mixed; boundary="------------020102050007020500030205" X-SW-Source: 2003-07/txt/msg00191.txt.bz2 This is a multi-part message in MIME format. --------------020102050007020500030205 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 447 Hello, Ref: Add frame_is_callee_p(), use in dwarf2-frame.c?, http://sources.redhat.com/ml/gdb-patches/2003-07/msg00046.html This patch adds a new `frame attribute' methods and defines one attribute `FRAME_IS_CALLER' (described in comment) (again better name?). It then uses it in a couple random places so that i know it is working. thoughts, The attached would be committed to the mainline, and just the new methods to the branch. Andrew --------------020102050007020500030205 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 5296 2003-07-09 Andrew Cagney * frame.c (frame_unwind_attrib, get_frame_attrib): New functions. (pc_notcurrent): Delete function. (find_frame_sal): Use get_frame_attrib instead of pc_notcurrent. * frame.h (frame_attrib): Define. (get_frame_attrib): Declare. (frame_unwind_attrib): Declare. * blockframe.c (frame_address_in_block): Use get_frame_attrib instead of get_frame_type. Index: blockframe.c =================================================================== RCS file: /cvs/src/src/gdb/blockframe.c,v retrieving revision 1.72 diff -u -r1.72 blockframe.c --- blockframe.c 23 May 2003 17:05:19 -0000 1.72 +++ blockframe.c 9 Jul 2003 19:56:01 -0000 @@ -179,15 +179,11 @@ /* If we are not in the innermost frame, and we are not interrupted by a signal, frame->pc points to the instruction following the - call. As a consequence, we need to get the address of the previous - instruction. Unfortunately, this is not straightforward to do, so - we just use the address minus one, which is a good enough - approximation. */ - /* FIXME: cagney/2002-11-10: Should this instead test for - NORMAL_FRAME? A dummy frame (in fact all the abnormal frames) - save the PC value in the block. */ - if (get_next_frame (frame) != 0 - && get_frame_type (get_next_frame (frame)) != SIGTRAMP_FRAME) + call. As a consequence, we need to get the address of the + previous instruction. Unfortunately, this is not straightforward + to do, so we just use the address minus one, which is a good + enough approximation. */ + if (get_frame_attrib (frame, FRAME_IS_CALLER)) --pc; return pc; Index: frame.c =================================================================== RCS file: /cvs/src/src/gdb/frame.c,v retrieving revision 1.130 diff -u -r1.130 frame.c --- frame.c 7 Jul 2003 20:07:12 -0000 1.130 +++ frame.c 9 Jul 2003 19:56:01 -0000 @@ -2006,8 +2006,8 @@ return frame_pc_unwind (frame->next); } -static int -pc_notcurrent (struct frame_info *frame) +void +find_frame_sal (struct frame_info *frame, struct symtab_and_line *sal) { /* If FRAME is not the innermost frame, that normally means that FRAME->pc points at the return instruction (which is *after* the @@ -2018,15 +2018,8 @@ PC and such a PC indicates the current (rather than next) instruction/line, consequently, for such cases, want to get the line containing fi->pc. */ - struct frame_info *next = get_next_frame (frame); - int notcurrent = (next != NULL && get_frame_type (next) == NORMAL_FRAME); - return notcurrent; -} - -void -find_frame_sal (struct frame_info *frame, struct symtab_and_line *sal) -{ - (*sal) = find_pc_line (get_frame_pc (frame), pc_notcurrent (frame)); + int pc_notcurrent = get_frame_attrib (frame, FRAME_IS_CALLER); + (*sal) = find_pc_line (get_frame_pc (frame), pc_notcurrent); } /* Per "frame.h", return the ``address'' of the frame. Code should @@ -2139,6 +2132,33 @@ { /* Arrrg! See comment in "frame.h". */ frame->type = type; +} + +int +get_frame_attrib (struct frame_info *this_frame, enum frame_attrib attrib) +{ + return frame_unwind_attrib (this_frame->next, attrib); +} + +int +frame_unwind_attrib (struct frame_info *next_frame, enum frame_attrib attrib) +{ + switch (attrib) + { + case FRAME_IS_CALLER: + /* If the next frame is a sentinel, this frame can't be a + caller. */ + if (next_frame->level < 0) + return 0; + /* If the next frame isn't normal, this frame can't be a caller. + Use get_frame_type because that hides NORMAL_FRAME. */ + if (get_frame_type (next_frame) != NORMAL_FRAME) + return 0; + /* Hope its a call frame. */ + return 1; + default: + internal_error (__FILE__, __LINE__, "bad switch"); + } } struct frame_extra_info * Index: frame.h =================================================================== RCS file: /cvs/src/src/gdb/frame.h,v retrieving revision 1.104 diff -u -r1.104 frame.h --- frame.h 7 Jul 2003 14:36:58 -0000 1.104 +++ frame.h 9 Jul 2003 19:56:03 -0000 @@ -322,6 +322,27 @@ }; extern enum frame_type get_frame_type (struct frame_info *); +/* Frame attributes. These can be tested individually. Please use + this in preference to the frame type. */ + +enum frame_attrib +{ + /* THIS is a "caller frame". It executed a "call" instruction as + part of creating the NEXT frame (which is the "callee"). Unlike + other categories of frames, this frame's PC value does not need + to point at valid code. For instance, if the callee is no-return + and the caller (this frame) is at the end of the function, any + code after the function call instruction may have been eliminated + by the compiler leaving this frame's PC pointing outside of the + current function or even into the next function. */ + FRAME_IS_CALLER +}; + +extern int get_frame_attrib (struct frame_info *this_frame, + enum frame_attrib attrib); +extern int frame_unwind_attrib (struct frame_info *next_frame, + enum frame_attrib attrib); + /* FIXME: cagney/2002-11-10: Some targets want to directly mark a frame as being of a specific type. This shouldn't be necessary. PC_IN_SIGTRAMP() indicates a SIGTRAMP_FRAME and --------------020102050007020500030205--