From patchwork Sat Apr 21 22:39:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 26900 Received: (qmail 28975 invoked by alias); 21 Apr 2018 22:39:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 28965 invoked by uid 89); 21 Apr 2018 22:39:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 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=sk:lookup_, Hx-languages-length:2451, xfree X-HELO: gateway23.websitewelcome.com Received: from gateway23.websitewelcome.com (HELO gateway23.websitewelcome.com) (192.185.49.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 21 Apr 2018 22:39:40 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway23.websitewelcome.com (Postfix) with ESMTP id E392ABF54 for ; Sat, 21 Apr 2018 17:39:38 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id A1AQf2L2B5CKDA1AQfatev; Sat, 21 Apr 2018 17:39:38 -0500 X-Authority-Reason: nr=8 Received: from 97-122-176-117.hlrn.qwest.net ([97.122.176.117]:51634 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fA1AQ-003UX6-MF; Sat, 21 Apr 2018 17:39:38 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Remove a cleanup from scm-frame.c Date: Sat, 21 Apr 2018 16:39:36 -0600 Message-Id: <20180421223936.31584-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fA1AQ-003UX6-MF X-Source-Sender: 97-122-176-117.hlrn.qwest.net (bapiya.Home) [97.122.176.117]:51634 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This removes a cleanup from scm-frame.c, replacing it with unique_xmalloc_ptr and a new scope. I believe this also fixes a latent bug involving calling do_cleanups twice for a single cleanup. Regression tested using the gdb.guile test suite on x86-64 Fedora 26. ChangeLog 2018-04-21 Tom Tromey * guile/scm-frame.c (gdbscm_frame_read_var): Use gdb::unique_xmalloc_ptr. --- gdb/ChangeLog | 5 +++++ gdb/guile/scm-frame.c | 54 ++++++++++++++++++++++++--------------------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c index 4f4766aceb..7b539677ff 100644 --- a/gdb/guile/scm-frame.c +++ b/gdb/guile/scm-frame.c @@ -877,7 +877,6 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest) } else if (scm_is_string (symbol_scm)) { - char *var_name; const struct block *block = NULL; struct cleanup *cleanup; struct gdb_exception except = exception_none; @@ -893,38 +892,35 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest) gdbscm_throw (except_scm); } - var_name = gdbscm_scm_to_c_string (symbol_scm); - cleanup = make_cleanup (xfree, var_name); - /* N.B. Between here and the call to do_cleanups, don't do anything - to cause a Scheme exception without performing the cleanup. */ + { + gdb::unique_xmalloc_ptr var_name + (gdbscm_scm_to_c_string (symbol_scm)); + /* N.B. Between here and the end of the scope, don't do anything + to cause a Scheme exception. */ + + TRY + { + struct block_symbol lookup_sym; + + if (block == NULL) + block = get_frame_block (frame, NULL); + lookup_sym = lookup_symbol (var_name.get (), block, VAR_DOMAIN, + NULL); + var = lookup_sym.symbol; + block = lookup_sym.block; + } + CATCH (ex, RETURN_MASK_ALL) + { + except = ex; + } + END_CATCH + } - TRY - { - struct block_symbol lookup_sym; - - if (block == NULL) - block = get_frame_block (frame, NULL); - lookup_sym = lookup_symbol (var_name, block, VAR_DOMAIN, NULL); - var = lookup_sym.symbol; - block = lookup_sym.block; - } - CATCH (ex, RETURN_MASK_ALL) - { - except = ex; - } - END_CATCH - - do_cleanups (cleanup); GDBSCM_HANDLE_GDB_EXCEPTION (except); if (var == NULL) - { - do_cleanups (cleanup); - gdbscm_out_of_range_error (FUNC_NAME, 0, symbol_scm, - _("variable not found")); - } - - do_cleanups (cleanup); + gdbscm_out_of_range_error (FUNC_NAME, 0, symbol_scm, + _("variable not found")); } else {