From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111470 invoked by alias); 25 May 2018 03:36:47 -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 87935 invoked by uid 89); 25 May 2018 03:36:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway31.websitewelcome.com Received: from gateway31.websitewelcome.com (HELO gateway31.websitewelcome.com) (192.185.143.31) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 May 2018 03:36:37 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 7408531396 for ; Thu, 24 May 2018 22:36:35 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id M3WtfwIbtVTw5M3Wtf5Qiz; Thu, 24 May 2018 22:36:35 -0500 X-Authority-Reason: nr=8 Received: from 174-29-44-154.hlrn.qwest.net ([174.29.44.154]:46050 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fM3Wt-002dG6-83; Thu, 24 May 2018 22:36:35 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Use TRY/CATCH in remove_prev_frame Date: Fri, 25 May 2018 09:55:00 -0000 Message-Id: <20180525033628.25677-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fM3Wt-002dG6-83 X-Source-Sender: 174-29-44-154.hlrn.qwest.net (bapiya.Home) [174.29.44.154]:46050 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-SW-Source: 2018-05/txt/msg00658.txt.bz2 This changes remove_prev_frame to use TRY/CATCH instead of a cleanup. TRY/CATCH seemed appropriate here because the cleanup is only needed in the case where an exception is thrown. Tested by the buildbot. ChangeLog 2018-05-24 Tom Tromey * frame.c (remove_prev_frame): Remove. (get_prev_frame_if_no_cycle): Use TRY/CATCH. --- gdb/ChangeLog | 5 +++++ gdb/frame.c | 58 +++++++++++++++++++++++++--------------------------------- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/gdb/frame.c b/gdb/frame.c index 1d0eb72514..e55b4e1630 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,29 +1898,38 @@ 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); - - compute_frame_id (prev_frame); - if (!frame_stash_add (prev_frame)) + TRY { - /* Another frame with the same id was already in the stash. We just - detected a cycle. */ - if (frame_debug) + compute_frame_id (prev_frame); + if (!frame_stash_add (prev_frame)) { - fprintf_unfiltered (gdb_stdlog, "-> "); - fprint_frame (gdb_stdlog, NULL); - fprintf_unfiltered (gdb_stdlog, " // this frame has same ID }\n"); + /* Another frame with the same id was already in the stash. We just + detected a cycle. */ + if (frame_debug) + { + fprintf_unfiltered (gdb_stdlog, "-> "); + fprint_frame (gdb_stdlog, NULL); + fprintf_unfiltered (gdb_stdlog, " // this frame has same ID }\n"); + } + this_frame->stop_reason = UNWIND_SAME_ID; + /* Unlink. */ + prev_frame->next = NULL; + this_frame->prev = NULL; + prev_frame = NULL; } - this_frame->stop_reason = UNWIND_SAME_ID; - /* Unlink. */ + } + CATCH (ex, RETURN_MASK_ERROR) + { + prev_frame = this_frame->prev; + gdb_assert (prev_frame != NULL); + prev_frame->next = NULL; this_frame->prev = NULL; - prev_frame = NULL; + + throw_exception (ex); } + END_CATCH - discard_cleanups (prev_frame_cleanup); return prev_frame; } -- 2.13.6