From patchwork Wed Jul 18 23:26:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 28476 Received: (qmail 69707 invoked by alias); 18 Jul 2018 23:26:43 -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 69693 invoked by uid 89); 18 Jul 2018 23:26:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, 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; Wed, 18 Jul 2018 23:26:41 +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 592D687AAB for ; Wed, 18 Jul 2018 23:26:40 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01D582156893 for ; Wed, 18 Jul 2018 23:26:39 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [ob/pushed] Eliminate cleanup in gdbscm_execute_gdb_command Date: Thu, 19 Jul 2018 00:26:39 +0100 Message-Id: <20180718232639.7563-1-palves@redhat.com> Note: the "may be modified" comment is no longer true nowadays. gdb/ChangeLog: 2018-07-18 Pedro Alves * guile/guile.c (gdbscm_execute_gdb_command): Adjust to use gdbscm_wrap. Use gdb::unique_xmalloc_ptr instead of a cleanup. --- gdb/ChangeLog | 6 ++++++ gdb/guile/guile.c | 29 ++++++++--------------------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6d1a1c6df23..92c93f494f5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2018-07-18 Pedro Alves + + * guile/guile.c (gdbscm_execute_gdb_command): Adjust to use + gdbscm_wrap. Use gdb::unique_xmalloc_ptr instead of a + cleanup. + 2018-07-18 Pedro Alves * guile/guile-internal.h: Add comment about mixing GDB and Scheme diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c index 6b5faa38bcc..6353b35326b 100644 --- a/gdb/guile/guile.c +++ b/gdb/guile/guile.c @@ -289,22 +289,17 @@ gdbscm_execute_gdb_command (SCM command_scm, SCM rest) int from_tty = 0, to_string = 0; const SCM keywords[] = { from_tty_keyword, to_string_keyword, SCM_BOOL_F }; char *command; - struct cleanup *cleanups; - struct gdb_exception except = exception_none; gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, keywords, "s#tt", command_scm, &command, rest, &from_tty_arg_pos, &from_tty, &to_string_arg_pos, &to_string); - /* Note: The contents of "command" may get modified while it is - executed. */ - cleanups = make_cleanup (xfree, command); - - std::string to_string_res; - - TRY + return gdbscm_wrap ([=] { + gdb::unique_xmalloc_ptr command_holder (command); + std::string to_string_res; + scoped_restore restore_async = make_scoped_restore (¤t_ui->async, 0); @@ -316,19 +311,11 @@ gdbscm_execute_gdb_command (SCM command_scm, SCM rest) /* Do any commands attached to breakpoint we stopped at. */ bpstat_do_actions (); - } - CATCH (ex, RETURN_MASK_ALL) - { - except = ex; - } - END_CATCH - - do_cleanups (cleanups); - GDBSCM_HANDLE_GDB_EXCEPTION (except); - if (to_string) - return gdbscm_scm_from_c_string (to_string_res.c_str ()); - return SCM_UNSPECIFIED; + if (to_string) + return gdbscm_scm_from_c_string (to_string_res.c_str ()); + return SCM_UNSPECIFIED; + }); } /* (data-directory) -> string */