From patchwork Wed Oct 18 04:06:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 23658 Received: (qmail 109597 invoked by alias); 18 Oct 2017 04:06:58 -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 109473 invoked by uid 89); 18 Oct 2017 04:06:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=H*MI:7212 X-HELO: gproxy8-pub.mail.unifiedlayer.com Received: from gproxy8-pub.mail.unifiedlayer.com (HELO gproxy8-pub.mail.unifiedlayer.com) (67.222.33.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Oct 2017 04:06:56 +0000 Received: from cmgw3 (unknown [10.0.90.84]) by gproxy8.mail.unifiedlayer.com (Postfix) with ESMTP id 8FF6D1AB3D3 for ; Tue, 17 Oct 2017 22:06:54 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id Ns6r1w00Q2f2jeq01s6uw9; Tue, 17 Oct 2017 22:06:54 -0600 X-Authority-Analysis: v=2.2 cv=H76r+6Qi c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=02M-m0pO-4AA:10 a=zstS-IiYAAAA:8 a=lE-2pVOv3Vrofc1YYOsA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 184-96-33-178.hlrn.qwest.net ([184.96.33.178]:51166 helo=bapiya.localdomain) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1e4fd5-001Wr2-B8; Tue, 17 Oct 2017 22:06:51 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 1/3] Remove cleanups from prepare_execute_command Date: Tue, 17 Oct 2017 22:06:43 -0600 Message-Id: <20171018040645.7212-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1e4fd5-001Wr2-B8 X-Source-Sender: 184-96-33-178.hlrn.qwest.net (bapiya.localdomain) [184.96.33.178]:51166 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This changes prepare_execute_command to return a scoped_value_mark rather than a cleanup. ChangeLog 2017-10-17 Tom Tromey * mi/mi-main.c (mi_cmd_execute): Update. * top.h (prepare_execute_command): Return scoped_value_mark. * value.h (class scoped_value_mark): Use DISABLE_COPY_AND_ASSIGN. Add move constructor. * top.c (prepare_execute_command): Return scoped_value_mark. (execute_command): Update. --- gdb/ChangeLog | 9 +++++++++ gdb/mi/mi-main.c | 5 +---- gdb/top.c | 18 +++++------------- gdb/top.h | 3 ++- gdb/value.h | 4 ++++ 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 8dc955da1f..3caf904e28 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -2095,9 +2095,7 @@ mi_execute_command (const char *cmd, int from_tty) static void mi_cmd_execute (struct mi_parse *parse) { - struct cleanup *cleanup; - - cleanup = prepare_execute_command (); + scoped_value_mark cleanup = prepare_execute_command (); if (parse->all && parse->thread_group != -1) error (_("Cannot specify --thread-group together with --all")); @@ -2189,7 +2187,6 @@ mi_cmd_execute (struct mi_parse *parse) error_stream (stb); } - do_cleanups (cleanup); } /* FIXME: This is just a hack so we can get some extra commands going. diff --git a/gdb/top.c b/gdb/top.c index 3b3bbee4ac..9f5dd58d21 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -438,15 +438,9 @@ do_chdir_cleanup (void *old_dir) } #endif -struct cleanup * -prepare_execute_command (void) +scoped_value_mark +prepare_execute_command () { - struct value *mark; - struct cleanup *cleanup; - - mark = value_mark (); - cleanup = make_cleanup_value_free_to_mark (mark); - /* With multiple threads running while the one we're examining is stopped, the dcache can get stale without us being able to detect it. For the duration of the command, though, use the dcache to @@ -454,7 +448,7 @@ prepare_execute_command (void) if (non_stop) target_dcache_invalidate (); - return cleanup; + return scoped_value_mark (); } /* Tell the user if the language has changed (except first time) after @@ -534,12 +528,12 @@ maybe_wait_sync_command_done (int was_sync) void execute_command (char *p, int from_tty) { - struct cleanup *cleanup_if_error, *cleanup; + struct cleanup *cleanup_if_error; struct cmd_list_element *c; char *line; cleanup_if_error = make_bpstat_clear_actions_cleanup (); - cleanup = prepare_execute_command (); + scoped_value_mark cleanup = prepare_execute_command (); /* Force cleanup of any alloca areas if using C alloca instead of a builtin alloca. */ @@ -548,7 +542,6 @@ execute_command (char *p, int from_tty) /* This can happen when command_line_input hits end of file. */ if (p == NULL) { - do_cleanups (cleanup); discard_cleanups (cleanup_if_error); return; } @@ -623,7 +616,6 @@ execute_command (char *p, int from_tty) check_frame_language_change (); - do_cleanups (cleanup); discard_cleanups (cleanup_if_error); } diff --git a/gdb/top.h b/gdb/top.h index ab21e5e013..ab65ddb741 100644 --- a/gdb/top.h +++ b/gdb/top.h @@ -22,6 +22,7 @@ #include "buffer.h" #include "event-loop.h" +#include "value.h" struct tl_interp_info; @@ -249,7 +250,7 @@ extern void check_frame_language_change (void); /* Prepare for execution of a command. Call this before every command, CLI or MI. Returns a cleanup to be run after the command is completed. */ -extern struct cleanup *prepare_execute_command (void); +extern scoped_value_mark prepare_execute_command (void); /* This function returns a pointer to the string that is used by gdb for its command prompt. */ diff --git a/gdb/value.h b/gdb/value.h index bc97ec0728..fb6f81fb12 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -730,6 +730,10 @@ class scoped_value_mark free_to_mark (); } + scoped_value_mark (scoped_value_mark &&other) = default; + + DISABLE_COPY_AND_ASSIGN (scoped_value_mark); + /* Free the values currently on the value stack. */ void free_to_mark () {