Change boolean options to bool instead of int
[deliverable/binutils-gdb.git] / gdb / maint.c
CommitLineData
c906108c 1/* Support for GDB maintenance commands.
c6f0559b 2
42a4f53d 3 Copyright (C) 1992-2019 Free Software Foundation, Inc.
c6f0559b 4
c906108c
SS
5 Written by Fred Fish at Cygnus Support.
6
c5aa993b 7 This file is part of GDB.
c906108c 8
c5aa993b
JM
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
a9762ec7 11 the Free Software Foundation; either version 3 of the License, or
c5aa993b 12 (at your option) any later version.
c906108c 13
c5aa993b
JM
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.
c906108c 18
c5aa993b 19 You should have received a copy of the GNU General Public License
a9762ec7 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
21
22
23#include "defs.h"
e17c207e 24#include "arch-utils.h"
c906108c 25#include <ctype.h>
aa17805f 26#include <cmath>
c906108c
SS
27#include <signal.h>
28#include "command.h"
29#include "gdbcmd.h"
30#include "symtab.h"
bd712aed 31#include "block.h"
c906108c
SS
32#include "gdbtypes.h"
33#include "demangle.h"
34#include "gdbcore.h"
c5aa993b 35#include "expression.h" /* For language.h */
c906108c
SS
36#include "language.h"
37#include "symfile.h"
38#include "objfiles.h"
39#include "value.h"
bd712aed 40#include "top.h"
bd712aed 41#include "maint.h"
268a13a5 42#include "gdbsupport/selftest.h"
c906108c 43
18a642a1 44#include "cli/cli-decode.h"
529480d0 45#include "cli/cli-utils.h"
bd712aed 46#include "cli/cli-setshow.h"
fdbc9870 47#include "cli/cli-cmds.h"
18a642a1 48
58971144 49static void maintenance_do_deprecate (const char *, int);
1c689132 50
7f86f058 51/* Access the maintenance subcommands. */
c906108c
SS
52
53static void
981a3fb3 54maintenance_command (const char *args, int from_tty)
c906108c 55{
3e43a32a
MS
56 printf_unfiltered (_("\"maintenance\" must be followed by "
57 "the name of a maintenance command.\n"));
635c7e8a 58 help_list (maintenancelist, "maintenance ", all_commands, gdb_stdout);
c906108c
SS
59}
60
61#ifndef _WIN32
c906108c 62static void
58971144 63maintenance_dump_me (const char *args, int from_tty)
c906108c 64{
9e2f0ad4 65 if (query (_("Should GDB dump core? ")))
c906108c 66 {
7be570e7
JM
67#ifdef __DJGPP__
68 /* SIGQUIT by default is ignored, so use SIGABRT instead. */
69 signal (SIGABRT, SIG_DFL);
70 kill (getpid (), SIGABRT);
71#else
c906108c
SS
72 signal (SIGQUIT, SIG_DFL);
73 kill (getpid (), SIGQUIT);
7be570e7 74#endif
c906108c
SS
75 }
76}
77#endif
78
7be570e7
JM
79/* Stimulate the internal error mechanism that GDB uses when an
80 internal problem is detected. Allows testing of the mechanism.
81 Also useful when the user wants to drop a core file but not exit
025bb325 82 GDB. */
7be570e7
JM
83
84static void
5fed81ff 85maintenance_internal_error (const char *args, int from_tty)
7be570e7 86{
dec43320
AC
87 internal_error (__FILE__, __LINE__, "%s", (args == NULL ? "" : args));
88}
89
90/* Stimulate the internal error mechanism that GDB uses when an
91 internal problem is detected. Allows testing of the mechanism.
92 Also useful when the user wants to drop a core file but not exit
025bb325 93 GDB. */
dec43320
AC
94
95static void
5fed81ff 96maintenance_internal_warning (const char *args, int from_tty)
dec43320
AC
97{
98 internal_warning (__FILE__, __LINE__, "%s", (args == NULL ? "" : args));
7be570e7
JM
99}
100
57fcfb1b
GB
101/* Stimulate the internal error mechanism that GDB uses when an
102 demangler problem is detected. Allows testing of the mechanism. */
103
104static void
5fed81ff 105maintenance_demangler_warning (const char *args, int from_tty)
57fcfb1b
GB
106{
107 demangler_warning (__FILE__, __LINE__, "%s", (args == NULL ? "" : args));
108}
109
439250fb
DE
110/* Old command to demangle a string. The command has been moved to "demangle".
111 It is kept for now because otherwise "mt demangle" gets interpreted as
112 "mt demangler-warning" which artificially creates an internal gdb error. */
c906108c
SS
113
114static void
58971144 115maintenance_demangle (const char *args, int from_tty)
c906108c 116{
439250fb 117 printf_filtered (_("This command has been moved to \"demangle\".\n"));
c906108c
SS
118}
119
120static void
58971144 121maintenance_time_display (const char *args, int from_tty)
c906108c 122{
c906108c 123 if (args == NULL || *args == '\0')
a3f17187 124 printf_unfiltered (_("\"maintenance time\" takes a numeric argument.\n"));
c906108c 125 else
bd712aed 126 set_per_command_time (strtol (args, NULL, 10));
c906108c
SS
127}
128
129static void
5fed81ff 130maintenance_space_display (const char *args, int from_tty)
c906108c 131{
c906108c
SS
132 if (args == NULL || *args == '\0')
133 printf_unfiltered ("\"maintenance space\" takes a numeric argument.\n");
134 else
bd712aed 135 set_per_command_space (strtol (args, NULL, 10));
c906108c
SS
136}
137
33f91161
AC
138/* The "maintenance info" command is defined as a prefix, with
139 allow_unknown 0. Therefore, its own definition is called only for
140 "maintenance info" with no args. */
c906108c 141
c906108c 142static void
981a3fb3 143maintenance_info_command (const char *arg, int from_tty)
c906108c 144{
3e43a32a
MS
145 printf_unfiltered (_("\"maintenance info\" must be followed "
146 "by the name of an info command.\n"));
635c7e8a
TT
147 help_list (maintenanceinfolist, "maintenance info ", all_commands,
148 gdb_stdout);
c906108c
SS
149}
150
27d41eac
YQ
151/* The "maintenance check" command is defined as a prefix, with
152 allow_unknown 0. Therefore, its own definition is called only for
153 "maintenance check" with no args. */
154
155static void
981a3fb3 156maintenance_check_command (const char *arg, int from_tty)
27d41eac
YQ
157{
158 printf_unfiltered (_("\"maintenance check\" must be followed "
159 "by the name of a check command.\n"));
160 help_list (maintenancechecklist, "maintenance check ", all_commands,
161 gdb_stdout);
162}
163
a532ca62
MS
164/* Mini tokenizing lexer for 'maint info sections' command. */
165
166static int
473e38f3 167match_substring (const char *string, const char *substr)
a532ca62
MS
168{
169 int substr_len = strlen(substr);
473e38f3 170 const char *tok;
a532ca62
MS
171
172 while ((tok = strstr (string, substr)) != NULL)
173 {
025bb325 174 /* Got a partial match. Is it a whole word? */
b01d807c
MS
175 if (tok == string
176 || tok[-1] == ' '
177 || tok[-1] == '\t')
a532ca62 178 {
025bb325 179 /* Token is delimited at the front... */
b01d807c
MS
180 if (tok[substr_len] == ' '
181 || tok[substr_len] == '\t'
182 || tok[substr_len] == '\0')
a532ca62
MS
183 {
184 /* Token is delimited at the rear. Got a whole-word match. */
185 return 1;
186 }
187 }
188 /* Token didn't match as a whole word. Advance and try again. */
189 string = tok + 1;
190 }
191 return 0;
192}
193
43155bc1 194static int
fc4baa5e 195match_bfd_flags (const char *string, flagword flags)
c906108c 196{
43155bc1 197 if (flags & SEC_ALLOC)
a532ca62 198 if (match_substring (string, "ALLOC"))
43155bc1
MS
199 return 1;
200 if (flags & SEC_LOAD)
a532ca62 201 if (match_substring (string, "LOAD"))
43155bc1
MS
202 return 1;
203 if (flags & SEC_RELOC)
a532ca62 204 if (match_substring (string, "RELOC"))
43155bc1
MS
205 return 1;
206 if (flags & SEC_READONLY)
a532ca62 207 if (match_substring (string, "READONLY"))
43155bc1
MS
208 return 1;
209 if (flags & SEC_CODE)
a532ca62 210 if (match_substring (string, "CODE"))
43155bc1
MS
211 return 1;
212 if (flags & SEC_DATA)
a532ca62 213 if (match_substring (string, "DATA"))
43155bc1
MS
214 return 1;
215 if (flags & SEC_ROM)
a532ca62 216 if (match_substring (string, "ROM"))
43155bc1
MS
217 return 1;
218 if (flags & SEC_CONSTRUCTOR)
a532ca62 219 if (match_substring (string, "CONSTRUCTOR"))
43155bc1
MS
220 return 1;
221 if (flags & SEC_HAS_CONTENTS)
a532ca62 222 if (match_substring (string, "HAS_CONTENTS"))
43155bc1
MS
223 return 1;
224 if (flags & SEC_NEVER_LOAD)
a532ca62 225 if (match_substring (string, "NEVER_LOAD"))
43155bc1
MS
226 return 1;
227 if (flags & SEC_COFF_SHARED_LIBRARY)
a532ca62 228 if (match_substring (string, "COFF_SHARED_LIBRARY"))
43155bc1
MS
229 return 1;
230 if (flags & SEC_IS_COMMON)
a532ca62 231 if (match_substring (string, "IS_COMMON"))
43155bc1 232 return 1;
c906108c 233
43155bc1
MS
234 return 0;
235}
c906108c 236
43155bc1
MS
237static void
238print_bfd_flags (flagword flags)
239{
c906108c
SS
240 if (flags & SEC_ALLOC)
241 printf_filtered (" ALLOC");
242 if (flags & SEC_LOAD)
243 printf_filtered (" LOAD");
244 if (flags & SEC_RELOC)
245 printf_filtered (" RELOC");
246 if (flags & SEC_READONLY)
247 printf_filtered (" READONLY");
248 if (flags & SEC_CODE)
249 printf_filtered (" CODE");
250 if (flags & SEC_DATA)
251 printf_filtered (" DATA");
252 if (flags & SEC_ROM)
253 printf_filtered (" ROM");
254 if (flags & SEC_CONSTRUCTOR)
255 printf_filtered (" CONSTRUCTOR");
256 if (flags & SEC_HAS_CONTENTS)
257 printf_filtered (" HAS_CONTENTS");
258 if (flags & SEC_NEVER_LOAD)
259 printf_filtered (" NEVER_LOAD");
260 if (flags & SEC_COFF_SHARED_LIBRARY)
261 printf_filtered (" COFF_SHARED_LIBRARY");
262 if (flags & SEC_IS_COMMON)
263 printf_filtered (" IS_COMMON");
43155bc1
MS
264}
265
266static void
67a2b77e
AC
267maint_print_section_info (const char *name, flagword flags,
268 CORE_ADDR addr, CORE_ADDR endaddr,
5af949e3 269 unsigned long filepos, int addr_size)
43155bc1 270{
5af949e3
UW
271 printf_filtered (" %s", hex_string_custom (addr, addr_size));
272 printf_filtered ("->%s", hex_string_custom (endaddr, addr_size));
3ab13650 273 printf_filtered (" at %s",
bb599908 274 hex_string_custom ((unsigned long) filepos, 8));
e3d3bfda
MS
275 printf_filtered (": %s", name);
276 print_bfd_flags (flags);
277 printf_filtered ("\n");
278}
c906108c 279
aa17805f
AB
280/* Information passed between the "maintenance info sections" command, and
281 the worker function that prints each section. */
282struct maint_print_section_data
283{
284 /* The GDB objfile we're printing this section for. */
285 struct objfile *objfile;
286
287 /* The argument string passed by the user to the top level maintenance
288 info sections command. Used for filtering which sections are
289 printed. */
290 const char *arg;
291
292 /* The number of digits in the highest section index for all sections
293 from the bfd object associated with OBJFILE. Used when pretty
294 printing the index number to ensure all of the indexes line up. */
295 int index_digits;
296
297 /* Constructor. */
298 maint_print_section_data (struct objfile *objfile, const char *arg,
299 bfd *abfd)
300 : objfile (objfile),
301 arg(arg)
302 {
303 int section_count = gdb_bfd_count_sections (abfd);
ec6c8338 304 index_digits = ((int) log10 ((float) section_count)) + 1;
aa17805f
AB
305 }
306
307private:
308 maint_print_section_data () = delete;
309 maint_print_section_data (const maint_print_section_data &) = delete;
310};
311
312/* Helper function to pretty-print the section index of ASECT from ABFD.
313 The INDEX_DIGITS is the number of digits in the largest index that will
314 be printed, and is used to pretty-print the resulting string. */
315
316static void
317print_section_index (bfd *abfd,
318 asection *asect,
319 int index_digits)
320{
321 std::string result
322 = string_printf (" [%d] ", gdb_bfd_section_index (abfd, asect));
323 /* The '+ 4' for the leading and trailing characters. */
324 printf_filtered ("%-*s", (index_digits + 4), result.c_str ());
325}
326
327/* Print information about ASECT from ABFD. DATUM holds a pointer to a
328 maint_print_section_data object. The section will be printed using the
329 VMA's from the bfd, which will not be the relocated addresses for bfds
330 that should be relocated. The information must be printed with the
331 same layout as PRINT_OBJFILE_SECTION_INFO below. */
332
e3d3bfda 333static void
aa17805f
AB
334print_bfd_section_info (bfd *abfd,
335 asection *asect,
fc4baa5e 336 void *datum)
e3d3bfda
MS
337{
338 flagword flags = bfd_get_section_flags (abfd, asect);
339 const char *name = bfd_section_name (abfd, asect);
aa17805f
AB
340 maint_print_section_data *print_data = (maint_print_section_data *) datum;
341 const char *arg = print_data->arg;
e3d3bfda 342
fc4baa5e
TT
343 if (arg == NULL || *arg == '\0'
344 || match_substring (arg, name)
345 || match_bfd_flags (arg, flags))
e3d3bfda 346 {
5af949e3
UW
347 struct gdbarch *gdbarch = gdbarch_from_bfd (abfd);
348 int addr_size = gdbarch_addr_bit (gdbarch) / 8;
e3d3bfda
MS
349 CORE_ADDR addr, endaddr;
350
351 addr = bfd_section_vma (abfd, asect);
352 endaddr = addr + bfd_section_size (abfd, asect);
aa17805f 353 print_section_index (abfd, asect, print_data->index_digits);
5af949e3
UW
354 maint_print_section_info (name, flags, addr, endaddr,
355 asect->filepos, addr_size);
e3d3bfda
MS
356 }
357}
358
aa17805f
AB
359/* Print information about ASECT which is GDB's wrapper around a section
360 from ABFD. The information must be printed with the same layout as
361 PRINT_BFD_SECTION_INFO above. PRINT_DATA holds information used to
362 filter which sections are printed, and for formatting the output. */
363
e3d3bfda 364static void
aa17805f
AB
365print_objfile_section_info (bfd *abfd,
366 struct obj_section *asect,
367 maint_print_section_data *print_data)
e3d3bfda
MS
368{
369 flagword flags = bfd_get_section_flags (abfd, asect->the_bfd_section);
370 const char *name = bfd_section_name (abfd, asect->the_bfd_section);
aa17805f 371 const char *string = print_data->arg;
43155bc1 372
b01d807c
MS
373 if (string == NULL || *string == '\0'
374 || match_substring (string, name)
375 || match_bfd_flags (string, flags))
43155bc1 376 {
5af949e3
UW
377 struct gdbarch *gdbarch = gdbarch_from_bfd (abfd);
378 int addr_size = gdbarch_addr_bit (gdbarch) / 8;
b8d56208 379
aa17805f
AB
380 print_section_index (abfd, asect->the_bfd_section,
381 print_data->index_digits);
f1f6aadf
PA
382 maint_print_section_info (name, flags,
383 obj_section_addr (asect),
384 obj_section_endaddr (asect),
5af949e3
UW
385 asect->the_bfd_section->filepos,
386 addr_size);
43155bc1 387 }
c906108c
SS
388}
389
aa17805f
AB
390/* Find an obj_section, GDB's wrapper around a bfd section for ASECTION
391 from ABFD. It might be that no such wrapper exists (for example debug
392 sections don't have such wrappers) in which case nullptr is returned. */
393
394static obj_section *
395maint_obj_section_from_bfd_section (bfd *abfd,
396 asection *asection,
397 objfile *ofile)
398{
399 if (ofile->sections == nullptr)
400 return nullptr;
401
402 obj_section *osect
403 = &ofile->sections[gdb_bfd_section_index (abfd, asection)];
404
405 if (osect >= ofile->sections_end)
406 return nullptr;
407
408 return osect;
409}
410
411/* Print information about ASECT from ABFD. DATUM holds a pointer to a
412 maint_print_section_data object. Where possible the information for
413 ASECT will print the relocated addresses of the section. */
414
415static void
416print_bfd_section_info_maybe_relocated (bfd *abfd,
417 asection *asect,
418 void *datum)
419{
420 maint_print_section_data *print_data = (maint_print_section_data *) datum;
421 objfile *objfile = print_data->objfile;
422
423 gdb_assert (objfile->sections != NULL);
424 obj_section *osect
425 = maint_obj_section_from_bfd_section (abfd, asect, objfile);
426
427 if (osect->the_bfd_section == NULL)
428 print_bfd_section_info (abfd, asect, datum);
429 else
430 print_objfile_section_info (abfd, osect, print_data);
431}
432
433/* Implement the "maintenance info sections" command. */
434
c906108c 435static void
58971144 436maintenance_info_sections (const char *arg, int from_tty)
c906108c
SS
437{
438 if (exec_bfd)
439 {
6eac171f
TV
440 bool allobj = false;
441
a3f17187 442 printf_filtered (_("Exec file:\n"));
c5aa993b 443 printf_filtered (" `%s', ", bfd_get_filename (exec_bfd));
c906108c 444 wrap_here (" ");
a3f17187 445 printf_filtered (_("file type %s.\n"), bfd_get_target (exec_bfd));
e3d3bfda 446
6eac171f
TV
447 /* Only this function cares about the 'ALLOBJ' argument;
448 if 'ALLOBJ' is the only argument, discard it rather than
449 passing it down to print_objfile_section_info (which
450 wouldn't know how to handle it). */
451 if (arg && strcmp (arg, "ALLOBJ") == 0)
452 {
453 arg = NULL;
454 allobj = true;
455 }
e3d3bfda 456
6eac171f
TV
457 for (objfile *ofile : current_program_space->objfiles ())
458 {
459 if (allobj)
460 printf_filtered (_(" Object file: %s\n"),
461 bfd_get_filename (ofile->obfd));
aa17805f
AB
462 else if (ofile->obfd != exec_bfd)
463 continue;
464
465 maint_print_section_data print_data (ofile, arg, ofile->obfd);
466
467 bfd_map_over_sections (ofile->obfd,
468 print_bfd_section_info_maybe_relocated,
469 (void *) &print_data);
e3d3bfda 470 }
c906108c
SS
471 }
472
473 if (core_bfd)
474 {
aa17805f
AB
475 maint_print_section_data print_data (nullptr, arg, core_bfd);
476
a3f17187 477 printf_filtered (_("Core file:\n"));
c5aa993b 478 printf_filtered (" `%s', ", bfd_get_filename (core_bfd));
c906108c 479 wrap_here (" ");
a3f17187 480 printf_filtered (_("file type %s.\n"), bfd_get_target (core_bfd));
aa17805f
AB
481 bfd_map_over_sections (core_bfd, print_bfd_section_info,
482 (void *) &print_data);
c906108c
SS
483 }
484}
485
025cfdb2 486static void
58971144 487maintenance_print_statistics (const char *args, int from_tty)
c906108c
SS
488{
489 print_objfile_statistics ();
490 print_symbol_bcache_statistics ();
491}
492
b9362cc7 493static void
5fed81ff 494maintenance_print_architecture (const char *args, int from_tty)
4b9b3959 495{
e17c207e
UW
496 struct gdbarch *gdbarch = get_current_arch ();
497
4b9b3959 498 if (args == NULL)
e17c207e 499 gdbarch_dump (gdbarch, gdb_stdout);
4b9b3959
AC
500 else
501 {
d7e74731 502 stdio_file file;
b8d56208 503
d7e74731 504 if (!file.open (args, "w"))
e2e0b3e5 505 perror_with_name (_("maintenance print architecture"));
d7e74731 506 gdbarch_dump (gdbarch, &file);
4b9b3959
AC
507 }
508}
509
33f91161
AC
510/* The "maintenance print" command is defined as a prefix, with
511 allow_unknown 0. Therefore, its own definition is called only for
512 "maintenance print" with no args. */
c906108c 513
c906108c 514static void
981a3fb3 515maintenance_print_command (const char *arg, int from_tty)
c906108c 516{
3e43a32a
MS
517 printf_unfiltered (_("\"maintenance print\" must be followed "
518 "by the name of a print command.\n"));
635c7e8a
TT
519 help_list (maintenanceprintlist, "maintenance print ", all_commands,
520 gdb_stdout);
c906108c
SS
521}
522
523/* The "maintenance translate-address" command converts a section and address
524 to a symbol. This can be called in two ways:
c5aa993b 525 maintenance translate-address <secname> <addr>
025bb325 526 or maintenance translate-address <addr>. */
c906108c
SS
527
528static void
5fed81ff 529maintenance_translate_address (const char *arg, int from_tty)
c906108c
SS
530{
531 CORE_ADDR address;
714835d5 532 struct obj_section *sect;
5fed81ff 533 const char *p;
7cbd4a93 534 struct bound_minimal_symbol sym;
c906108c
SS
535
536 if (arg == NULL || *arg == 0)
8a3fe4f8 537 error (_("requires argument (address or section + address)"));
c906108c
SS
538
539 sect = NULL;
540 p = arg;
541
542 if (!isdigit (*p))
025bb325
MS
543 { /* See if we have a valid section name. */
544 while (*p && !isspace (*p)) /* Find end of section name. */
c906108c 545 p++;
025bb325 546 if (*p == '\000') /* End of command? */
65e65158 547 error (_("Need to specify section name and address"));
5fed81ff
TT
548
549 int arg_len = p - arg;
550 p = skip_spaces (p + 1);
c906108c 551
2030c079 552 for (objfile *objfile : current_program_space->objfiles ())
3b9d3ac2
TT
553 ALL_OBJFILE_OSECTIONS (objfile, sect)
554 {
555 if (strncmp (sect->the_bfd_section->name, arg, arg_len) == 0)
556 goto found;
557 }
c906108c 558
3b9d3ac2
TT
559 error (_("Unknown section %s."), arg);
560 found: ;
c906108c
SS
561 }
562
563 address = parse_and_eval_address (p);
564
565 if (sect)
566 sym = lookup_minimal_symbol_by_pc_section (address, sect);
567 else
568 sym = lookup_minimal_symbol_by_pc (address);
569
7cbd4a93 570 if (sym.minsym)
c14c28ba 571 {
efd66ac6 572 const char *symbol_name = MSYMBOL_PRINT_NAME (sym.minsym);
3e43a32a 573 const char *symbol_offset
77e371c0 574 = pulongest (address - BMSYMBOL_VALUE_ADDRESS (sym));
c14c28ba 575
efd66ac6 576 sect = MSYMBOL_OBJ_SECTION(sym.objfile, sym.minsym);
c14c28ba
PP
577 if (sect != NULL)
578 {
579 const char *section_name;
580 const char *obj_name;
581
582 gdb_assert (sect->the_bfd_section && sect->the_bfd_section->name);
583 section_name = sect->the_bfd_section->name;
584
4262abfb
JK
585 gdb_assert (sect->objfile && objfile_name (sect->objfile));
586 obj_name = objfile_name (sect->objfile);
c14c28ba
PP
587
588 if (MULTI_OBJFILE_P ())
589 printf_filtered (_("%s + %s in section %s of %s\n"),
3e43a32a
MS
590 symbol_name, symbol_offset,
591 section_name, obj_name);
c14c28ba
PP
592 else
593 printf_filtered (_("%s + %s in section %s\n"),
594 symbol_name, symbol_offset, section_name);
595 }
596 else
597 printf_filtered (_("%s + %s\n"), symbol_name, symbol_offset);
598 }
c906108c 599 else if (sect)
5af949e3
UW
600 printf_filtered (_("no symbol at %s:%s\n"),
601 sect->the_bfd_section->name, hex_string (address));
c906108c 602 else
5af949e3 603 printf_filtered (_("no symbol at %s\n"), hex_string (address));
c906108c
SS
604
605 return;
606}
607
56382845 608
c114dcd5 609/* When a command is deprecated the user will be warned the first time
33f91161 610 the command is used. If possible, a replacement will be
025bb325 611 offered. */
56382845
FN
612
613static void
58971144 614maintenance_deprecate (const char *args, int from_tty)
56382845
FN
615{
616 if (args == NULL || *args == '\0')
617 {
cce7e648
PA
618 printf_unfiltered (_("\"maintenance deprecate\" takes an argument,\n\
619the command you want to deprecate, and optionally the replacement command\n\
a3f17187 620enclosed in quotes.\n"));
56382845 621 }
33f91161 622
56382845 623 maintenance_do_deprecate (args, 1);
56382845
FN
624}
625
626
627static void
58971144 628maintenance_undeprecate (const char *args, int from_tty)
56382845
FN
629{
630 if (args == NULL || *args == '\0')
631 {
a3f17187
AC
632 printf_unfiltered (_("\"maintenance undeprecate\" takes an argument, \n\
633the command you want to undeprecate.\n"));
56382845 634 }
33f91161 635
56382845 636 maintenance_do_deprecate (args, 0);
56382845
FN
637}
638
025bb325 639/* You really shouldn't be using this. It is just for the testsuite.
33f91161
AC
640 Rather, you should use deprecate_cmd() when the command is created
641 in _initialize_blah().
642
643 This function deprecates a command and optionally assigns it a
644 replacement. */
645
8399535b 646static void
58971144 647maintenance_do_deprecate (const char *text, int deprecate)
33f91161 648{
33f91161
AC
649 struct cmd_list_element *alias = NULL;
650 struct cmd_list_element *prefix_cmd = NULL;
651 struct cmd_list_element *cmd = NULL;
652
58971144
TT
653 const char *start_ptr = NULL;
654 const char *end_ptr = NULL;
56382845 655 int len;
33f91161
AC
656 char *replacement = NULL;
657
1c689132
DB
658 if (text == NULL)
659 return;
56382845 660
33f91161
AC
661 if (!lookup_cmd_composition (text, &alias, &prefix_cmd, &cmd))
662 {
a3f17187 663 printf_filtered (_("Can't find command '%s' to deprecate.\n"), text);
33f91161
AC
664 return;
665 }
56382845 666
56382845
FN
667 if (deprecate)
668 {
025bb325 669 /* Look for a replacement command. */
80ce1ecb
AC
670 start_ptr = strchr (text, '\"');
671 if (start_ptr != NULL)
33f91161
AC
672 {
673 start_ptr++;
80ce1ecb
AC
674 end_ptr = strrchr (start_ptr, '\"');
675 if (end_ptr != NULL)
33f91161
AC
676 {
677 len = end_ptr - start_ptr;
58971144 678 replacement = savestring (start_ptr, len);
33f91161
AC
679 }
680 }
56382845 681 }
33f91161 682
56382845
FN
683 if (!start_ptr || !end_ptr)
684 replacement = NULL;
33f91161
AC
685
686
56382845 687 /* If they used an alias, we only want to deprecate the alias.
33f91161 688
56382845
FN
689 Note the MALLOCED_REPLACEMENT test. If the command's replacement
690 string was allocated at compile time we don't want to free the
025bb325 691 memory. */
56382845
FN
692 if (alias)
693 {
1f2bdf09 694 if (alias->malloced_replacement)
429e55ea 695 xfree ((char *) alias->replacement);
33f91161 696
56382845 697 if (deprecate)
1f2bdf09
TT
698 {
699 alias->deprecated_warn_user = 1;
700 alias->cmd_deprecated = 1;
701 }
56382845 702 else
1f2bdf09
TT
703 {
704 alias->deprecated_warn_user = 0;
705 alias->cmd_deprecated = 0;
706 }
33f91161 707 alias->replacement = replacement;
1f2bdf09 708 alias->malloced_replacement = 1;
56382845
FN
709 return;
710 }
711 else if (cmd)
712 {
1f2bdf09 713 if (cmd->malloced_replacement)
429e55ea 714 xfree ((char *) cmd->replacement);
56382845
FN
715
716 if (deprecate)
1f2bdf09
TT
717 {
718 cmd->deprecated_warn_user = 1;
719 cmd->cmd_deprecated = 1;
720 }
56382845 721 else
1f2bdf09
TT
722 {
723 cmd->deprecated_warn_user = 0;
724 cmd->cmd_deprecated = 0;
725 }
33f91161 726 cmd->replacement = replacement;
1f2bdf09 727 cmd->malloced_replacement = 1;
56382845
FN
728 return;
729 }
240f9570 730 xfree (replacement);
56382845
FN
731}
732
4f337972
AC
733/* Maintenance set/show framework. */
734
ae038cb0
DJ
735struct cmd_list_element *maintenance_set_cmdlist;
736struct cmd_list_element *maintenance_show_cmdlist;
4f337972
AC
737
738static void
981a3fb3 739maintenance_set_cmd (const char *args, int from_tty)
4f337972 740{
3e43a32a
MS
741 printf_unfiltered (_("\"maintenance set\" must be followed "
742 "by the name of a set command.\n"));
635c7e8a
TT
743 help_list (maintenance_set_cmdlist, "maintenance set ", all_commands,
744 gdb_stdout);
4f337972
AC
745}
746
747static void
981a3fb3 748maintenance_show_cmd (const char *args, int from_tty)
4f337972
AC
749{
750 cmd_show_list (maintenance_show_cmdlist, from_tty, "");
751}
752
fdbc9870
PA
753/* "maintenance with" command. */
754
755static void
756maintenance_with_cmd (const char *args, int from_tty)
757{
758 with_command_1 ("maintenance set ", maintenance_set_cmdlist, args, from_tty);
759}
760
761/* "maintenance with" command completer. */
762
763static void
764maintenance_with_cmd_completer (struct cmd_list_element *ignore,
765 completion_tracker &tracker,
766 const char *text, const char * /*word*/)
767{
768 with_command_completer_1 ("maintenance set ", tracker, text);
769}
770
4f337972
AC
771/* Profiling support. */
772
491144b5 773static bool maintenance_profile_p;
920d2a44
AC
774static void
775show_maintenance_profile_p (struct ui_file *file, int from_tty,
776 struct cmd_list_element *c, const char *value)
777{
778 fprintf_filtered (file, _("Internal profiling is %s.\n"), value);
779}
d9feb4e7 780
b0b1c2c0
MK
781#ifdef HAVE__ETEXT
782extern char _etext;
783#define TEXTEND &_etext
01fe12f6 784#elif defined (HAVE_ETEXT)
b0b1c2c0
MK
785extern char etext;
786#define TEXTEND &etext
787#endif
788
01fe12f6
JB
789#if defined (HAVE_MONSTARTUP) && defined (HAVE__MCLEANUP) && defined (TEXTEND)
790
d28f9cdf
DJ
791static int profiling_state;
792
56000a98
PA
793EXTERN_C void _mcleanup (void);
794
d28f9cdf
DJ
795static void
796mcleanup_wrapper (void)
797{
d28f9cdf
DJ
798 if (profiling_state)
799 _mcleanup ();
800}
4f337972 801
56000a98
PA
802EXTERN_C void monstartup (unsigned long, unsigned long);
803extern int main ();
804
4f337972 805static void
eb4c3f4a 806maintenance_set_profile_cmd (const char *args, int from_tty,
3e43a32a 807 struct cmd_list_element *c)
4f337972 808{
d28f9cdf
DJ
809 if (maintenance_profile_p == profiling_state)
810 return;
811
812 profiling_state = maintenance_profile_p;
813
814 if (maintenance_profile_p)
815 {
816 static int profiling_initialized;
817
d28f9cdf
DJ
818 if (!profiling_initialized)
819 {
820 atexit (mcleanup_wrapper);
821 profiling_initialized = 1;
822 }
823
824 /* "main" is now always the first function in the text segment, so use
825 its address for monstartup. */
b0b1c2c0 826 monstartup ((unsigned long) &main, (unsigned long) TEXTEND);
d28f9cdf
DJ
827 }
828 else
829 {
830 extern void _mcleanup (void);
b8d56208 831
d28f9cdf
DJ
832 _mcleanup ();
833 }
4f337972 834}
d9feb4e7
DJ
835#else
836static void
eb4c3f4a 837maintenance_set_profile_cmd (const char *args, int from_tty,
3e43a32a 838 struct cmd_list_element *c)
d9feb4e7 839{
8a3fe4f8 840 error (_("Profiling support is not available on this system."));
d9feb4e7
DJ
841}
842#endif
bd712aed 843\f
491144b5 844/* If true, display time usage both at startup and for each command. */
56382845 845
491144b5 846static bool per_command_time;
bd712aed 847
491144b5 848/* If true, display space usage both at startup and for each command. */
bd712aed 849
491144b5 850static bool per_command_space;
bd712aed 851
491144b5 852/* If true, display basic symtab stats for each command. */
bd712aed 853
491144b5 854static bool per_command_symtab;
bd712aed
DE
855
856/* mt per-command commands. */
857
858static struct cmd_list_element *per_command_setlist;
859static struct cmd_list_element *per_command_showlist;
860
bd712aed
DE
861/* Set whether to display time statistics to NEW_VALUE
862 (non-zero means true). */
863
864void
865set_per_command_time (int new_value)
866{
867 per_command_time = new_value;
868}
869
870/* Set whether to display space statistics to NEW_VALUE
871 (non-zero means true). */
872
873void
874set_per_command_space (int new_value)
875{
876 per_command_space = new_value;
877}
878
879/* Count the number of symtabs and blocks. */
880
881static void
43f3e411 882count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
bd712aed
DE
883 int *nr_blocks_ptr)
884{
bd712aed 885 int nr_symtabs = 0;
43f3e411 886 int nr_compunit_symtabs = 0;
bd712aed
DE
887 int nr_blocks = 0;
888
b8b8facf
DE
889 /* When collecting statistics during startup, this is called before
890 pretty much anything in gdb has been initialized, and thus
891 current_program_space may be NULL. */
892 if (current_program_space != NULL)
bd712aed 893 {
2030c079 894 for (objfile *o : current_program_space->objfiles ())
bd712aed 895 {
b669c953 896 for (compunit_symtab *cu : o->compunits ())
d8aeb77f
TT
897 {
898 ++nr_compunit_symtabs;
899 nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu));
5accd1a0
TT
900 nr_symtabs += std::distance (compunit_filetabs (cu).begin (),
901 compunit_filetabs (cu).end ());
d8aeb77f 902 }
bd712aed
DE
903 }
904 }
905
906 *nr_symtabs_ptr = nr_symtabs;
43f3e411 907 *nr_compunit_symtabs_ptr = nr_compunit_symtabs;
bd712aed
DE
908 *nr_blocks_ptr = nr_blocks;
909}
910
1e3b796d
TT
911/* As indicated by display_time and display_space, report GDB's
912 elapsed time and space usage from the base time and space recorded
913 in this object. */
bd712aed 914
1e3b796d 915scoped_command_stats::~scoped_command_stats ()
bd712aed 916{
1e3b796d
TT
917 /* Early exit if we're not reporting any stats. It can be expensive to
918 compute the pre-command values so don't collect them at all if we're
919 not reporting stats. Alas this doesn't work in the startup case because
920 we don't know yet whether we will be reporting the stats. For the
921 startup case collect the data anyway (it should be cheap at this point),
922 and leave it to the reporter to decide whether to print them. */
923 if (m_msg_type
924 && !per_command_time
925 && !per_command_space
926 && !per_command_symtab)
927 return;
bd712aed 928
1e3b796d 929 if (m_time_enabled && per_command_time)
bd712aed 930 {
3847a7bf
TT
931 print_time (_("command finished"));
932
dcb07cfa 933 using namespace std::chrono;
bd712aed 934
dcb07cfa
PA
935 run_time_clock::duration cmd_time
936 = run_time_clock::now () - m_start_cpu_time;
bd712aed 937
dcb07cfa
PA
938 steady_clock::duration wall_time
939 = steady_clock::now () - m_start_wall_time;
bd712aed 940 /* Subtract time spend in prompt_for_continue from walltime. */
dcb07cfa 941 wall_time -= get_prompt_for_continue_wait_time ();
bd712aed 942
1e3b796d 943 printf_unfiltered (!m_msg_type
dcb07cfa
PA
944 ? _("Startup time: %.6f (cpu), %.6f (wall)\n")
945 : _("Command execution time: %.6f (cpu), %.6f (wall)\n"),
946 duration<double> (cmd_time).count (),
947 duration<double> (wall_time).count ());
bd712aed
DE
948 }
949
1e3b796d 950 if (m_space_enabled && per_command_space)
bd712aed 951 {
6242c6a6 952#ifdef HAVE_USEFUL_SBRK
bd712aed
DE
953 char *lim = (char *) sbrk (0);
954
955 long space_now = lim - lim_at_start;
1e3b796d 956 long space_diff = space_now - m_start_space;
bd712aed 957
1e3b796d 958 printf_unfiltered (!m_msg_type
bd712aed
DE
959 ? _("Space used: %ld (%s%ld during startup)\n")
960 : _("Space used: %ld (%s%ld for this command)\n"),
961 space_now,
962 (space_diff >= 0 ? "+" : ""),
963 space_diff);
964#endif
965 }
966
1e3b796d 967 if (m_symtab_enabled && per_command_symtab)
bd712aed 968 {
43f3e411 969 int nr_symtabs, nr_compunit_symtabs, nr_blocks;
bd712aed 970
43f3e411 971 count_symtabs_and_blocks (&nr_symtabs, &nr_compunit_symtabs, &nr_blocks);
bd712aed 972 printf_unfiltered (_("#symtabs: %d (+%d),"
43f3e411 973 " #compunits: %d (+%d),"
bd712aed
DE
974 " #blocks: %d (+%d)\n"),
975 nr_symtabs,
1e3b796d 976 nr_symtabs - m_start_nr_symtabs,
43f3e411
DE
977 nr_compunit_symtabs,
978 (nr_compunit_symtabs
1e3b796d 979 - m_start_nr_compunit_symtabs),
bd712aed 980 nr_blocks,
1e3b796d 981 nr_blocks - m_start_nr_blocks);
bd712aed
DE
982 }
983}
984
1e3b796d
TT
985scoped_command_stats::scoped_command_stats (bool msg_type)
986: m_msg_type (msg_type)
bd712aed 987{
1e3b796d 988 if (!m_msg_type || per_command_space)
bd712aed 989 {
6242c6a6 990#ifdef HAVE_USEFUL_SBRK
bd712aed 991 char *lim = (char *) sbrk (0);
1e3b796d
TT
992 m_start_space = lim - lim_at_start;
993 m_space_enabled = 1;
bd712aed
DE
994#endif
995 }
44d83468
PA
996 else
997 m_space_enabled = 0;
bd712aed 998
b8b8facf 999 if (msg_type == 0 || per_command_time)
bd712aed 1000 {
dcb07cfa
PA
1001 using namespace std::chrono;
1002
1003 m_start_cpu_time = run_time_clock::now ();
1004 m_start_wall_time = steady_clock::now ();
1e3b796d 1005 m_time_enabled = 1;
3847a7bf
TT
1006
1007 if (per_command_time)
1008 print_time (_("command started"));
bd712aed 1009 }
44d83468
PA
1010 else
1011 m_time_enabled = 0;
bd712aed 1012
b8b8facf 1013 if (msg_type == 0 || per_command_symtab)
bd712aed 1014 {
43f3e411 1015 int nr_symtabs, nr_compunit_symtabs, nr_blocks;
bd712aed 1016
43f3e411 1017 count_symtabs_and_blocks (&nr_symtabs, &nr_compunit_symtabs, &nr_blocks);
1e3b796d
TT
1018 m_start_nr_symtabs = nr_symtabs;
1019 m_start_nr_compunit_symtabs = nr_compunit_symtabs;
1020 m_start_nr_blocks = nr_blocks;
1021 m_symtab_enabled = 1;
bd712aed 1022 }
44d83468
PA
1023 else
1024 m_symtab_enabled = 0;
bd712aed 1025
26c4b26f 1026 /* Initialize timer to keep track of how long we waited for the user. */
bd712aed 1027 reset_prompt_for_continue_wait_time ();
bd712aed
DE
1028}
1029
3847a7bf
TT
1030/* See maint.h. */
1031
1032void
1033scoped_command_stats::print_time (const char *msg)
1034{
1035 using namespace std::chrono;
1036
1037 auto now = system_clock::now ();
1038 auto ticks = now.time_since_epoch ().count () / (1000 * 1000);
1039 auto millis = ticks % 1000;
1040
1041 std::time_t as_time = system_clock::to_time_t (now);
1042 struct tm *tm = localtime (&as_time);
1043
1044 char out[100];
1045 strftime (out, sizeof (out), "%F %H:%M:%S", tm);
1046
1047 printf_unfiltered ("%s.%03d - %s\n", out, (int) millis, msg);
1048}
1049
bd712aed
DE
1050/* Handle unknown "mt set per-command" arguments.
1051 In this case have "mt set per-command on|off" affect every setting. */
1052
1053static void
981a3fb3 1054set_per_command_cmd (const char *args, int from_tty)
bd712aed
DE
1055{
1056 struct cmd_list_element *list;
bd712aed
DE
1057 int val;
1058
1059 val = parse_cli_boolean_value (args);
1060 if (val < 0)
1061 error (_("Bad value for 'mt set per-command no'."));
1062
1063 for (list = per_command_setlist; list != NULL; list = list->next)
1064 if (list->var_type == var_boolean)
1065 {
1066 gdb_assert (list->type == set_cmd);
1067 do_set_command (args, from_tty, list);
1068 }
1069}
1070
1071/* Command "show per-command" displays summary of all the current
1072 "show per-command " settings. */
1073
1074static void
981a3fb3 1075show_per_command_cmd (const char *args, int from_tty)
bd712aed
DE
1076{
1077 cmd_show_list (per_command_showlist, from_tty, "");
1078}
dcd1f979
TT
1079\f
1080
1081/* The "maintenance selftest" command. */
1082
1083static void
58971144 1084maintenance_selftest (const char *args, int from_tty)
dcd1f979 1085{
1e5ded6c 1086#if GDB_SELF_TEST
1526853e 1087 selftests::run_tests (args);
1e5ded6c
YQ
1088#else
1089 printf_filtered (_("\
8ecfd7bd 1090Selftests have been disabled for this build.\n"));
1e5ded6c 1091#endif
1526853e
SM
1092}
1093
1094static void
5fed81ff 1095maintenance_info_selftests (const char *arg, int from_tty)
1526853e 1096{
1e5ded6c 1097#if GDB_SELF_TEST
1526853e
SM
1098 printf_filtered ("Registered selftests:\n");
1099 selftests::for_each_selftest ([] (const std::string &name) {
1100 printf_filtered (" - %s\n", name.c_str ());
1101 });
1e5ded6c
YQ
1102#else
1103 printf_filtered (_("\
8ecfd7bd 1104Selftests have been disabled for this build.\n"));
1e5ded6c 1105#endif
dcd1f979
TT
1106}
1107
bd712aed 1108\f
c906108c 1109void
fba45db2 1110_initialize_maint_cmds (void)
c906108c 1111{
439250fb
DE
1112 struct cmd_list_element *cmd;
1113
1bedd215
AC
1114 add_prefix_cmd ("maintenance", class_maintenance, maintenance_command, _("\
1115Commands for use by GDB maintainers.\n\
c906108c 1116Includes commands to dump specific internal GDB structures in\n\
439250fb 1117a human readable form, to cause GDB to deliberately dump core, etc."),
c906108c
SS
1118 &maintenancelist, "maintenance ", 0,
1119 &cmdlist);
1120
1121 add_com_alias ("mt", "maintenance", class_maintenance, 1);
1122
1bedd215
AC
1123 add_prefix_cmd ("info", class_maintenance, maintenance_info_command, _("\
1124Commands for showing internal info about the program being debugged."),
c906108c
SS
1125 &maintenanceinfolist, "maintenance info ", 0,
1126 &maintenancelist);
90515c23 1127 add_alias_cmd ("i", "info", class_maintenance, 1, &maintenancelist);
c906108c 1128
1a966eab 1129 add_cmd ("sections", class_maintenance, maintenance_info_sections, _("\
590042fc 1130List the BFD sections of the exec and core files.\n\
e3d3bfda
MS
1131Arguments may be any combination of:\n\
1132 [one or more section names]\n\
1133 ALLOC LOAD RELOC READONLY CODE DATA ROM CONSTRUCTOR\n\
1134 HAS_CONTENTS NEVER_LOAD COFF_SHARED_LIBRARY IS_COMMON\n\
1135Sections matching any argument will be listed (no argument\n\
1136implies all sections). In addition, the special argument\n\
1137 ALLOBJ\n\
1a966eab 1138lists all sections from all object files, including shared libraries."),
c906108c
SS
1139 &maintenanceinfolist);
1140
1141 add_prefix_cmd ("print", class_maintenance, maintenance_print_command,
1bedd215 1142 _("Maintenance command for printing GDB internal state."),
c906108c
SS
1143 &maintenanceprintlist, "maintenance print ", 0,
1144 &maintenancelist);
1145
1bedd215 1146 add_prefix_cmd ("set", class_maintenance, maintenance_set_cmd, _("\
4f337972 1147Set GDB internal variables used by the GDB maintainer.\n\
1bedd215 1148Configure variables internal to GDB that aid in GDB's maintenance"),
4f337972
AC
1149 &maintenance_set_cmdlist, "maintenance set ",
1150 0/*allow-unknown*/,
1151 &maintenancelist);
1152
1bedd215 1153 add_prefix_cmd ("show", class_maintenance, maintenance_show_cmd, _("\
4f337972 1154Show GDB internal variables used by the GDB maintainer.\n\
1bedd215 1155Configure variables internal to GDB that aid in GDB's maintenance"),
4f337972
AC
1156 &maintenance_show_cmdlist, "maintenance show ",
1157 0/*allow-unknown*/,
1158 &maintenancelist);
1159
fdbc9870
PA
1160 cmd = add_cmd ("with", class_maintenance, maintenance_with_cmd, _("\
1161Like \"with\", but works with \"maintenance set\" variables.\n\
1162Usage: maintenance with SETTING [VALUE] [-- COMMAND]\n\
1163With no COMMAND, repeats the last executed command.\n\
1164SETTING is any setting you can change with the \"maintenance set\"\n\
1165subcommands."),
1166 &maintenancelist);
1167 set_cmd_completer_handle_brkchars (cmd, maintenance_with_cmd_completer);
1168
c906108c 1169#ifndef _WIN32
1a966eab
AC
1170 add_cmd ("dump-me", class_maintenance, maintenance_dump_me, _("\
1171Get fatal error; make debugger dump its core.\n\
8308e54c 1172GDB sets its handling of SIGQUIT back to SIG_DFL and then sends\n\
1a966eab 1173itself a SIGQUIT signal."),
c906108c
SS
1174 &maintenancelist);
1175#endif
1176
1a966eab
AC
1177 add_cmd ("internal-error", class_maintenance,
1178 maintenance_internal_error, _("\
1179Give GDB an internal error.\n\
1180Cause GDB to behave as if an internal error was detected."),
7be570e7
JM
1181 &maintenancelist);
1182
1a966eab
AC
1183 add_cmd ("internal-warning", class_maintenance,
1184 maintenance_internal_warning, _("\
1185Give GDB an internal warning.\n\
1186Cause GDB to behave as if an internal warning was reported."),
dec43320
AC
1187 &maintenancelist);
1188
57fcfb1b
GB
1189 add_cmd ("demangler-warning", class_maintenance,
1190 maintenance_demangler_warning, _("\
1191Give GDB a demangler warning.\n\
1192Cause GDB to behave as if a demangler warning was reported."),
1193 &maintenancelist);
1194
439250fb
DE
1195 cmd = add_cmd ("demangle", class_maintenance, maintenance_demangle, _("\
1196This command has been moved to \"demangle\"."),
1197 &maintenancelist);
1198 deprecate_cmd (cmd, "demangle");
c906108c 1199
bd712aed
DE
1200 add_prefix_cmd ("per-command", class_maintenance, set_per_command_cmd, _("\
1201Per-command statistics settings."),
387cd15b 1202 &per_command_setlist, "maintenance set per-command ",
bd712aed
DE
1203 1/*allow-unknown*/, &maintenance_set_cmdlist);
1204
1205 add_prefix_cmd ("per-command", class_maintenance, show_per_command_cmd, _("\
1206Show per-command statistics settings."),
387cd15b 1207 &per_command_showlist, "maintenance show per-command ",
bd712aed
DE
1208 0/*allow-unknown*/, &maintenance_show_cmdlist);
1209
1210 add_setshow_boolean_cmd ("time", class_maintenance,
1211 &per_command_time, _("\
1212Set whether to display per-command execution time."), _("\
1213Show whether to display per-command execution time."),
1214 _("\
1215If enabled, the execution time for each command will be\n\
1216displayed following the command's output."),
1217 NULL, NULL,
1218 &per_command_setlist, &per_command_showlist);
1219
1220 add_setshow_boolean_cmd ("space", class_maintenance,
1221 &per_command_space, _("\
1222Set whether to display per-command space usage."), _("\
1223Show whether to display per-command space usage."),
1224 _("\
1225If enabled, the space usage for each command will be\n\
1226displayed following the command's output."),
1227 NULL, NULL,
1228 &per_command_setlist, &per_command_showlist);
1229
1230 add_setshow_boolean_cmd ("symtab", class_maintenance,
1231 &per_command_symtab, _("\
1232Set whether to display per-command symtab statistics."), _("\
1233Show whether to display per-command symtab statistics."),
1234 _("\
1235If enabled, the basic symtab statistics for each command will be\n\
1236displayed following the command's output."),
1237 NULL, NULL,
1238 &per_command_setlist, &per_command_showlist);
1239
1240 /* This is equivalent to "mt set per-command time on".
1241 Kept because some people are used to typing "mt time 1". */
1a966eab
AC
1242 add_cmd ("time", class_maintenance, maintenance_time_display, _("\
1243Set the display of time usage.\n\
c906108c 1244If nonzero, will cause the execution time for each command to be\n\
1a966eab 1245displayed, following the command's output."),
c906108c
SS
1246 &maintenancelist);
1247
bd712aed
DE
1248 /* This is equivalent to "mt set per-command space on".
1249 Kept because some people are used to typing "mt space 1". */
1a966eab
AC
1250 add_cmd ("space", class_maintenance, maintenance_space_display, _("\
1251Set the display of space usage.\n\
c906108c 1252If nonzero, will cause the execution space for each command to be\n\
1a966eab 1253displayed, following the command's output."),
c906108c
SS
1254 &maintenancelist);
1255
1a966eab
AC
1256 add_cmd ("type", class_maintenance, maintenance_print_type, _("\
1257Print a type chain for a given symbol.\n\
c906108c 1258For each node in a type chain, print the raw data for each member of\n\
1a966eab 1259the type structure, and the interpretation of the data."),
c906108c
SS
1260 &maintenanceprintlist);
1261
c906108c 1262 add_cmd ("statistics", class_maintenance, maintenance_print_statistics,
1a966eab 1263 _("Print statistics about internal gdb state."),
c906108c
SS
1264 &maintenanceprintlist);
1265
1a966eab
AC
1266 add_cmd ("architecture", class_maintenance,
1267 maintenance_print_architecture, _("\
1268Print the internal architecture configuration.\n\
1269Takes an optional file parameter."),
4b9b3959
AC
1270 &maintenanceprintlist);
1271
27d41eac
YQ
1272 add_prefix_cmd ("check", class_maintenance, maintenance_check_command, _("\
1273Commands for checking internal gdb state."),
1274 &maintenancechecklist, "maintenance check ", 0,
1275 &maintenancelist);
1276
3e43a32a
MS
1277 add_cmd ("translate-address", class_maintenance,
1278 maintenance_translate_address,
1a966eab 1279 _("Translate a section name and address to a symbol."),
c906108c
SS
1280 &maintenancelist);
1281
1a966eab 1282 add_cmd ("deprecate", class_maintenance, maintenance_deprecate, _("\
590042fc
PW
1283Deprecate a command (for testing purposes).\n\
1284Usage: maintenance deprecate COMMANDNAME [\"REPLACEMENT\"]\n\
1285This is used by the testsuite to check the command deprecator.\n\
1286You probably shouldn't use this,\n\
1287rather you should use the C function deprecate_cmd()."), &maintenancelist);
56382845 1288
1a966eab 1289 add_cmd ("undeprecate", class_maintenance, maintenance_undeprecate, _("\
590042fc
PW
1290Undeprecate a command (for testing purposes).\n\
1291Usage: maintenance undeprecate COMMANDNAME\n\
1292This is used by the testsuite to check the command deprecator.\n\
1293You probably shouldn't use this."),
33f91161 1294 &maintenancelist);
56382845 1295
dcd1f979
TT
1296 add_cmd ("selftest", class_maintenance, maintenance_selftest, _("\
1297Run gdb's unit tests.\n\
590042fc 1298Usage: maintenance selftest [FILTER]\n\
dcd1f979 1299This will run any unit tests that were built in to gdb.\n\
1526853e 1300If a filter is given, only the tests with that value in their name will ran."),
dcd1f979
TT
1301 &maintenancelist);
1302
1526853e
SM
1303 add_cmd ("selftests", class_maintenance, maintenance_info_selftests,
1304 _("List the registered selftests."), &maintenanceinfolist);
1305
d28f9cdf 1306 add_setshow_boolean_cmd ("profile", class_maintenance,
7915a72c
AC
1307 &maintenance_profile_p, _("\
1308Set internal profiling."), _("\
1309Show internal profiling."), _("\
1310When enabled GDB is profiled."),
2c5b56ce 1311 maintenance_set_profile_cmd,
920d2a44 1312 show_maintenance_profile_p,
d28f9cdf
DJ
1313 &maintenance_set_cmdlist,
1314 &maintenance_show_cmdlist);
c906108c 1315}
This page took 2.969028 seconds and 4 git commands to generate.