From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30006 invoked by alias); 21 Feb 2007 16:24:47 -0000 Received: (qmail 29995 invoked by uid 22791); 21 Feb 2007 16:24:46 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 21 Feb 2007 16:24:39 +0000 Received: (qmail 10399 invoked from network); 21 Feb 2007 16:24:35 -0000 Received: from unknown (HELO localhost) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 21 Feb 2007 16:24:35 -0000 Date: Wed, 21 Feb 2007 16:24:00 -0000 From: Nathan Froyd To: gdb-patches@sourceware.org Subject: [PATCH] fix assertion when returning from initial frame Message-ID: <20070221162434.GL4200@sparrowhawk.codesourcery.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i 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: 2007-02/txt/msg00252.txt.bz2 The following patch fixes an assertion when a user attempts to return from the initial frame (or a frame for which GDB cannot find the previous frame due to limited debugging information). frame_pop always assumed that a previous frame could be found; it now checks that it actually finds a previous frame before proceeding. OK? (I do not have gdb commit privileges.) -Nathan 2007-02-21 Nathan Froyd * frame.c (frame_pop): Check to see whether there's a frame to which we can pop first. --- frame.c (revision 163834) +++ frame.c (local) @@ -524,13 +524,22 @@ frame_save_as_regcache (struct frame_inf void frame_pop (struct frame_info *this_frame) { + struct frame_info *prev_frame; + struct regcache *scratch; + struct cleanup *cleanups; + + /* Ensure that we have a frame to pop to. */ + prev_frame = get_prev_frame_1 (this_frame); + + if (!prev_frame) + error (_("Cannot pop the initial frame.")); + /* Make a copy of all the register values unwound from this frame. Save them in a scratch buffer so that there isn't a race between trying to extract the old values from the current_regcache while at the same time writing new values into that same cache. */ - struct regcache *scratch - = frame_save_as_regcache (get_prev_frame_1 (this_frame)); - struct cleanup *cleanups = make_cleanup_regcache_xfree (scratch); + scratch = frame_save_as_regcache (prev_frame); + cleanups = make_cleanup_regcache_xfree (scratch); /* FIXME: cagney/2003-03-16: It should be possible to tell the target's register cache that it is about to be hit with a burst