From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27575 invoked by alias); 9 Mar 2011 14:22:04 -0000 Received: (qmail 27566 invoked by uid 22791); 9 Mar 2011 14:22:02 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 09 Mar 2011 14:21:58 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p29ELvRA017578 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 9 Mar 2011 09:21:57 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p29ELu8H013427; Wed, 9 Mar 2011 09:21:56 -0500 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p29ELtVN032443; Wed, 9 Mar 2011 09:21:56 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id 99A2C3782A7; Wed, 9 Mar 2011 07:21:55 -0700 (MST) From: Tom Tromey To: Jan Kratochvil Cc: gdb-patches@sourceware.org Subject: Re: RFC: lazily call save_current_space_and_thread References: <20110305125239.GA31797@host1.jankratochvil.net> Date: Wed, 09 Mar 2011 14:43:00 -0000 In-Reply-To: (Tom Tromey's message of "Tue, 08 Mar 2011 09:51:56 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-03/txt/msg00601.txt.bz2 >>>>> "Tom" == Tom Tromey writes: Tom> This patch makes make_cleanup_restore_current_thread more efficient, by Tom> having it not compute the current frame when there is no selected frame. Tom> This approach let me remove another hack I had in my tree. I am checking in this revised version. I made the changes Jan and Pedro suggested. Built and regtested on x86-64 (compile farm). Tom 2011-03-09 Tom Tromey * thread.c (restore_selected_frame): Handle frame_level == -1. (make_cleanup_restore_current_thread): Use get_selected_frame_if_set. * frame.h (get_selected_frame_if_set): Declare. * frame.c (get_selected_frame_if_set): New function. Index: frame.c =================================================================== RCS file: /cvs/src/src/gdb/frame.c,v retrieving revision 1.291 diff -u -r1.291 frame.c --- frame.c 7 Jan 2011 19:36:17 -0000 1.291 +++ frame.c 9 Mar 2011 14:21:33 -0000 @@ -1247,6 +1247,14 @@ return selected_frame; } +/* If there is a selected frame, return it. Otherwise, return NULL. */ + +struct frame_info * +get_selected_frame_if_set (void) +{ + return selected_frame; +} + /* This is a variant of get_selected_frame() which can be called when the inferior does not have a frame; in that case it will return NULL instead of calling error(). */ Index: frame.h =================================================================== RCS file: /cvs/src/src/gdb/frame.h,v retrieving revision 1.188 diff -u -r1.188 frame.h --- frame.h 27 Feb 2011 16:25:37 -0000 1.188 +++ frame.h 9 Mar 2011 14:21:33 -0000 @@ -260,6 +260,9 @@ and then return that thread's previously selected frame. */ extern struct frame_info *get_selected_frame (const char *message); +/* If there is a selected frame, return it. Otherwise, return NULL. */ +extern struct frame_info *get_selected_frame_if_set (void); + /* Select a specific frame. NULL, apparently implies re-select the inner most frame. */ extern void select_frame (struct frame_info *); Index: thread.c =================================================================== RCS file: /cvs/src/src/gdb/thread.c,v retrieving revision 1.136 diff -u -r1.136 thread.c --- thread.c 21 Feb 2011 23:40:46 -0000 1.136 +++ thread.c 9 Mar 2011 14:21:33 -0000 @@ -1019,6 +1019,13 @@ struct frame_info *frame = NULL; int count; + /* This means there was no selected frame. */ + if (frame_level == -1) + { + select_frame (NULL); + return; + } + gdb_assert (frame_level >= 0); /* Restore by level first, check if the frame id is the same as @@ -1137,7 +1144,14 @@ && target_has_registers && target_has_stack && target_has_memory) - frame = get_selected_frame (NULL); + { + /* When processing internal events, there might not be a + selected frame. If we naively call get_selected_frame + here, then we can end up reading debuginfo for the + current frame, but we don't generally need the debuginfo + at this point. */ + frame = get_selected_frame_if_set (); + } else frame = NULL;