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