From patchwork Sun Sep 10 21:50:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 22810 Received: (qmail 42194 invoked by alias); 10 Sep 2017 21:50:50 -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 41844 invoked by uid 89); 10 Sep 2017 21:50:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=H*MI:sk:2017091, 2111, Arrange X-HELO: gproxy7-pub.mail.unifiedlayer.com Received: from gproxy7-pub.mail.unifiedlayer.com (HELO gproxy7-pub.mail.unifiedlayer.com) (70.40.196.235) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 10 Sep 2017 21:50:46 +0000 Received: from CMOut01 (unknown [10.0.90.82]) by gproxy7.mail.unifiedlayer.com (Postfix) with ESMTP id 781F2215C0E for ; Sun, 10 Sep 2017 15:50:44 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id 7xqh1w0012f2jeq01xqkb1; Sun, 10 Sep 2017 15:50:44 -0600 X-Authority-Analysis: v=2.2 cv=K4VSJ2eI c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=2JCJgTwv5E4A:10 a=zstS-IiYAAAA:8 a=13KGAo4DAAAA:8 a=-70PPxosVGSiXztxGxoA:9 a=cNAr749fJOqtL50H:21 a=MU64XZ0wksjJ3A0g:21 a=4G6NA9xxw8l3yy4pmD5M:22 a=DdAeqqNASC6T8jxox_Jq:22 Received: from 75-166-76-94.hlrn.qwest.net ([75.166.76.94]:39396 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1drA7k-0020eg-RN; Sun, 10 Sep 2017 15:50:40 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 1/8] Change setup_breakpoint_reporting to return a scoped_restore Date: Sun, 10 Sep 2017 15:50:30 -0600 Message-Id: <20170910215037.24329-2-tom@tromey.com> In-Reply-To: <20170910215037.24329-1-tom@tromey.com> References: <20170910215037.24329-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1drA7k-0020eg-RN X-Source-Sender: 75-166-76-94.hlrn.qwest.net (bapiya.Home) [75.166.76.94]:39396 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This changes setup_breakpoint_reporting to return a scoped_restore, allowing for some cleanup removal. ChangeLog 2017-09-10 Tom Tromey * mi/mi-cmd-catch.c (mi_cmd_catch_assert) (mi_cmd_catch_exception, mi_catch_load_unload): Update. * mi/mi-cmd-break.c (setup_breakpoint_reporting): Return a scoped_restore. (mi_cmd_break_insert_1): Update. * mi/mi-cmd-break.h (setup_breakpoint_reporting): Return a scoped_restore. --- gdb/ChangeLog | 10 ++++++++++ gdb/mi/mi-cmd-break.c | 14 +++++--------- gdb/mi/mi-cmd-break.h | 3 ++- gdb/mi/mi-cmd-catch.c | 10 +++------- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1781ddd..80d615b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2017-09-10 Tom Tromey + + * mi/mi-cmd-catch.c (mi_cmd_catch_assert) + (mi_cmd_catch_exception, mi_catch_load_unload): Update. + * mi/mi-cmd-break.c (setup_breakpoint_reporting): Return a + scoped_restore. + (mi_cmd_break_insert_1): Update. + * mi/mi-cmd-break.h (setup_breakpoint_reporting): Return a + scoped_restore. + 2017-09-10 Andrew Burgess * utils.c (abort_with_message): Don't compare gdb_stderr to NULL, diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index 560174e..bae8711 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -64,26 +64,22 @@ enum bp_type }; /* Arrange for all new breakpoints and catchpoints to be reported to - CURRENT_UIOUT until the cleanup returned by this function is run. + CURRENT_UIOUT until the destructor of the returned scoped_restore + is run. Note that MI output will be probably invalid if more than one breakpoint is created inside one MI command. */ -struct cleanup * +scoped_restore_tmpl setup_breakpoint_reporting (void) { - struct cleanup *rev_flag; - if (! mi_breakpoint_observers_installed) { observer_attach_breakpoint_created (breakpoint_notify); mi_breakpoint_observers_installed = 1; } - rev_flag = make_cleanup_restore_integer (&mi_can_breakpoint_notify); - mi_can_breakpoint_notify = 1; - - return rev_flag; + return make_scoped_restore (&mi_can_breakpoint_notify, 1); } @@ -301,7 +297,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) } /* Now we have what we need, let's insert the breakpoint! */ - setup_breakpoint_reporting (); + scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting (); if (tracepoint) { diff --git a/gdb/mi/mi-cmd-break.h b/gdb/mi/mi-cmd-break.h index 6fb30c8..2394074 100644 --- a/gdb/mi/mi-cmd-break.h +++ b/gdb/mi/mi-cmd-break.h @@ -21,10 +21,11 @@ #ifndef MI_CMD_BREAK_H #define MI_CMD_BREAK_H +#include "common/scoped_restore.h" /* Setup the reporting of the insertion of a new breakpoint or catchpoint. */ -struct cleanup *setup_breakpoint_reporting (void); +scoped_restore_tmpl setup_breakpoint_reporting (void); #endif diff --git a/gdb/mi/mi-cmd-catch.c b/gdb/mi/mi-cmd-catch.c index a767ee7..0e1fb7e 100644 --- a/gdb/mi/mi-cmd-catch.c +++ b/gdb/mi/mi-cmd-catch.c @@ -79,7 +79,7 @@ mi_cmd_catch_assert (const char *cmd, char *argv[], int argc) if (oind != argc) error (_("Invalid argument: %s"), argv[oind]); - setup_breakpoint_reporting (); + scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting (); /* create_ada_exception_catchpoint needs CONDITION to be xstrdup'ed, and will assume control of its lifetime. */ if (condition != NULL) @@ -156,7 +156,7 @@ mi_cmd_catch_exception (const char *cmd, char *argv[], int argc) if (ex_kind == ada_catch_exception_unhandled && exception_name != NULL) error (_("\"-e\" and \"-u\" are mutually exclusive")); - setup_breakpoint_reporting (); + scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting (); /* create_ada_exception_catchpoint needs EXCEPTION_NAME and CONDITION to be xstrdup'ed, and will assume control of their lifetime. */ if (exception_name != NULL) @@ -173,7 +173,6 @@ mi_cmd_catch_exception (const char *cmd, char *argv[], int argc) static void mi_catch_load_unload (int load, char *argv[], int argc) { - struct cleanup *back_to; const char *actual_cmd = load ? "-catch-load" : "-catch-unload"; int temp = 0; int enabled = 1; @@ -215,11 +214,8 @@ mi_catch_load_unload (int load, char *argv[], int argc) if (oind < argc -1) error (_("-catch-load/unload: Garbage following the ")); - back_to = setup_breakpoint_reporting (); - + scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting (); add_solib_catchpoint (argv[oind], load, temp, enabled); - - do_cleanups (back_to); } /* Handler for the -catch-load. */