From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52853 invoked by alias); 21 Sep 2017 05:40:04 -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 52768 invoked by uid 89); 21 Sep 2017 05:40:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.0 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=3487, 5497, 9467 X-HELO: gproxy2-pub.mail.unifiedlayer.com Received: from gproxy2-pub.mail.unifiedlayer.com (HELO gproxy2-pub.mail.unifiedlayer.com) (69.89.18.3) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Sep 2017 05:40:02 +0000 Received: from CMOut01 (unknown [10.0.90.82]) by gproxy2.mail.unifiedlayer.com (Postfix) with ESMTP id 617D91E0BC9 for ; Wed, 20 Sep 2017 23:40:01 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id C5fy1w0042f2jeq015g1WJ; Wed, 20 Sep 2017 23:40:01 -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=R-WO1EF5dsPmVbYHi_IA:9 a=Rn-dUT8ZTnM-RPT8:21 a=xs-EoNxvDdKA5Chv:21 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-76-94.hlrn.qwest.net ([75.166.76.94]:36574 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dutkw-00118R-5N; Wed, 20 Sep 2017 23:10:34 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 35/67] Constify commands maint.c, plus maintenance_print_type Date: Thu, 21 Sep 2017 05:40:00 -0000 Message-Id: <20170921051023.19023-36-tom@tromey.com> In-Reply-To: <20170921051023.19023-1-tom@tromey.com> References: <20170921051023.19023-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1dutkw-00118R-5N X-Source-Sender: 75-166-76-94.hlrn.qwest.net (bapiya.Home) [75.166.76.94]:36574 X-Source-Auth: tom+tromey.com X-Email-Count: 40 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes X-SW-Source: 2017-09/txt/msg00571.txt.bz2 ChangeLog 2017-09-20 Tom Tromey * typeprint.c (maintenance_print_type): Constify. * maint.c (maintenance_dump_me, maintenance_demangle) (maintenance_time_display, maintenance_info_sections) (maintenance_print_statistics, maintenance_deprecate) (maintenance_undeprecate): Constify. (maintenance_do_deprecate): Constify. Use std::string. (maintenance_selftest): Constify. * gdbtypes.h (maintenance_print_type): Constify. --- gdb/ChangeLog | 11 +++++++++++ gdb/gdbtypes.h | 2 +- gdb/maint.c | 39 +++++++++++++++------------------------ gdb/typeprint.c | 2 +- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 9d9b09f..8d6fd9b 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1931,7 +1931,7 @@ extern int is_scalar_type_recursive (struct type *); extern int class_or_union_p (const struct type *); -extern void maintenance_print_type (char *, int); +extern void maintenance_print_type (const char *, int); extern htab_t create_copied_types_hash (struct objfile *objfile); diff --git a/gdb/maint.c b/gdb/maint.c index b540d1c..6c0dec2 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -48,19 +48,13 @@ static void maintenance_command (char *, int); static void maintenance_internal_error (char *args, int from_tty); -static void maintenance_demangle (char *, int); - -static void maintenance_time_display (char *, int); - static void maintenance_space_display (char *, int); static void maintenance_info_command (char *, int); -static void maintenance_info_sections (char *, int); - static void maintenance_print_command (char *, int); -static void maintenance_do_deprecate (char *, int); +static void maintenance_do_deprecate (const char *, int); /* Set this to the maximum number of seconds to wait instead of waiting forever in target_wait(). If this timer times out, then it generates an error and @@ -88,7 +82,7 @@ maintenance_command (char *args, int from_tty) #ifndef _WIN32 static void -maintenance_dump_me (char *args, int from_tty) +maintenance_dump_me (const char *args, int from_tty) { if (query (_("Should GDB dump core? "))) { @@ -140,13 +134,13 @@ maintenance_demangler_warning (char *args, int from_tty) "mt demangler-warning" which artificially creates an internal gdb error. */ static void -maintenance_demangle (char *args, int from_tty) +maintenance_demangle (const char *args, int from_tty) { printf_filtered (_("This command has been moved to \"demangle\".\n")); } static void -maintenance_time_display (char *args, int from_tty) +maintenance_time_display (const char *args, int from_tty) { if (args == NULL || *args == '\0') printf_unfiltered (_("\"maintenance time\" takes a numeric argument.\n")); @@ -354,7 +348,7 @@ print_objfile_section_info (bfd *abfd, } static void -maintenance_info_sections (char *arg, int from_tty) +maintenance_info_sections (const char *arg, int from_tty) { if (exec_bfd) { @@ -385,7 +379,7 @@ maintenance_info_sections (char *arg, int from_tty) } } else - bfd_map_over_sections (exec_bfd, print_bfd_section_info, arg); + bfd_map_over_sections (exec_bfd, print_bfd_section_info, (void *) arg); } if (core_bfd) @@ -394,12 +388,12 @@ maintenance_info_sections (char *arg, int from_tty) printf_filtered (" `%s', ", bfd_get_filename (core_bfd)); wrap_here (" "); printf_filtered (_("file type %s.\n"), bfd_get_target (core_bfd)); - bfd_map_over_sections (core_bfd, print_bfd_section_info, arg); + bfd_map_over_sections (core_bfd, print_bfd_section_info, (void *) arg); } } static void -maintenance_print_statistics (char *args, int from_tty) +maintenance_print_statistics (const char *args, int from_tty) { print_objfile_statistics (); print_symbol_bcache_statistics (); @@ -525,7 +519,7 @@ maintenance_translate_address (char *arg, int from_tty) offered. */ static void -maintenance_deprecate (char *args, int from_tty) +maintenance_deprecate (const char *args, int from_tty) { if (args == NULL || *args == '\0') { @@ -535,12 +529,11 @@ enclosed in quotes.\n")); } maintenance_do_deprecate (args, 1); - } static void -maintenance_undeprecate (char *args, int from_tty) +maintenance_undeprecate (const char *args, int from_tty) { if (args == NULL || *args == '\0') { @@ -549,7 +542,6 @@ the command you want to undeprecate.\n")); } maintenance_do_deprecate (args, 0); - } /* You really shouldn't be using this. It is just for the testsuite. @@ -560,14 +552,14 @@ the command you want to undeprecate.\n")); replacement. */ static void -maintenance_do_deprecate (char *text, int deprecate) +maintenance_do_deprecate (const char *text, int deprecate) { struct cmd_list_element *alias = NULL; struct cmd_list_element *prefix_cmd = NULL; struct cmd_list_element *cmd = NULL; - char *start_ptr = NULL; - char *end_ptr = NULL; + const char *start_ptr = NULL; + const char *end_ptr = NULL; int len; char *replacement = NULL; @@ -591,8 +583,7 @@ maintenance_do_deprecate (char *text, int deprecate) if (end_ptr != NULL) { len = end_ptr - start_ptr; - start_ptr[len] = '\0'; - replacement = xstrdup (start_ptr); + replacement = savestring (start_ptr, len); } } } @@ -955,7 +946,7 @@ show_per_command_cmd (char *args, int from_tty) /* The "maintenance selftest" command. */ static void -maintenance_selftest (char *args, int from_tty) +maintenance_selftest (const char *args, int from_tty) { selftests::run_tests (args); } diff --git a/gdb/typeprint.c b/gdb/typeprint.c index c82e623..8ee44af 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -629,7 +629,7 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream) and whatis_command(). */ void -maintenance_print_type (char *type_name, int from_tty) +maintenance_print_type (const char *type_name, int from_tty) { struct value *val; struct type *type; -- 2.9.4