aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-09-12 14:40:43 -0600
committerTom Tromey <tom@tromey.com>2017-09-27 08:44:43 -0600
commit58971144622629bd11acc82b61140f8c47f0e306 (patch)
treefe943e5c2d9c2f5e6cd2ce2d7642a07ea3a91aea
parentc482f52ccfbd5609aef5482fb0872545bdcabaf2 (diff)
downloadgdb-58971144622629bd11acc82b61140f8c47f0e306.zip
gdb-58971144622629bd11acc82b61140f8c47f0e306.tar.gz
gdb-58971144622629bd11acc82b61140f8c47f0e306.tar.bz2
Constify commands maint.c, plus maintenance_print_type
In addition to the constification, this fixes a command-repeat bug. gdb/ChangeLog 2017-09-27 Tom Tromey <tom@tromey.com> * 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.
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/gdbtypes.h2
-rw-r--r--gdb/maint.c39
-rw-r--r--gdb/typeprint.c2
4 files changed, 28 insertions, 26 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index acdd73a..bfde0e8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,16 @@
2017-09-27 Tom Tromey <tom@tromey.com>
+ * 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.
+
+2017-09-27 Tom Tromey <tom@tromey.com>
+
* hppa-tdep.c (unwind_command): Constify.
2017-09-27 Tom Tromey <tom@tromey.com>
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;