From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53594 invoked by alias); 3 May 2017 22:46:51 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 52379 invoked by uid 89); 3 May 2017 22:46:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*RU:sk:outboun, Hx-spam-relays-external:sk:outboun, HX-HELO:sk:outboun, Hx-languages-length:2094 X-HELO: outbound-ss-1812.hostmonster.com Received: from gproxy1-pub.mail.unifiedlayer.com (HELO outbound-ss-1812.hostmonster.com) (69.89.25.95) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 03 May 2017 22:46:38 +0000 Received: from cmgw3 (cmgw4 [10.0.90.84]) by gproxy1.mail.unifiedlayer.com (Postfix) with ESMTP id 77EAA175A0A for ; Wed, 3 May 2017 16:46:39 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id Fymc1v00K2f2jeq01ymfL5; Wed, 03 May 2017 16:46:39 -0600 X-Authority-Analysis: v=2.2 cv=VKStp5HX c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=tJ8p9aeEuA8A:10 a=zstS-IiYAAAA:8 a=w9C9K4Gf-HaCJW8wgLQA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-63-71.hlrn.qwest.net ([75.166.63.71]:53090 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1d632a-00051x-8R; Wed, 03 May 2017 16:46:36 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 17/23] Use a scoped_restore for user_call_depth Date: Wed, 03 May 2017 22:46:00 -0000 Message-Id: <20170503224626.2818-18-tom@tromey.com> In-Reply-To: <20170503224626.2818-1-tom@tromey.com> References: <20170503224626.2818-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1d632a-00051x-8R X-Source-Sender: 75-166-63-71.hlrn.qwest.net (bapiya.Home) [75.166.63.71]:53090 X-Source-Auth: tom+tromey.com X-Email-Count: 24 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-SW-Source: 2017-05/txt/msg00086.txt.bz2 This changes execute_user_command to use a scoped_restore for user_call_depth. This avoids a cleanup. 2017-05-02 Tom Tromey * cli/cli-script.c (do_restore_user_call_depth): Remove. (execute_user_command): Use scoped_restore. --- gdb/ChangeLog | 5 +++++ gdb/cli/cli-script.c | 18 ++++-------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 45c5db7..873b404 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2017-05-02 Tom Tromey + * cli/cli-script.c (do_restore_user_call_depth): Remove. + (execute_user_command): Use scoped_restore. + +2017-05-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 994f5c4..7f90d27 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) { @@ -398,15 +388,15 @@ execute_user_command (struct cmd_list_element *c, char *args) return; scoped_user_args_level push_user_args (args); + scoped_restore restore_call_depth + = make_scoped_restore (&user_call_depth, user_call_depth + 1); - if (++user_call_depth > max_user_call_depth) + if (user_call_depth > 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); -- 2.9.3