From patchwork Wed Aug 2 15:02:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 21865 Received: (qmail 37465 invoked by alias); 2 Aug 2017 15:03:49 -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 37420 invoked by uid 89); 2 Aug 2017 15:03:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.6 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= X-HELO: gproxy3-pub.mail.unifiedlayer.com Received: from gproxy3-pub.mail.unifiedlayer.com (HELO gproxy3-pub.mail.unifiedlayer.com) (69.89.30.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 02 Aug 2017 15:03:46 +0000 Received: from CMOut01 (unknown [10.0.90.82]) by gproxy3.mail.unifiedlayer.com (Postfix) with ESMTP id 2339E4131A for ; Wed, 2 Aug 2017 09:02:42 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id sF2f1v0082f2jeq01F2ish; Wed, 02 Aug 2017 09:02:42 -0600 X-Authority-Analysis: v=2.2 cv=XMVAcUpE c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=KeKAF7QvOSUA:10 a=zstS-IiYAAAA:8 a=w9C9K4Gf-HaCJW8wgLQA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 174-29-39-24.hlrn.qwest.net ([174.29.39.24]:54692 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dcvAU-002dpC-RY; Wed, 02 Aug 2017 09:02:38 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA v3 16/23] Remove user_call_depth Date: Wed, 2 Aug 2017 09:02:20 -0600 Message-Id: <20170802150227.24460-17-tom@tromey.com> In-Reply-To: <20170802150227.24460-1-tom@tromey.com> References: <20170802150227.24460-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1dcvAU-002dpC-RY X-Source-Sender: 174-29-39-24.hlrn.qwest.net (bapiya.Home) [174.29.39.24]:54692 X-Source-Auth: tom+tromey.com X-Email-Count: 17 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This changes execute_user_command to remove user_call_depth, using the size of user_args_stack instead. This avoids a cleanup. ChangeLog 2017-08-02 Tom Tromey * cli/cli-script.c (do_restore_user_call_depth): Remove. (execute_user_command): Remove user_call_depth; use user_args_stack's size instead. --- gdb/ChangeLog | 6 ++++++ gdb/cli/cli-script.c | 17 ++--------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ca3432b..93522b4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2017-08-02 Tom Tromey + * cli/cli-script.c (do_restore_user_call_depth): Remove. + (execute_user_command): Remove user_call_depth; use + user_args_stack's size instead. + +2017-08-02 Tom Tromey + * top.h (in_user_command): Remove. * top.c (in_user_command): Remove. * cli/cli-script.c (do_restore_user_call_depth) diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 527540a..36aa371 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -372,16 +372,6 @@ execute_cmd_post_hook (struct cmd_list_element *c) } } -/* Execute the command in CMD. */ -static void -do_restore_user_call_depth (void * call_depth) -{ - int *depth = (int *) call_depth; - - (*depth)--; -} - - void execute_user_command (struct cmd_list_element *c, char *args) { @@ -389,7 +379,6 @@ execute_user_command (struct cmd_list_element *c, char *args) struct command_line *cmdlines; struct cleanup *old_chain; enum command_control_type ret; - static int user_call_depth = 0; extern unsigned int max_user_call_depth; cmdlines = c->user_commands; @@ -399,14 +388,12 @@ execute_user_command (struct cmd_list_element *c, char *args) scoped_user_args_level push_user_args (args); - if (++user_call_depth > max_user_call_depth) + if (user_args_stack.size () > max_user_call_depth) error (_("Max user call depth exceeded -- command aborted.")); - old_chain = make_cleanup (do_restore_user_call_depth, &user_call_depth); - /* Set the instream to 0, indicating execution of a user-defined function. */ - make_cleanup (do_restore_instream_cleanup, ui->instream); + old_chain = make_cleanup (do_restore_instream_cleanup, ui->instream); ui->instream = NULL; scoped_restore save_async = make_scoped_restore (¤t_ui->async, 0);