From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26871 invoked by alias); 10 Dec 2003 17:42:22 -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 26864 invoked from network); 10 Dec 2003 17:42:20 -0000 Received: from unknown (HELO takamaka.act-europe.fr) (205.232.38.116) by sources.redhat.com with SMTP; 10 Dec 2003 17:42:20 -0000 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id 8880C47D62; Wed, 10 Dec 2003 12:42:20 -0500 (EST) Date: Wed, 10 Dec 2003 17:42:00 -0000 From: Joel Brobecker To: Andrew Cagney Cc: Michael Snyder , gdb-patches@sources.redhat.com Subject: Re: [RFC] Unexpected automatic language switch - get_frame_language() Message-ID: <20031210174220.GG1296@gnat.com> References: <20031205224807.GE716@gnat.com> <3FD11B60.2040008@redhat.com> <20031206001815.GF716@gnat.com> <3FD12296.8090809@gnu.org> <20031210015055.GB842@gnat.com> <3FD74659.9020900@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="VbJkn9YxBvnuCH5J" Content-Disposition: inline In-Reply-To: <3FD74659.9020900@gnu.org> User-Agent: Mutt/1.4i X-SW-Source: 2003-12/txt/msg00293.txt.bz2 --VbJkn9YxBvnuCH5J Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 551 > >2003-12-09 J. Brobecker > > > > * frame.c (select_frame): Get the current frame PC using > > get_frame_address_in_block() instead of get_frame_pc(). > > * stack.c (get_frame_language): Likewise. > > > >Tested on x86-linux, with no regression. > > > >OK to apply? > > Yes, but just add a comment at each point reminding us why the PC is > wrong before committing. Thanks. Here is the patch that I ended up committing. Let me know if somebody would like the comments to be worded differently. -- Joel --VbJkn9YxBvnuCH5J Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="addr_in_block.diff" Content-length: 2079 Index: frame.c =================================================================== RCS file: /cvs/src/src/gdb/frame.c,v retrieving revision 1.152 diff -u -p -r1.152 frame.c --- frame.c 23 Nov 2003 21:49:12 -0000 1.152 +++ frame.c 10 Dec 2003 17:21:46 -0000 @@ -917,7 +917,13 @@ select_frame (struct frame_info *fi) source language of this frame, and switch to it if desired. */ if (fi) { - s = find_pc_symtab (get_frame_pc (fi)); + /* We retrieve the frame's symtab by using the frame PC. However + we cannot use the frame pc as is, because it usually points to + the instruction following the "call", which is sometimes the + first instruction of another function. So we rely on + get_frame_address_in_block() which provides us with a PC which + is guaranteed to be inside the frame's code block. */ + s = find_pc_symtab (get_frame_address_in_block (fi)); if (s && s->language != current_language->la_language && s->language != language_unknown Index: stack.c =================================================================== RCS file: /cvs/src/src/gdb/stack.c,v retrieving revision 1.97 diff -u -p -r1.97 stack.c --- stack.c 23 Nov 2003 20:41:17 -0000 1.97 +++ stack.c 10 Dec 2003 17:21:47 -0000 @@ -2036,7 +2036,14 @@ get_frame_language (void) if (deprecated_selected_frame) { - s = find_pc_symtab (get_frame_pc (deprecated_selected_frame)); + /* We determine the current frame language by looking up its + associated symtab. To retrieve this symtab, we use the frame PC. + However we cannot use the frame pc as is, because it usually points + to the instruction following the "call", which is sometimes the first + instruction of another function. So we rely on + get_frame_address_in_block(), it provides us with a PC which is + guaranteed to be inside the frame's code block. */ + s = find_pc_symtab (get_frame_address_in_block (deprecated_selected_frame)); if (s) flang = s->language; else --VbJkn9YxBvnuCH5J--