1 /* Support for GDB maintenance commands.
3 Copyright (C) 1992-2019 Free Software Foundation, Inc.
5 Written by Fred Fish at Cygnus Support.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 #include "arch-utils.h"
34 #include "expression.h" /* For language.h */
41 #include "common/selftest.h"
43 #include "cli/cli-decode.h"
44 #include "cli/cli-utils.h"
45 #include "cli/cli-setshow.h"
47 static void maintenance_do_deprecate (const char *, int);
49 /* Access the maintenance subcommands. */
52 maintenance_command (const char *args, int from_tty)
54 printf_unfiltered (_("\"maintenance\" must be followed by "
55 "the name of a maintenance command.\n"));
56 help_list (maintenancelist, "maintenance ", all_commands, gdb_stdout);
61 maintenance_dump_me (const char *args, int from_tty)
63 if (query (_("Should GDB dump core? ")))
66 /* SIGQUIT by default is ignored, so use SIGABRT instead. */
67 signal (SIGABRT, SIG_DFL);
68 kill (getpid (), SIGABRT);
70 signal (SIGQUIT, SIG_DFL);
71 kill (getpid (), SIGQUIT);
77 /* Stimulate the internal error mechanism that GDB uses when an
78 internal problem is detected. Allows testing of the mechanism.
79 Also useful when the user wants to drop a core file but not exit
83 maintenance_internal_error (const char *args, int from_tty)
85 internal_error (__FILE__, __LINE__, "%s", (args == NULL ? "" : args));
88 /* Stimulate the internal error mechanism that GDB uses when an
89 internal problem is detected. Allows testing of the mechanism.
90 Also useful when the user wants to drop a core file but not exit
94 maintenance_internal_warning (const char *args, int from_tty)
96 internal_warning (__FILE__, __LINE__, "%s", (args == NULL ? "" : args));
99 /* Stimulate the internal error mechanism that GDB uses when an
100 demangler problem is detected. Allows testing of the mechanism. */
103 maintenance_demangler_warning (const char *args, int from_tty)
105 demangler_warning (__FILE__, __LINE__, "%s", (args == NULL ? "" : args));
108 /* Old command to demangle a string. The command has been moved to "demangle".
109 It is kept for now because otherwise "mt demangle" gets interpreted as
110 "mt demangler-warning" which artificially creates an internal gdb error. */
113 maintenance_demangle (const char *args, int from_tty)
115 printf_filtered (_("This command has been moved to \"demangle\".\n"));
119 maintenance_time_display (const char *args, int from_tty)
121 if (args == NULL || *args == '\0')
122 printf_unfiltered (_("\"maintenance time\" takes a numeric argument.\n"));
124 set_per_command_time (strtol (args, NULL, 10));
128 maintenance_space_display (const char *args, int from_tty)
130 if (args == NULL || *args == '\0')
131 printf_unfiltered ("\"maintenance space\" takes a numeric argument.\n");
133 set_per_command_space (strtol (args, NULL, 10));
136 /* The "maintenance info" command is defined as a prefix, with
137 allow_unknown 0. Therefore, its own definition is called only for
138 "maintenance info" with no args. */
141 maintenance_info_command (const char *arg, int from_tty)
143 printf_unfiltered (_("\"maintenance info\" must be followed "
144 "by the name of an info command.\n"));
145 help_list (maintenanceinfolist, "maintenance info ", all_commands,
149 /* The "maintenance check" command is defined as a prefix, with
150 allow_unknown 0. Therefore, its own definition is called only for
151 "maintenance check" with no args. */
154 maintenance_check_command (const char *arg, int from_tty)
156 printf_unfiltered (_("\"maintenance check\" must be followed "
157 "by the name of a check command.\n"));
158 help_list (maintenancechecklist, "maintenance check ", all_commands,
162 /* Mini tokenizing lexer for 'maint info sections' command. */
165 match_substring (const char *string, const char *substr)
167 int substr_len = strlen(substr);
170 while ((tok = strstr (string, substr)) != NULL)
172 /* Got a partial match. Is it a whole word? */
177 /* Token is delimited at the front... */
178 if (tok[substr_len] == ' '
179 || tok[substr_len] == '\t'
180 || tok[substr_len] == '\0')
182 /* Token is delimited at the rear. Got a whole-word match. */
186 /* Token didn't match as a whole word. Advance and try again. */
193 match_bfd_flags (const char *string, flagword flags)
195 if (flags & SEC_ALLOC)
196 if (match_substring (string, "ALLOC"))
198 if (flags & SEC_LOAD)
199 if (match_substring (string, "LOAD"))
201 if (flags & SEC_RELOC)
202 if (match_substring (string, "RELOC"))
204 if (flags & SEC_READONLY)
205 if (match_substring (string, "READONLY"))
207 if (flags & SEC_CODE)
208 if (match_substring (string, "CODE"))
210 if (flags & SEC_DATA)
211 if (match_substring (string, "DATA"))
214 if (match_substring (string, "ROM"))
216 if (flags & SEC_CONSTRUCTOR)
217 if (match_substring (string, "CONSTRUCTOR"))
219 if (flags & SEC_HAS_CONTENTS)
220 if (match_substring (string, "HAS_CONTENTS"))
222 if (flags & SEC_NEVER_LOAD)
223 if (match_substring (string, "NEVER_LOAD"))
225 if (flags & SEC_COFF_SHARED_LIBRARY)
226 if (match_substring (string, "COFF_SHARED_LIBRARY"))
228 if (flags & SEC_IS_COMMON)
229 if (match_substring (string, "IS_COMMON"))
236 print_bfd_flags (flagword flags)
238 if (flags & SEC_ALLOC)
239 printf_filtered (" ALLOC");
240 if (flags & SEC_LOAD)
241 printf_filtered (" LOAD");
242 if (flags & SEC_RELOC)
243 printf_filtered (" RELOC");
244 if (flags & SEC_READONLY)
245 printf_filtered (" READONLY");
246 if (flags & SEC_CODE)
247 printf_filtered (" CODE");
248 if (flags & SEC_DATA)
249 printf_filtered (" DATA");
251 printf_filtered (" ROM");
252 if (flags & SEC_CONSTRUCTOR)
253 printf_filtered (" CONSTRUCTOR");
254 if (flags & SEC_HAS_CONTENTS)
255 printf_filtered (" HAS_CONTENTS");
256 if (flags & SEC_NEVER_LOAD)
257 printf_filtered (" NEVER_LOAD");
258 if (flags & SEC_COFF_SHARED_LIBRARY)
259 printf_filtered (" COFF_SHARED_LIBRARY");
260 if (flags & SEC_IS_COMMON)
261 printf_filtered (" IS_COMMON");
265 maint_print_section_info (const char *name, flagword flags,
266 CORE_ADDR addr, CORE_ADDR endaddr,
267 unsigned long filepos, int addr_size)
269 printf_filtered (" %s", hex_string_custom (addr, addr_size));
270 printf_filtered ("->%s", hex_string_custom (endaddr, addr_size));
271 printf_filtered (" at %s",
272 hex_string_custom ((unsigned long) filepos, 8));
273 printf_filtered (": %s", name);
274 print_bfd_flags (flags);
275 printf_filtered ("\n");
279 print_bfd_section_info (bfd *abfd,
283 flagword flags = bfd_get_section_flags (abfd, asect);
284 const char *name = bfd_section_name (abfd, asect);
285 const char *arg = (const char *) datum;
287 if (arg == NULL || *arg == '\0'
288 || match_substring (arg, name)
289 || match_bfd_flags (arg, flags))
291 struct gdbarch *gdbarch = gdbarch_from_bfd (abfd);
292 int addr_size = gdbarch_addr_bit (gdbarch) / 8;
293 CORE_ADDR addr, endaddr;
295 addr = bfd_section_vma (abfd, asect);
296 endaddr = addr + bfd_section_size (abfd, asect);
297 printf_filtered (" [%d] ", gdb_bfd_section_index (abfd, asect));
298 maint_print_section_info (name, flags, addr, endaddr,
299 asect->filepos, addr_size);
304 print_objfile_section_info (bfd *abfd,
305 struct obj_section *asect,
308 flagword flags = bfd_get_section_flags (abfd, asect->the_bfd_section);
309 const char *name = bfd_section_name (abfd, asect->the_bfd_section);
311 if (string == NULL || *string == '\0'
312 || match_substring (string, name)
313 || match_bfd_flags (string, flags))
315 struct gdbarch *gdbarch = gdbarch_from_bfd (abfd);
316 int addr_size = gdbarch_addr_bit (gdbarch) / 8;
318 maint_print_section_info (name, flags,
319 obj_section_addr (asect),
320 obj_section_endaddr (asect),
321 asect->the_bfd_section->filepos,
327 maintenance_info_sections (const char *arg, int from_tty)
331 printf_filtered (_("Exec file:\n"));
332 printf_filtered (" `%s', ", bfd_get_filename (exec_bfd));
334 printf_filtered (_("file type %s.\n"), bfd_get_target (exec_bfd));
335 if (arg && *arg && match_substring (arg, "ALLOBJ"))
337 struct obj_section *osect;
339 /* Only this function cares about the 'ALLOBJ' argument;
340 if 'ALLOBJ' is the only argument, discard it rather than
341 passing it down to print_objfile_section_info (which
342 wouldn't know how to handle it). */
343 if (strcmp (arg, "ALLOBJ") == 0)
346 for (objfile *ofile : current_program_space->objfiles ())
348 printf_filtered (_(" Object file: %s\n"),
349 bfd_get_filename (ofile->obfd));
350 ALL_OBJFILE_OSECTIONS (ofile, osect)
352 print_objfile_section_info (ofile->obfd, osect, arg);
357 bfd_map_over_sections (exec_bfd, print_bfd_section_info, (void *) arg);
362 printf_filtered (_("Core file:\n"));
363 printf_filtered (" `%s', ", bfd_get_filename (core_bfd));
365 printf_filtered (_("file type %s.\n"), bfd_get_target (core_bfd));
366 bfd_map_over_sections (core_bfd, print_bfd_section_info, (void *) arg);
371 maintenance_print_statistics (const char *args, int from_tty)
373 print_objfile_statistics ();
374 print_symbol_bcache_statistics ();
378 maintenance_print_architecture (const char *args, int from_tty)
380 struct gdbarch *gdbarch = get_current_arch ();
383 gdbarch_dump (gdbarch, gdb_stdout);
388 if (!file.open (args, "w"))
389 perror_with_name (_("maintenance print architecture"));
390 gdbarch_dump (gdbarch, &file);
394 /* The "maintenance print" command is defined as a prefix, with
395 allow_unknown 0. Therefore, its own definition is called only for
396 "maintenance print" with no args. */
399 maintenance_print_command (const char *arg, int from_tty)
401 printf_unfiltered (_("\"maintenance print\" must be followed "
402 "by the name of a print command.\n"));
403 help_list (maintenanceprintlist, "maintenance print ", all_commands,
407 /* The "maintenance translate-address" command converts a section and address
408 to a symbol. This can be called in two ways:
409 maintenance translate-address <secname> <addr>
410 or maintenance translate-address <addr>. */
413 maintenance_translate_address (const char *arg, int from_tty)
416 struct obj_section *sect;
418 struct bound_minimal_symbol sym;
420 if (arg == NULL || *arg == 0)
421 error (_("requires argument (address or section + address)"));
427 { /* See if we have a valid section name. */
428 while (*p && !isspace (*p)) /* Find end of section name. */
430 if (*p == '\000') /* End of command? */
431 error (_("Need to specify section name and address"));
433 int arg_len = p - arg;
434 p = skip_spaces (p + 1);
436 for (objfile *objfile : current_program_space->objfiles ())
437 ALL_OBJFILE_OSECTIONS (objfile, sect)
439 if (strncmp (sect->the_bfd_section->name, arg, arg_len) == 0)
443 error (_("Unknown section %s."), arg);
447 address = parse_and_eval_address (p);
450 sym = lookup_minimal_symbol_by_pc_section (address, sect);
452 sym = lookup_minimal_symbol_by_pc (address);
456 const char *symbol_name = MSYMBOL_PRINT_NAME (sym.minsym);
457 const char *symbol_offset
458 = pulongest (address - BMSYMBOL_VALUE_ADDRESS (sym));
460 sect = MSYMBOL_OBJ_SECTION(sym.objfile, sym.minsym);
463 const char *section_name;
464 const char *obj_name;
466 gdb_assert (sect->the_bfd_section && sect->the_bfd_section->name);
467 section_name = sect->the_bfd_section->name;
469 gdb_assert (sect->objfile && objfile_name (sect->objfile));
470 obj_name = objfile_name (sect->objfile);
472 if (MULTI_OBJFILE_P ())
473 printf_filtered (_("%s + %s in section %s of %s\n"),
474 symbol_name, symbol_offset,
475 section_name, obj_name);
477 printf_filtered (_("%s + %s in section %s\n"),
478 symbol_name, symbol_offset, section_name);
481 printf_filtered (_("%s + %s\n"), symbol_name, symbol_offset);
484 printf_filtered (_("no symbol at %s:%s\n"),
485 sect->the_bfd_section->name, hex_string (address));
487 printf_filtered (_("no symbol at %s\n"), hex_string (address));
493 /* When a command is deprecated the user will be warned the first time
494 the command is used. If possible, a replacement will be
498 maintenance_deprecate (const char *args, int from_tty)
500 if (args == NULL || *args == '\0')
502 printf_unfiltered (_("\"maintenance deprecate\" takes an argument,\n\
503 the command you want to deprecate, and optionally the replacement command\n\
504 enclosed in quotes.\n"));
507 maintenance_do_deprecate (args, 1);
512 maintenance_undeprecate (const char *args, int from_tty)
514 if (args == NULL || *args == '\0')
516 printf_unfiltered (_("\"maintenance undeprecate\" takes an argument, \n\
517 the command you want to undeprecate.\n"));
520 maintenance_do_deprecate (args, 0);
523 /* You really shouldn't be using this. It is just for the testsuite.
524 Rather, you should use deprecate_cmd() when the command is created
525 in _initialize_blah().
527 This function deprecates a command and optionally assigns it a
531 maintenance_do_deprecate (const char *text, int deprecate)
533 struct cmd_list_element *alias = NULL;
534 struct cmd_list_element *prefix_cmd = NULL;
535 struct cmd_list_element *cmd = NULL;
537 const char *start_ptr = NULL;
538 const char *end_ptr = NULL;
540 char *replacement = NULL;
545 if (!lookup_cmd_composition (text, &alias, &prefix_cmd, &cmd))
547 printf_filtered (_("Can't find command '%s' to deprecate.\n"), text);
553 /* Look for a replacement command. */
554 start_ptr = strchr (text, '\"');
555 if (start_ptr != NULL)
558 end_ptr = strrchr (start_ptr, '\"');
561 len = end_ptr - start_ptr;
562 replacement = savestring (start_ptr, len);
567 if (!start_ptr || !end_ptr)
571 /* If they used an alias, we only want to deprecate the alias.
573 Note the MALLOCED_REPLACEMENT test. If the command's replacement
574 string was allocated at compile time we don't want to free the
578 if (alias->malloced_replacement)
579 xfree ((char *) alias->replacement);
583 alias->deprecated_warn_user = 1;
584 alias->cmd_deprecated = 1;
588 alias->deprecated_warn_user = 0;
589 alias->cmd_deprecated = 0;
591 alias->replacement = replacement;
592 alias->malloced_replacement = 1;
597 if (cmd->malloced_replacement)
598 xfree ((char *) cmd->replacement);
602 cmd->deprecated_warn_user = 1;
603 cmd->cmd_deprecated = 1;
607 cmd->deprecated_warn_user = 0;
608 cmd->cmd_deprecated = 0;
610 cmd->replacement = replacement;
611 cmd->malloced_replacement = 1;
617 /* Maintenance set/show framework. */
619 struct cmd_list_element *maintenance_set_cmdlist;
620 struct cmd_list_element *maintenance_show_cmdlist;
623 maintenance_set_cmd (const char *args, int from_tty)
625 printf_unfiltered (_("\"maintenance set\" must be followed "
626 "by the name of a set command.\n"));
627 help_list (maintenance_set_cmdlist, "maintenance set ", all_commands,
632 maintenance_show_cmd (const char *args, int from_tty)
634 cmd_show_list (maintenance_show_cmdlist, from_tty, "");
637 /* Profiling support. */
639 static int maintenance_profile_p;
641 show_maintenance_profile_p (struct ui_file *file, int from_tty,
642 struct cmd_list_element *c, const char *value)
644 fprintf_filtered (file, _("Internal profiling is %s.\n"), value);
649 #define TEXTEND &_etext
650 #elif defined (HAVE_ETEXT)
652 #define TEXTEND &etext
655 #if defined (HAVE_MONSTARTUP) && defined (HAVE__MCLEANUP) && defined (TEXTEND)
657 static int profiling_state;
659 EXTERN_C void _mcleanup (void);
662 mcleanup_wrapper (void)
668 EXTERN_C void monstartup (unsigned long, unsigned long);
672 maintenance_set_profile_cmd (const char *args, int from_tty,
673 struct cmd_list_element *c)
675 if (maintenance_profile_p == profiling_state)
678 profiling_state = maintenance_profile_p;
680 if (maintenance_profile_p)
682 static int profiling_initialized;
684 if (!profiling_initialized)
686 atexit (mcleanup_wrapper);
687 profiling_initialized = 1;
690 /* "main" is now always the first function in the text segment, so use
691 its address for monstartup. */
692 monstartup ((unsigned long) &main, (unsigned long) TEXTEND);
696 extern void _mcleanup (void);
703 maintenance_set_profile_cmd (const char *args, int from_tty,
704 struct cmd_list_element *c)
706 error (_("Profiling support is not available on this system."));
710 /* If nonzero, display time usage both at startup and for each command. */
712 static int per_command_time;
714 /* If nonzero, display space usage both at startup and for each command. */
716 static int per_command_space;
718 /* If nonzero, display basic symtab stats for each command. */
720 static int per_command_symtab;
722 /* mt per-command commands. */
724 static struct cmd_list_element *per_command_setlist;
725 static struct cmd_list_element *per_command_showlist;
727 /* Set whether to display time statistics to NEW_VALUE
728 (non-zero means true). */
731 set_per_command_time (int new_value)
733 per_command_time = new_value;
736 /* Set whether to display space statistics to NEW_VALUE
737 (non-zero means true). */
740 set_per_command_space (int new_value)
742 per_command_space = new_value;
745 /* Count the number of symtabs and blocks. */
748 count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
752 int nr_compunit_symtabs = 0;
755 /* When collecting statistics during startup, this is called before
756 pretty much anything in gdb has been initialized, and thus
757 current_program_space may be NULL. */
758 if (current_program_space != NULL)
760 for (objfile *o : current_program_space->objfiles ())
762 for (compunit_symtab *cu : o->compunits ())
764 ++nr_compunit_symtabs;
765 nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu));
766 nr_symtabs += std::distance (compunit_filetabs (cu).begin (),
767 compunit_filetabs (cu).end ());
772 *nr_symtabs_ptr = nr_symtabs;
773 *nr_compunit_symtabs_ptr = nr_compunit_symtabs;
774 *nr_blocks_ptr = nr_blocks;
777 /* As indicated by display_time and display_space, report GDB's
778 elapsed time and space usage from the base time and space recorded
781 scoped_command_stats::~scoped_command_stats ()
783 /* Early exit if we're not reporting any stats. It can be expensive to
784 compute the pre-command values so don't collect them at all if we're
785 not reporting stats. Alas this doesn't work in the startup case because
786 we don't know yet whether we will be reporting the stats. For the
787 startup case collect the data anyway (it should be cheap at this point),
788 and leave it to the reporter to decide whether to print them. */
791 && !per_command_space
792 && !per_command_symtab)
795 if (m_time_enabled && per_command_time)
797 using namespace std::chrono;
799 run_time_clock::duration cmd_time
800 = run_time_clock::now () - m_start_cpu_time;
802 steady_clock::duration wall_time
803 = steady_clock::now () - m_start_wall_time;
804 /* Subtract time spend in prompt_for_continue from walltime. */
805 wall_time -= get_prompt_for_continue_wait_time ();
807 printf_unfiltered (!m_msg_type
808 ? _("Startup time: %.6f (cpu), %.6f (wall)\n")
809 : _("Command execution time: %.6f (cpu), %.6f (wall)\n"),
810 duration<double> (cmd_time).count (),
811 duration<double> (wall_time).count ());
814 if (m_space_enabled && per_command_space)
816 #ifdef HAVE_USEFUL_SBRK
817 char *lim = (char *) sbrk (0);
819 long space_now = lim - lim_at_start;
820 long space_diff = space_now - m_start_space;
822 printf_unfiltered (!m_msg_type
823 ? _("Space used: %ld (%s%ld during startup)\n")
824 : _("Space used: %ld (%s%ld for this command)\n"),
826 (space_diff >= 0 ? "+" : ""),
831 if (m_symtab_enabled && per_command_symtab)
833 int nr_symtabs, nr_compunit_symtabs, nr_blocks;
835 count_symtabs_and_blocks (&nr_symtabs, &nr_compunit_symtabs, &nr_blocks);
836 printf_unfiltered (_("#symtabs: %d (+%d),"
837 " #compunits: %d (+%d),"
838 " #blocks: %d (+%d)\n"),
840 nr_symtabs - m_start_nr_symtabs,
843 - m_start_nr_compunit_symtabs),
845 nr_blocks - m_start_nr_blocks);
849 scoped_command_stats::scoped_command_stats (bool msg_type)
850 : m_msg_type (msg_type)
852 if (!m_msg_type || per_command_space)
854 #ifdef HAVE_USEFUL_SBRK
855 char *lim = (char *) sbrk (0);
856 m_start_space = lim - lim_at_start;
863 if (msg_type == 0 || per_command_time)
865 using namespace std::chrono;
867 m_start_cpu_time = run_time_clock::now ();
868 m_start_wall_time = steady_clock::now ();
874 if (msg_type == 0 || per_command_symtab)
876 int nr_symtabs, nr_compunit_symtabs, nr_blocks;
878 count_symtabs_and_blocks (&nr_symtabs, &nr_compunit_symtabs, &nr_blocks);
879 m_start_nr_symtabs = nr_symtabs;
880 m_start_nr_compunit_symtabs = nr_compunit_symtabs;
881 m_start_nr_blocks = nr_blocks;
882 m_symtab_enabled = 1;
885 m_symtab_enabled = 0;
887 /* Initialize timer to keep track of how long we waited for the user. */
888 reset_prompt_for_continue_wait_time ();
891 /* Handle unknown "mt set per-command" arguments.
892 In this case have "mt set per-command on|off" affect every setting. */
895 set_per_command_cmd (const char *args, int from_tty)
897 struct cmd_list_element *list;
900 val = parse_cli_boolean_value (args);
902 error (_("Bad value for 'mt set per-command no'."));
904 for (list = per_command_setlist; list != NULL; list = list->next)
905 if (list->var_type == var_boolean)
907 gdb_assert (list->type == set_cmd);
908 do_set_command (args, from_tty, list);
912 /* Command "show per-command" displays summary of all the current
913 "show per-command " settings. */
916 show_per_command_cmd (const char *args, int from_tty)
918 cmd_show_list (per_command_showlist, from_tty, "");
922 /* The "maintenance selftest" command. */
925 maintenance_selftest (const char *args, int from_tty)
928 selftests::run_tests (args);
930 printf_filtered (_("\
931 Selftests have been disabled for this build.\n"));
936 maintenance_info_selftests (const char *arg, int from_tty)
939 printf_filtered ("Registered selftests:\n");
940 selftests::for_each_selftest ([] (const std::string &name) {
941 printf_filtered (" - %s\n", name.c_str ());
944 printf_filtered (_("\
945 Selftests have been disabled for this build.\n"));
951 _initialize_maint_cmds (void)
953 struct cmd_list_element *cmd;
955 add_prefix_cmd ("maintenance", class_maintenance, maintenance_command, _("\
956 Commands for use by GDB maintainers.\n\
957 Includes commands to dump specific internal GDB structures in\n\
958 a human readable form, to cause GDB to deliberately dump core, etc."),
959 &maintenancelist, "maintenance ", 0,
962 add_com_alias ("mt", "maintenance", class_maintenance, 1);
964 add_prefix_cmd ("info", class_maintenance, maintenance_info_command, _("\
965 Commands for showing internal info about the program being debugged."),
966 &maintenanceinfolist, "maintenance info ", 0,
968 add_alias_cmd ("i", "info", class_maintenance, 1, &maintenancelist);
970 add_cmd ("sections", class_maintenance, maintenance_info_sections, _("\
971 List the BFD sections of the exec and core files. \n\
972 Arguments may be any combination of:\n\
973 [one or more section names]\n\
974 ALLOC LOAD RELOC READONLY CODE DATA ROM CONSTRUCTOR\n\
975 HAS_CONTENTS NEVER_LOAD COFF_SHARED_LIBRARY IS_COMMON\n\
976 Sections matching any argument will be listed (no argument\n\
977 implies all sections). In addition, the special argument\n\
979 lists all sections from all object files, including shared libraries."),
980 &maintenanceinfolist);
982 add_prefix_cmd ("print", class_maintenance, maintenance_print_command,
983 _("Maintenance command for printing GDB internal state."),
984 &maintenanceprintlist, "maintenance print ", 0,
987 add_prefix_cmd ("set", class_maintenance, maintenance_set_cmd, _("\
988 Set GDB internal variables used by the GDB maintainer.\n\
989 Configure variables internal to GDB that aid in GDB's maintenance"),
990 &maintenance_set_cmdlist, "maintenance set ",
994 add_prefix_cmd ("show", class_maintenance, maintenance_show_cmd, _("\
995 Show GDB internal variables used by the GDB maintainer.\n\
996 Configure variables internal to GDB that aid in GDB's maintenance"),
997 &maintenance_show_cmdlist, "maintenance show ",
1002 add_cmd ("dump-me", class_maintenance, maintenance_dump_me, _("\
1003 Get fatal error; make debugger dump its core.\n\
1004 GDB sets its handling of SIGQUIT back to SIG_DFL and then sends\n\
1005 itself a SIGQUIT signal."),
1009 add_cmd ("internal-error", class_maintenance,
1010 maintenance_internal_error, _("\
1011 Give GDB an internal error.\n\
1012 Cause GDB to behave as if an internal error was detected."),
1015 add_cmd ("internal-warning", class_maintenance,
1016 maintenance_internal_warning, _("\
1017 Give GDB an internal warning.\n\
1018 Cause GDB to behave as if an internal warning was reported."),
1021 add_cmd ("demangler-warning", class_maintenance,
1022 maintenance_demangler_warning, _("\
1023 Give GDB a demangler warning.\n\
1024 Cause GDB to behave as if a demangler warning was reported."),
1027 cmd = add_cmd ("demangle", class_maintenance, maintenance_demangle, _("\
1028 This command has been moved to \"demangle\"."),
1030 deprecate_cmd (cmd, "demangle");
1032 add_prefix_cmd ("per-command", class_maintenance, set_per_command_cmd, _("\
1033 Per-command statistics settings."),
1034 &per_command_setlist, "maintenance set per-command ",
1035 1/*allow-unknown*/, &maintenance_set_cmdlist);
1037 add_prefix_cmd ("per-command", class_maintenance, show_per_command_cmd, _("\
1038 Show per-command statistics settings."),
1039 &per_command_showlist, "maintenance show per-command ",
1040 0/*allow-unknown*/, &maintenance_show_cmdlist);
1042 add_setshow_boolean_cmd ("time", class_maintenance,
1043 &per_command_time, _("\
1044 Set whether to display per-command execution time."), _("\
1045 Show whether to display per-command execution time."),
1047 If enabled, the execution time for each command will be\n\
1048 displayed following the command's output."),
1050 &per_command_setlist, &per_command_showlist);
1052 add_setshow_boolean_cmd ("space", class_maintenance,
1053 &per_command_space, _("\
1054 Set whether to display per-command space usage."), _("\
1055 Show whether to display per-command space usage."),
1057 If enabled, the space usage for each command will be\n\
1058 displayed following the command's output."),
1060 &per_command_setlist, &per_command_showlist);
1062 add_setshow_boolean_cmd ("symtab", class_maintenance,
1063 &per_command_symtab, _("\
1064 Set whether to display per-command symtab statistics."), _("\
1065 Show whether to display per-command symtab statistics."),
1067 If enabled, the basic symtab statistics for each command will be\n\
1068 displayed following the command's output."),
1070 &per_command_setlist, &per_command_showlist);
1072 /* This is equivalent to "mt set per-command time on".
1073 Kept because some people are used to typing "mt time 1". */
1074 add_cmd ("time", class_maintenance, maintenance_time_display, _("\
1075 Set the display of time usage.\n\
1076 If nonzero, will cause the execution time for each command to be\n\
1077 displayed, following the command's output."),
1080 /* This is equivalent to "mt set per-command space on".
1081 Kept because some people are used to typing "mt space 1". */
1082 add_cmd ("space", class_maintenance, maintenance_space_display, _("\
1083 Set the display of space usage.\n\
1084 If nonzero, will cause the execution space for each command to be\n\
1085 displayed, following the command's output."),
1088 add_cmd ("type", class_maintenance, maintenance_print_type, _("\
1089 Print a type chain for a given symbol.\n\
1090 For each node in a type chain, print the raw data for each member of\n\
1091 the type structure, and the interpretation of the data."),
1092 &maintenanceprintlist);
1094 add_cmd ("statistics", class_maintenance, maintenance_print_statistics,
1095 _("Print statistics about internal gdb state."),
1096 &maintenanceprintlist);
1098 add_cmd ("architecture", class_maintenance,
1099 maintenance_print_architecture, _("\
1100 Print the internal architecture configuration.\n\
1101 Takes an optional file parameter."),
1102 &maintenanceprintlist);
1104 add_prefix_cmd ("check", class_maintenance, maintenance_check_command, _("\
1105 Commands for checking internal gdb state."),
1106 &maintenancechecklist, "maintenance check ", 0,
1109 add_cmd ("translate-address", class_maintenance,
1110 maintenance_translate_address,
1111 _("Translate a section name and address to a symbol."),
1114 add_cmd ("deprecate", class_maintenance, maintenance_deprecate, _("\
1115 Deprecate a command. Note that this is just in here so the \n\
1116 testsuite can check the command deprecator. You probably shouldn't use this,\n\
1117 rather you should use the C function deprecate_cmd(). If you decide you \n\
1118 want to use it: maintenance deprecate 'commandname' \"replacement\". The \n\
1119 replacement is optional."), &maintenancelist);
1121 add_cmd ("undeprecate", class_maintenance, maintenance_undeprecate, _("\
1122 Undeprecate a command. Note that this is just in here so the \n\
1123 testsuite can check the command deprecator. You probably shouldn't use this,\n\
1124 If you decide you want to use it: maintenance undeprecate 'commandname'"),
1127 add_cmd ("selftest", class_maintenance, maintenance_selftest, _("\
1128 Run gdb's unit tests.\n\
1129 Usage: maintenance selftest [filter]\n\
1130 This will run any unit tests that were built in to gdb.\n\
1131 If a filter is given, only the tests with that value in their name will ran."),
1134 add_cmd ("selftests", class_maintenance, maintenance_info_selftests,
1135 _("List the registered selftests."), &maintenanceinfolist);
1137 add_setshow_boolean_cmd ("profile", class_maintenance,
1138 &maintenance_profile_p, _("\
1139 Set internal profiling."), _("\
1140 Show internal profiling."), _("\
1141 When enabled GDB is profiled."),
1142 maintenance_set_profile_cmd,
1143 show_maintenance_profile_p,
1144 &maintenance_set_cmdlist,
1145 &maintenance_show_cmdlist);