From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 81162 invoked by alias); 25 May 2018 09:55:49 -0000 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 Received: (qmail 81120 invoked by uid 89); 25 May 2018 09:55:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 May 2018 09:55:48 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC3574187E41; Fri, 25 May 2018 09:55:46 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id EFB6F2166BB2; Fri, 25 May 2018 09:55:45 +0000 (UTC) Subject: Re: [RFA] Use TRY/CATCH in remove_prev_frame To: Tom Tromey , gdb-patches@sourceware.org References: <20180525033628.25677-1-tom@tromey.com> From: Pedro Alves Message-ID: <12d1f3f6-3d5b-6b0c-8cbc-7d3af668934e@redhat.com> Date: Fri, 25 May 2018 11:54:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180525033628.25677-1-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-05/txt/msg00660.txt.bz2 Quoting a "git diff -w" version of the patch, for easier context. On 05/25/2018 04:36 AM, Tom Tromey wrote: > diff --git a/gdb/frame.c b/gdb/frame.c > index 1d0eb725145..e55b4e16305 100644 > --- a/gdb/frame.c > +++ b/gdb/frame.c > @@ -1871,22 +1871,6 @@ frame_register_unwind_location (struct frame_info *this_frame, int regnum, > } > } > > -/* Called during frame unwinding to remove a previous frame pointer from a > - frame passed in ARG. */ > - > -static void > -remove_prev_frame (void *arg) > -{ > - struct frame_info *this_frame, *prev_frame; > - > - this_frame = (struct frame_info *) arg; > - prev_frame = this_frame->prev; > - gdb_assert (prev_frame != NULL); > - > - prev_frame->next = NULL; > - this_frame->prev = NULL; > -} > - > /* Get the previous raw frame, and check that it is not identical to > same other frame frame already in the chain. If it is, there is > most likely a stack cycle, so we discard it, and mark THIS_FRAME as > @@ -1899,7 +1883,6 @@ static struct frame_info * > get_prev_frame_if_no_cycle (struct frame_info *this_frame) > { > struct frame_info *prev_frame; > - struct cleanup *prev_frame_cleanup; > > prev_frame = get_prev_frame_raw (this_frame); > > @@ -1915,10 +1898,8 @@ get_prev_frame_if_no_cycle (struct frame_info *this_frame) > if (prev_frame->level == 0) > return prev_frame; > > - /* The cleanup will remove the previous frame that get_prev_frame_raw > - linked onto THIS_FRAME. */ > - prev_frame_cleanup = make_cleanup (remove_prev_frame, this_frame); > - > + TRY > + { > compute_frame_id (prev_frame); > if (!frame_stash_add (prev_frame)) > { > @@ -1936,8 +1917,19 @@ get_prev_frame_if_no_cycle (struct frame_info *this_frame) > this_frame->prev = NULL; > prev_frame = NULL; > } > + } > + CATCH (ex, RETURN_MASK_ERROR) Use RETURN_MASK_ALL. > + { > + prev_frame = this_frame->prev; > + gdb_assert (prev_frame != NULL); I think these two lines aren't necessary? It seems like they existed in remove_prev_frame because that needs to find the prev_frame from its passed-in argument, which is just this_frame. But here we already have prev_frame handy. OK with those changes. > + > + prev_frame->next = NULL; > + this_frame->prev = NULL; > + > + throw_exception (ex); > + } > + END_CATCH > > - discard_cleanups (prev_frame_cleanup); > return prev_frame; > } > >