From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5512 invoked by alias); 2 Jul 2002 19:12:46 -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 5298 invoked from network); 2 Jul 2002 19:12:26 -0000 Received: from unknown (HELO takamaka.act-europe.fr) (142.179.108.207) by sources.redhat.com with SMTP; 2 Jul 2002 19:12:26 -0000 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id 386B2D2F70; Tue, 2 Jul 2002 12:12:18 -0700 (PDT) Date: Tue, 02 Jul 2002 12:12:00 -0000 From: Joel Brobecker To: Jim Blandy Cc: Andrew Cagney , gdb-patches@sources.redhat.com Subject: Re: [RFA] block_innermost_frame tweak Message-ID: <20020702191217.GQ17987@gnat.com> References: <20020620131440.M397@gnat.com> <3D126D8A.9020908@cygnus.com> <3D138B65.8070401@cygnus.com> <3D13AEE9.10209@cygnus.com> <20020702174116.GP17987@gnat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="/04w6evG8XlLl3ft" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i X-SW-Source: 2002-07/txt/msg00038.txt.bz2 --/04w6evG8XlLl3ft Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 977 > The latter is the name we all agreed on, right? I think it's okay, > then. That's what I understood, but not being a native english speaker, I sometime have doubts about what I understand. I committed the attached change (I'll try to remember to add the attachement this time :). Basically, I just did a search and replace to use the name we agreed on. 2002-07-02 Joel Brobecker * frame.h (frame_address_in_block): New function. * blockframe.c (frame_address_in_block): New function extracted from get_frame_block(). (get_frame_block): Use frame_address_in_block(). (block_innermost_frame): Use frame_address_in_block() to match the frame pc address against the block boundaries rather than the frame pc directly. This prevents a failure when a frame pc is actually a return-address pointing immediately after the end of the given block. Thanks for the feedback, -- Joel --/04w6evG8XlLl3ft Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="frame.diff" Content-length: 3553 Index: frame.h =================================================================== RCS file: /cvs/src/src/gdb/frame.h,v retrieving revision 1.20 diff -c -3 -p -r1.20 frame.h *** frame.h 18 Jun 2002 09:04:24 -0000 1.20 --- frame.h 2 Jul 2002 18:21:32 -0000 *************** extern struct symbol *get_frame_function *** 250,255 **** --- 250,257 ---- extern CORE_ADDR get_frame_pc (struct frame_info *); + extern CORE_ADDR frame_address_in_block (struct frame_info *); + extern CORE_ADDR get_pc_function_start (CORE_ADDR); extern struct block *block_for_pc (CORE_ADDR); Index: blockframe.c =================================================================== RCS file: /cvs/src/src/gdb/blockframe.c,v retrieving revision 1.29 diff -c -3 -p -r1.29 blockframe.c *** blockframe.c 8 Jun 2002 18:30:14 -0000 1.29 --- blockframe.c 2 Jul 2002 18:21:32 -0000 *************** get_frame_pc (struct frame_info *frame) *** 528,533 **** --- 528,553 ---- return frame->pc; } + /* return the address of the PC for the given FRAME, ie the current PC value + if FRAME is the innermost frame, or the address adjusted to point to the + call instruction if not. */ + + CORE_ADDR + frame_address_in_block (struct frame_info *frame) + { + CORE_ADDR pc = frame->pc; + + /* 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. */ + if (frame->next != 0 && frame->next->signal_handler_caller == 0) + --pc; + + return pc; + } #ifdef FRAME_FIND_SAVED_REGS /* XXX - deprecated. This is a compatibility function for targets *************** get_frame_saved_regs (struct frame_info *** 576,592 **** struct block * get_frame_block (struct frame_info *frame, CORE_ADDR *addr_in_block) { ! CORE_ADDR pc; ! ! pc = frame->pc; ! if (frame->next != 0 && frame->next->signal_handler_caller == 0) ! /* We are not in the innermost frame and we were not interrupted ! by a signal. We need to subtract one to get the correct block, ! in case the call instruction was the last instruction of the block. ! If there are any machines on which the saved pc does not point to ! after the call insn, we probably want to make frame->pc point after ! the call insn anyway. */ ! --pc; if (addr_in_block) *addr_in_block = pc; --- 596,602 ---- struct block * get_frame_block (struct frame_info *frame, CORE_ADDR *addr_in_block) { ! const CORE_ADDR pc = frame_address_in_block (frame); if (addr_in_block) *addr_in_block = pc; *************** block_innermost_frame (struct block *blo *** 970,975 **** --- 980,986 ---- struct frame_info *frame; register CORE_ADDR start; register CORE_ADDR end; + CORE_ADDR calling_pc; if (block == NULL) return NULL; *************** block_innermost_frame (struct block *blo *** 983,989 **** frame = get_prev_frame (frame); if (frame == NULL) return NULL; ! if (frame->pc >= start && frame->pc < end) return frame; } } --- 994,1001 ---- frame = get_prev_frame (frame); if (frame == NULL) return NULL; ! calling_pc = frame_address_in_block (frame); ! if (calling_pc >= start && calling_pc < end) return frame; } } --/04w6evG8XlLl3ft--