From patchwork Tue Sep 12 20:16:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 22860 Received: (qmail 100858 invoked by alias); 12 Sep 2017 20:16:44 -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 98257 invoked by uid 89); 12 Sep 2017 20:16:43 -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, SPF_PASS autolearn=ham version=3.3.2 spammy=(unknown) 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; Tue, 12 Sep 2017 20:16:41 +0000 Received: from cmgw3 (unknown [10.0.90.84]) by gproxy8.mail.unifiedlayer.com (Postfix) with ESMTP id 687D91AB153 for ; Tue, 12 Sep 2017 14:16:40 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id 8kGd1w00W2f2jeq01kGgoa; Tue, 12 Sep 2017 14:16:40 -0600 X-Authority-Analysis: v=2.2 cv=K/VSJ2eI c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=2JCJgTwv5E4A:10 a=zstS-IiYAAAA:8 a=0FD05c-RAAAA:8 a=1XGhwCjprv-732cgk7cA:9 a=4G6NA9xxw8l3yy4pmD5M:22 a=l1rpMCqCXRGZwUSuRcM3:22 Received: from 75-166-76-94.hlrn.qwest.net ([75.166.76.94]:46510 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1drrbp-002fk5-At; Tue, 12 Sep 2017 14:16:37 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Overload catch_command_errors Date: Tue, 12 Sep 2017 14:16:32 -0600 Message-Id: <20170912201632.15786-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1drrbp-002fk5-At X-Source-Sender: 75-166-76-94.hlrn.qwest.net (bapiya.Home) [75.166.76.94]:46510 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This changes catch_command_errors_const to be an overload of catch_command_errors, which may mildly help future constification efforts. Tested by rebuilding. ChangeLog 2017-09-12 Tom Tromey * main.c (catch_command_errors): Rename from catch_command_errors_const. (captured_main_1): Update. --- gdb/ChangeLog | 6 ++++++ gdb/main.c | 42 +++++++++++++++++++++--------------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3905a51..7982bd9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2017-09-12 Tom Tromey + + * main.c (catch_command_errors): Rename from + catch_command_errors_const. + (captured_main_1): Update. + 2017-09-12 Simon Marchi * probe.h (probe_ops_cp): Remove typedef. diff --git a/gdb/main.c b/gdb/main.c index a0646ed..fe80511 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -340,8 +340,7 @@ captured_command_loop (void *data) return 1; } -/* Handle command errors thrown from within - catch_command_errors/catch_command_errors_const. */ +/* Handle command errors thrown from within catch_command_errors. */ static int handle_command_errors (struct gdb_exception e) @@ -386,15 +385,16 @@ catch_command_errors (catch_command_errors_ftype *command, return 1; } -/* Type of the command callback passed to catch_command_errors_const. */ +/* Type of the command callback passed to the const + catch_command_errors. */ typedef void (catch_command_errors_const_ftype) (const char *, int); -/* Like catch_command_errors, but works with const command and args. */ +/* Const-correct catch_command_errors. */ static int -catch_command_errors_const (catch_command_errors_const_ftype *command, - const char *arg, int from_tty) +catch_command_errors (catch_command_errors_const_ftype command, + const char *arg, int from_tty) { TRY { @@ -982,7 +982,7 @@ captured_main_1 (struct captured_main_args *context) processed; it sets global parameters, which are independent of what file you are debugging or what directory you are in. */ if (system_gdbinit && !inhibit_gdbinit) - catch_command_errors_const (source_script, system_gdbinit, 0); + catch_command_errors (source_script, system_gdbinit, 0); /* Read and execute $HOME/.gdbinit file, if it exists. This is done *before* all the command line arguments are processed; it sets @@ -990,7 +990,7 @@ captured_main_1 (struct captured_main_args *context) debugging or what directory you are in. */ if (home_gdbinit && !inhibit_gdbinit && !inhibit_home_gdbinit) - catch_command_errors_const (source_script, home_gdbinit, 0); + catch_command_errors (source_script, home_gdbinit, 0); /* Process '-ix' and '-iex' options early. */ for (i = 0; i < cmdarg_vec.size (); i++) @@ -1000,8 +1000,8 @@ captured_main_1 (struct captured_main_args *context) switch (cmdarg_p.type) { case CMDARG_INIT_FILE: - catch_command_errors_const (source_script, cmdarg_p.string, - !batch_flag); + catch_command_errors (source_script, cmdarg_p.string, + !batch_flag); break; case CMDARG_INIT_COMMAND: catch_command_errors (execute_command, cmdarg_p.string, @@ -1032,19 +1032,19 @@ captured_main_1 (struct captured_main_args *context) /* The exec file and the symbol-file are the same. If we can't open it, better only print one error message. catch_command_errors returns non-zero on success! */ - if (catch_command_errors_const (exec_file_attach, execarg, - !batch_flag)) - catch_command_errors_const (symbol_file_add_main_adapter, symarg, - !batch_flag); + if (catch_command_errors (exec_file_attach, execarg, + !batch_flag)) + catch_command_errors (symbol_file_add_main_adapter, symarg, + !batch_flag); } else { if (execarg != NULL) - catch_command_errors_const (exec_file_attach, execarg, - !batch_flag); + catch_command_errors (exec_file_attach, execarg, + !batch_flag); if (symarg != NULL) - catch_command_errors_const (symbol_file_add_main_adapter, symarg, - !batch_flag); + catch_command_errors (symbol_file_add_main_adapter, symarg, + !batch_flag); } if (corearg && pidarg) @@ -1094,7 +1094,7 @@ captured_main_1 (struct captured_main_args *context) { auto_load_local_gdbinit_loaded = 1; - catch_command_errors_const (source_script, local_gdbinit, 0); + catch_command_errors (source_script, local_gdbinit, 0); } } @@ -1114,8 +1114,8 @@ captured_main_1 (struct captured_main_args *context) switch (cmdarg_p.type) { case CMDARG_FILE: - catch_command_errors_const (source_script, cmdarg_p.string, - !batch_flag); + catch_command_errors (source_script, cmdarg_p.string, + !batch_flag); break; case CMDARG_COMMAND: catch_command_errors (execute_command, cmdarg_p.string,