maint.c revision 1.1 1 1.1 christos /* Support for GDB maintenance commands.
2 1.1 christos
3 1.1 christos Copyright (C) 1992-2014 Free Software Foundation, Inc.
4 1.1 christos
5 1.1 christos Written by Fred Fish at Cygnus Support.
6 1.1 christos
7 1.1 christos This file is part of GDB.
8 1.1 christos
9 1.1 christos This program is free software; you can redistribute it and/or modify
10 1.1 christos it under the terms of the GNU General Public License as published by
11 1.1 christos the Free Software Foundation; either version 3 of the License, or
12 1.1 christos (at your option) any later version.
13 1.1 christos
14 1.1 christos This program is distributed in the hope that it will be useful,
15 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
16 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 1.1 christos GNU General Public License for more details.
18 1.1 christos
19 1.1 christos You should have received a copy of the GNU General Public License
20 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 1.1 christos
22 1.1 christos
23 1.1 christos #include "defs.h"
24 1.1 christos #include "arch-utils.h"
25 1.1 christos #include <ctype.h>
26 1.1 christos #include <signal.h>
27 1.1 christos #include <sys/time.h>
28 1.1 christos #include <time.h>
29 1.1 christos #include "command.h"
30 1.1 christos #include "gdbcmd.h"
31 1.1 christos #include "symtab.h"
32 1.1 christos #include "block.h"
33 1.1 christos #include "gdbtypes.h"
34 1.1 christos #include "demangle.h"
35 1.1 christos #include "gdbcore.h"
36 1.1 christos #include "expression.h" /* For language.h */
37 1.1 christos #include "language.h"
38 1.1 christos #include "symfile.h"
39 1.1 christos #include "objfiles.h"
40 1.1 christos #include "value.h"
41 1.1 christos #include "gdb_assert.h"
42 1.1 christos #include "top.h"
43 1.1 christos #include "timeval-utils.h"
44 1.1 christos #include "maint.h"
45 1.1 christos
46 1.1 christos #include "cli/cli-decode.h"
47 1.1 christos #include "cli/cli-utils.h"
48 1.1 christos #include "cli/cli-setshow.h"
49 1.1 christos
50 1.1 christos extern void _initialize_maint_cmds (void);
51 1.1 christos
52 1.1 christos static void maintenance_command (char *, int);
53 1.1 christos
54 1.1 christos static void maintenance_internal_error (char *args, int from_tty);
55 1.1 christos
56 1.1 christos static void maintenance_demangle (char *, int);
57 1.1 christos
58 1.1 christos static void maintenance_time_display (char *, int);
59 1.1 christos
60 1.1 christos static void maintenance_space_display (char *, int);
61 1.1 christos
62 1.1 christos static void maintenance_info_command (char *, int);
63 1.1 christos
64 1.1 christos static void maintenance_info_sections (char *, int);
65 1.1 christos
66 1.1 christos static void maintenance_print_command (char *, int);
67 1.1 christos
68 1.1 christos static void maintenance_do_deprecate (char *, int);
69 1.1 christos
70 1.1 christos /* Set this to the maximum number of seconds to wait instead of waiting forever
71 1.1 christos in target_wait(). If this timer times out, then it generates an error and
72 1.1 christos the command is aborted. This replaces most of the need for timeouts in the
73 1.1 christos GDB test suite, and makes it possible to distinguish between a hung target
74 1.1 christos and one with slow communications. */
75 1.1 christos
76 1.1 christos int watchdog = 0;
77 1.1 christos static void
78 1.1 christos show_watchdog (struct ui_file *file, int from_tty,
79 1.1 christos struct cmd_list_element *c, const char *value)
80 1.1 christos {
81 1.1 christos fprintf_filtered (file, _("Watchdog timer is %s.\n"), value);
82 1.1 christos }
83 1.1 christos
84 1.1 christos /* Access the maintenance subcommands. */
85 1.1 christos
86 1.1 christos static void
87 1.1 christos maintenance_command (char *args, int from_tty)
88 1.1 christos {
89 1.1 christos printf_unfiltered (_("\"maintenance\" must be followed by "
90 1.1 christos "the name of a maintenance command.\n"));
91 1.1 christos help_list (maintenancelist, "maintenance ", -1, gdb_stdout);
92 1.1 christos }
93 1.1 christos
94 1.1 christos #ifndef _WIN32
95 1.1 christos static void
96 1.1 christos maintenance_dump_me (char *args, int from_tty)
97 1.1 christos {
98 1.1 christos if (query (_("Should GDB dump core? ")))
99 1.1 christos {
100 1.1 christos #ifdef __DJGPP__
101 1.1 christos /* SIGQUIT by default is ignored, so use SIGABRT instead. */
102 1.1 christos signal (SIGABRT, SIG_DFL);
103 1.1 christos kill (getpid (), SIGABRT);
104 1.1 christos #else
105 1.1 christos signal (SIGQUIT, SIG_DFL);
106 1.1 christos kill (getpid (), SIGQUIT);
107 1.1 christos #endif
108 1.1 christos }
109 1.1 christos }
110 1.1 christos #endif
111 1.1 christos
112 1.1 christos /* Stimulate the internal error mechanism that GDB uses when an
113 1.1 christos internal problem is detected. Allows testing of the mechanism.
114 1.1 christos Also useful when the user wants to drop a core file but not exit
115 1.1 christos GDB. */
116 1.1 christos
117 1.1 christos static void
118 1.1 christos maintenance_internal_error (char *args, int from_tty)
119 1.1 christos {
120 1.1 christos internal_error (__FILE__, __LINE__, "%s", (args == NULL ? "" : args));
121 1.1 christos }
122 1.1 christos
123 1.1 christos /* Stimulate the internal error mechanism that GDB uses when an
124 1.1 christos internal problem is detected. Allows testing of the mechanism.
125 1.1 christos Also useful when the user wants to drop a core file but not exit
126 1.1 christos GDB. */
127 1.1 christos
128 1.1 christos static void
129 1.1 christos maintenance_internal_warning (char *args, int from_tty)
130 1.1 christos {
131 1.1 christos internal_warning (__FILE__, __LINE__, "%s", (args == NULL ? "" : args));
132 1.1 christos }
133 1.1 christos
134 1.1 christos /* Someday we should allow demangling for things other than just
135 1.1 christos explicit strings. For example, we might want to be able to specify
136 1.1 christos the address of a string in either GDB's process space or the
137 1.1 christos debuggee's process space, and have gdb fetch and demangle that
138 1.1 christos string. If we have a char* pointer "ptr" that points to a string,
139 1.1 christos we might want to be able to given just the name and have GDB
140 1.1 christos demangle and print what it points to, etc. (FIXME) */
141 1.1 christos
142 1.1 christos static void
143 1.1 christos maintenance_demangle (char *args, int from_tty)
144 1.1 christos {
145 1.1 christos char *demangled;
146 1.1 christos
147 1.1 christos if (args == NULL || *args == '\0')
148 1.1 christos {
149 1.1 christos printf_unfiltered (_("\"maintenance demangle\" takes "
150 1.1 christos "an argument to demangle.\n"));
151 1.1 christos }
152 1.1 christos else
153 1.1 christos {
154 1.1 christos demangled = language_demangle (current_language, args,
155 1.1 christos DMGL_ANSI | DMGL_PARAMS);
156 1.1 christos if (demangled != NULL)
157 1.1 christos {
158 1.1 christos printf_unfiltered ("%s\n", demangled);
159 1.1 christos xfree (demangled);
160 1.1 christos }
161 1.1 christos else
162 1.1 christos {
163 1.1 christos printf_unfiltered (_("Can't demangle \"%s\"\n"), args);
164 1.1 christos }
165 1.1 christos }
166 1.1 christos }
167 1.1 christos
168 1.1 christos static void
169 1.1 christos maintenance_time_display (char *args, int from_tty)
170 1.1 christos {
171 1.1 christos if (args == NULL || *args == '\0')
172 1.1 christos printf_unfiltered (_("\"maintenance time\" takes a numeric argument.\n"));
173 1.1 christos else
174 1.1 christos set_per_command_time (strtol (args, NULL, 10));
175 1.1 christos }
176 1.1 christos
177 1.1 christos static void
178 1.1 christos maintenance_space_display (char *args, int from_tty)
179 1.1 christos {
180 1.1 christos if (args == NULL || *args == '\0')
181 1.1 christos printf_unfiltered ("\"maintenance space\" takes a numeric argument.\n");
182 1.1 christos else
183 1.1 christos set_per_command_space (strtol (args, NULL, 10));
184 1.1 christos }
185 1.1 christos
186 1.1 christos /* The "maintenance info" command is defined as a prefix, with
187 1.1 christos allow_unknown 0. Therefore, its own definition is called only for
188 1.1 christos "maintenance info" with no args. */
189 1.1 christos
190 1.1 christos static void
191 1.1 christos maintenance_info_command (char *arg, int from_tty)
192 1.1 christos {
193 1.1 christos printf_unfiltered (_("\"maintenance info\" must be followed "
194 1.1 christos "by the name of an info command.\n"));
195 1.1 christos help_list (maintenanceinfolist, "maintenance info ", -1, gdb_stdout);
196 1.1 christos }
197 1.1 christos
198 1.1 christos /* Mini tokenizing lexer for 'maint info sections' command. */
199 1.1 christos
200 1.1 christos static int
201 1.1 christos match_substring (const char *string, const char *substr)
202 1.1 christos {
203 1.1 christos int substr_len = strlen(substr);
204 1.1 christos const char *tok;
205 1.1 christos
206 1.1 christos while ((tok = strstr (string, substr)) != NULL)
207 1.1 christos {
208 1.1 christos /* Got a partial match. Is it a whole word? */
209 1.1 christos if (tok == string
210 1.1 christos || tok[-1] == ' '
211 1.1 christos || tok[-1] == '\t')
212 1.1 christos {
213 1.1 christos /* Token is delimited at the front... */
214 1.1 christos if (tok[substr_len] == ' '
215 1.1 christos || tok[substr_len] == '\t'
216 1.1 christos || tok[substr_len] == '\0')
217 1.1 christos {
218 1.1 christos /* Token is delimited at the rear. Got a whole-word match. */
219 1.1 christos return 1;
220 1.1 christos }
221 1.1 christos }
222 1.1 christos /* Token didn't match as a whole word. Advance and try again. */
223 1.1 christos string = tok + 1;
224 1.1 christos }
225 1.1 christos return 0;
226 1.1 christos }
227 1.1 christos
228 1.1 christos static int
229 1.1 christos match_bfd_flags (char *string, flagword flags)
230 1.1 christos {
231 1.1 christos if (flags & SEC_ALLOC)
232 1.1 christos if (match_substring (string, "ALLOC"))
233 1.1 christos return 1;
234 1.1 christos if (flags & SEC_LOAD)
235 1.1 christos if (match_substring (string, "LOAD"))
236 1.1 christos return 1;
237 1.1 christos if (flags & SEC_RELOC)
238 1.1 christos if (match_substring (string, "RELOC"))
239 1.1 christos return 1;
240 1.1 christos if (flags & SEC_READONLY)
241 1.1 christos if (match_substring (string, "READONLY"))
242 1.1 christos return 1;
243 1.1 christos if (flags & SEC_CODE)
244 1.1 christos if (match_substring (string, "CODE"))
245 1.1 christos return 1;
246 1.1 christos if (flags & SEC_DATA)
247 1.1 christos if (match_substring (string, "DATA"))
248 1.1 christos return 1;
249 1.1 christos if (flags & SEC_ROM)
250 1.1 christos if (match_substring (string, "ROM"))
251 1.1 christos return 1;
252 1.1 christos if (flags & SEC_CONSTRUCTOR)
253 1.1 christos if (match_substring (string, "CONSTRUCTOR"))
254 1.1 christos return 1;
255 1.1 christos if (flags & SEC_HAS_CONTENTS)
256 1.1 christos if (match_substring (string, "HAS_CONTENTS"))
257 1.1 christos return 1;
258 1.1 christos if (flags & SEC_NEVER_LOAD)
259 1.1 christos if (match_substring (string, "NEVER_LOAD"))
260 1.1 christos return 1;
261 1.1 christos if (flags & SEC_COFF_SHARED_LIBRARY)
262 1.1 christos if (match_substring (string, "COFF_SHARED_LIBRARY"))
263 1.1 christos return 1;
264 1.1 christos if (flags & SEC_IS_COMMON)
265 1.1 christos if (match_substring (string, "IS_COMMON"))
266 1.1 christos return 1;
267 1.1 christos
268 1.1 christos return 0;
269 1.1 christos }
270 1.1 christos
271 1.1 christos static void
272 1.1 christos print_bfd_flags (flagword flags)
273 1.1 christos {
274 1.1 christos if (flags & SEC_ALLOC)
275 1.1 christos printf_filtered (" ALLOC");
276 1.1 christos if (flags & SEC_LOAD)
277 1.1 christos printf_filtered (" LOAD");
278 1.1 christos if (flags & SEC_RELOC)
279 1.1 christos printf_filtered (" RELOC");
280 1.1 christos if (flags & SEC_READONLY)
281 1.1 christos printf_filtered (" READONLY");
282 1.1 christos if (flags & SEC_CODE)
283 1.1 christos printf_filtered (" CODE");
284 1.1 christos if (flags & SEC_DATA)
285 1.1 christos printf_filtered (" DATA");
286 1.1 christos if (flags & SEC_ROM)
287 1.1 christos printf_filtered (" ROM");
288 1.1 christos if (flags & SEC_CONSTRUCTOR)
289 1.1 christos printf_filtered (" CONSTRUCTOR");
290 1.1 christos if (flags & SEC_HAS_CONTENTS)
291 1.1 christos printf_filtered (" HAS_CONTENTS");
292 1.1 christos if (flags & SEC_NEVER_LOAD)
293 1.1 christos printf_filtered (" NEVER_LOAD");
294 1.1 christos if (flags & SEC_COFF_SHARED_LIBRARY)
295 1.1 christos printf_filtered (" COFF_SHARED_LIBRARY");
296 1.1 christos if (flags & SEC_IS_COMMON)
297 1.1 christos printf_filtered (" IS_COMMON");
298 1.1 christos }
299 1.1 christos
300 1.1 christos static void
301 1.1 christos maint_print_section_info (const char *name, flagword flags,
302 1.1 christos CORE_ADDR addr, CORE_ADDR endaddr,
303 1.1 christos unsigned long filepos, int addr_size)
304 1.1 christos {
305 1.1 christos printf_filtered (" %s", hex_string_custom (addr, addr_size));
306 1.1 christos printf_filtered ("->%s", hex_string_custom (endaddr, addr_size));
307 1.1 christos printf_filtered (" at %s",
308 1.1 christos hex_string_custom ((unsigned long) filepos, 8));
309 1.1 christos printf_filtered (": %s", name);
310 1.1 christos print_bfd_flags (flags);
311 1.1 christos printf_filtered ("\n");
312 1.1 christos }
313 1.1 christos
314 1.1 christos static void
315 1.1 christos print_bfd_section_info (bfd *abfd,
316 1.1 christos asection *asect,
317 1.1 christos void *arg)
318 1.1 christos {
319 1.1 christos flagword flags = bfd_get_section_flags (abfd, asect);
320 1.1 christos const char *name = bfd_section_name (abfd, asect);
321 1.1 christos
322 1.1 christos if (arg == NULL || *((char *) arg) == '\0'
323 1.1 christos || match_substring ((char *) arg, name)
324 1.1 christos || match_bfd_flags ((char *) arg, flags))
325 1.1 christos {
326 1.1 christos struct gdbarch *gdbarch = gdbarch_from_bfd (abfd);
327 1.1 christos int addr_size = gdbarch_addr_bit (gdbarch) / 8;
328 1.1 christos CORE_ADDR addr, endaddr;
329 1.1 christos
330 1.1 christos addr = bfd_section_vma (abfd, asect);
331 1.1 christos endaddr = addr + bfd_section_size (abfd, asect);
332 1.1 christos printf_filtered (" [%d] ", gdb_bfd_section_index (abfd, asect));
333 1.1 christos maint_print_section_info (name, flags, addr, endaddr,
334 1.1 christos asect->filepos, addr_size);
335 1.1 christos }
336 1.1 christos }
337 1.1 christos
338 1.1 christos static void
339 1.1 christos print_objfile_section_info (bfd *abfd,
340 1.1 christos struct obj_section *asect,
341 1.1 christos char *string)
342 1.1 christos {
343 1.1 christos flagword flags = bfd_get_section_flags (abfd, asect->the_bfd_section);
344 1.1 christos const char *name = bfd_section_name (abfd, asect->the_bfd_section);
345 1.1 christos
346 1.1 christos if (string == NULL || *string == '\0'
347 1.1 christos || match_substring (string, name)
348 1.1 christos || match_bfd_flags (string, flags))
349 1.1 christos {
350 1.1 christos struct gdbarch *gdbarch = gdbarch_from_bfd (abfd);
351 1.1 christos int addr_size = gdbarch_addr_bit (gdbarch) / 8;
352 1.1 christos
353 1.1 christos maint_print_section_info (name, flags,
354 1.1 christos obj_section_addr (asect),
355 1.1 christos obj_section_endaddr (asect),
356 1.1 christos asect->the_bfd_section->filepos,
357 1.1 christos addr_size);
358 1.1 christos }
359 1.1 christos }
360 1.1 christos
361 1.1 christos static void
362 1.1 christos maintenance_info_sections (char *arg, int from_tty)
363 1.1 christos {
364 1.1 christos if (exec_bfd)
365 1.1 christos {
366 1.1 christos printf_filtered (_("Exec file:\n"));
367 1.1 christos printf_filtered (" `%s', ", bfd_get_filename (exec_bfd));
368 1.1 christos wrap_here (" ");
369 1.1 christos printf_filtered (_("file type %s.\n"), bfd_get_target (exec_bfd));
370 1.1 christos if (arg && *arg && match_substring (arg, "ALLOBJ"))
371 1.1 christos {
372 1.1 christos struct objfile *ofile;
373 1.1 christos struct obj_section *osect;
374 1.1 christos
375 1.1 christos /* Only this function cares about the 'ALLOBJ' argument;
376 1.1 christos if 'ALLOBJ' is the only argument, discard it rather than
377 1.1 christos passing it down to print_objfile_section_info (which
378 1.1 christos wouldn't know how to handle it). */
379 1.1 christos if (strcmp (arg, "ALLOBJ") == 0)
380 1.1 christos arg = NULL;
381 1.1 christos
382 1.1 christos ALL_OBJFILES (ofile)
383 1.1 christos {
384 1.1 christos printf_filtered (_(" Object file: %s\n"),
385 1.1 christos bfd_get_filename (ofile->obfd));
386 1.1 christos ALL_OBJFILE_OSECTIONS (ofile, osect)
387 1.1 christos {
388 1.1 christos print_objfile_section_info (ofile->obfd, osect, arg);
389 1.1 christos }
390 1.1 christos }
391 1.1 christos }
392 1.1 christos else
393 1.1 christos bfd_map_over_sections (exec_bfd, print_bfd_section_info, arg);
394 1.1 christos }
395 1.1 christos
396 1.1 christos if (core_bfd)
397 1.1 christos {
398 1.1 christos printf_filtered (_("Core file:\n"));
399 1.1 christos printf_filtered (" `%s', ", bfd_get_filename (core_bfd));
400 1.1 christos wrap_here (" ");
401 1.1 christos printf_filtered (_("file type %s.\n"), bfd_get_target (core_bfd));
402 1.1 christos bfd_map_over_sections (core_bfd, print_bfd_section_info, arg);
403 1.1 christos }
404 1.1 christos }
405 1.1 christos
406 1.1 christos static void
407 1.1 christos maintenance_print_statistics (char *args, int from_tty)
408 1.1 christos {
409 1.1 christos print_objfile_statistics ();
410 1.1 christos print_symbol_bcache_statistics ();
411 1.1 christos }
412 1.1 christos
413 1.1 christos static void
414 1.1 christos maintenance_print_architecture (char *args, int from_tty)
415 1.1 christos {
416 1.1 christos struct gdbarch *gdbarch = get_current_arch ();
417 1.1 christos
418 1.1 christos if (args == NULL)
419 1.1 christos gdbarch_dump (gdbarch, gdb_stdout);
420 1.1 christos else
421 1.1 christos {
422 1.1 christos struct cleanup *cleanups;
423 1.1 christos struct ui_file *file = gdb_fopen (args, "w");
424 1.1 christos
425 1.1 christos if (file == NULL)
426 1.1 christos perror_with_name (_("maintenance print architecture"));
427 1.1 christos cleanups = make_cleanup_ui_file_delete (file);
428 1.1 christos gdbarch_dump (gdbarch, file);
429 1.1 christos do_cleanups (cleanups);
430 1.1 christos }
431 1.1 christos }
432 1.1 christos
433 1.1 christos /* The "maintenance print" command is defined as a prefix, with
434 1.1 christos allow_unknown 0. Therefore, its own definition is called only for
435 1.1 christos "maintenance print" with no args. */
436 1.1 christos
437 1.1 christos static void
438 1.1 christos maintenance_print_command (char *arg, int from_tty)
439 1.1 christos {
440 1.1 christos printf_unfiltered (_("\"maintenance print\" must be followed "
441 1.1 christos "by the name of a print command.\n"));
442 1.1 christos help_list (maintenanceprintlist, "maintenance print ", -1, gdb_stdout);
443 1.1 christos }
444 1.1 christos
445 1.1 christos /* The "maintenance translate-address" command converts a section and address
446 1.1 christos to a symbol. This can be called in two ways:
447 1.1 christos maintenance translate-address <secname> <addr>
448 1.1 christos or maintenance translate-address <addr>. */
449 1.1 christos
450 1.1 christos static void
451 1.1 christos maintenance_translate_address (char *arg, int from_tty)
452 1.1 christos {
453 1.1 christos CORE_ADDR address;
454 1.1 christos struct obj_section *sect;
455 1.1 christos char *p;
456 1.1 christos struct bound_minimal_symbol sym;
457 1.1 christos struct objfile *objfile;
458 1.1 christos
459 1.1 christos if (arg == NULL || *arg == 0)
460 1.1 christos error (_("requires argument (address or section + address)"));
461 1.1 christos
462 1.1 christos sect = NULL;
463 1.1 christos p = arg;
464 1.1 christos
465 1.1 christos if (!isdigit (*p))
466 1.1 christos { /* See if we have a valid section name. */
467 1.1 christos while (*p && !isspace (*p)) /* Find end of section name. */
468 1.1 christos p++;
469 1.1 christos if (*p == '\000') /* End of command? */
470 1.1 christos error (_("Need to specify <section-name> and <address>"));
471 1.1 christos *p++ = '\000';
472 1.1 christos p = skip_spaces (p);
473 1.1 christos
474 1.1 christos ALL_OBJSECTIONS (objfile, sect)
475 1.1 christos {
476 1.1 christos if (strcmp (sect->the_bfd_section->name, arg) == 0)
477 1.1 christos break;
478 1.1 christos }
479 1.1 christos
480 1.1 christos if (!objfile)
481 1.1 christos error (_("Unknown section %s."), arg);
482 1.1 christos }
483 1.1 christos
484 1.1 christos address = parse_and_eval_address (p);
485 1.1 christos
486 1.1 christos if (sect)
487 1.1 christos sym = lookup_minimal_symbol_by_pc_section (address, sect);
488 1.1 christos else
489 1.1 christos sym = lookup_minimal_symbol_by_pc (address);
490 1.1 christos
491 1.1 christos if (sym.minsym)
492 1.1 christos {
493 1.1 christos const char *symbol_name = SYMBOL_PRINT_NAME (sym.minsym);
494 1.1 christos const char *symbol_offset
495 1.1 christos = pulongest (address - SYMBOL_VALUE_ADDRESS (sym.minsym));
496 1.1 christos
497 1.1 christos sect = SYMBOL_OBJ_SECTION(sym.objfile, sym.minsym);
498 1.1 christos if (sect != NULL)
499 1.1 christos {
500 1.1 christos const char *section_name;
501 1.1 christos const char *obj_name;
502 1.1 christos
503 1.1 christos gdb_assert (sect->the_bfd_section && sect->the_bfd_section->name);
504 1.1 christos section_name = sect->the_bfd_section->name;
505 1.1 christos
506 1.1 christos gdb_assert (sect->objfile && objfile_name (sect->objfile));
507 1.1 christos obj_name = objfile_name (sect->objfile);
508 1.1 christos
509 1.1 christos if (MULTI_OBJFILE_P ())
510 1.1 christos printf_filtered (_("%s + %s in section %s of %s\n"),
511 1.1 christos symbol_name, symbol_offset,
512 1.1 christos section_name, obj_name);
513 1.1 christos else
514 1.1 christos printf_filtered (_("%s + %s in section %s\n"),
515 1.1 christos symbol_name, symbol_offset, section_name);
516 1.1 christos }
517 1.1 christos else
518 1.1 christos printf_filtered (_("%s + %s\n"), symbol_name, symbol_offset);
519 1.1 christos }
520 1.1 christos else if (sect)
521 1.1 christos printf_filtered (_("no symbol at %s:%s\n"),
522 1.1 christos sect->the_bfd_section->name, hex_string (address));
523 1.1 christos else
524 1.1 christos printf_filtered (_("no symbol at %s\n"), hex_string (address));
525 1.1 christos
526 1.1 christos return;
527 1.1 christos }
528 1.1 christos
529 1.1 christos
530 1.1 christos /* When a command is deprecated the user will be warned the first time
531 1.1 christos the command is used. If possible, a replacement will be
532 1.1 christos offered. */
533 1.1 christos
534 1.1 christos static void
535 1.1 christos maintenance_deprecate (char *args, int from_tty)
536 1.1 christos {
537 1.1 christos if (args == NULL || *args == '\0')
538 1.1 christos {
539 1.1 christos printf_unfiltered (_("\"maintenance deprecate\" takes an argument,\n\
540 1.1 christos the command you want to deprecate, and optionally the replacement command\n\
541 1.1 christos enclosed in quotes.\n"));
542 1.1 christos }
543 1.1 christos
544 1.1 christos maintenance_do_deprecate (args, 1);
545 1.1 christos
546 1.1 christos }
547 1.1 christos
548 1.1 christos
549 1.1 christos static void
550 1.1 christos maintenance_undeprecate (char *args, int from_tty)
551 1.1 christos {
552 1.1 christos if (args == NULL || *args == '\0')
553 1.1 christos {
554 1.1 christos printf_unfiltered (_("\"maintenance undeprecate\" takes an argument, \n\
555 1.1 christos the command you want to undeprecate.\n"));
556 1.1 christos }
557 1.1 christos
558 1.1 christos maintenance_do_deprecate (args, 0);
559 1.1 christos
560 1.1 christos }
561 1.1 christos
562 1.1 christos /* You really shouldn't be using this. It is just for the testsuite.
563 1.1 christos Rather, you should use deprecate_cmd() when the command is created
564 1.1 christos in _initialize_blah().
565 1.1 christos
566 1.1 christos This function deprecates a command and optionally assigns it a
567 1.1 christos replacement. */
568 1.1 christos
569 1.1 christos static void
570 1.1 christos maintenance_do_deprecate (char *text, int deprecate)
571 1.1 christos {
572 1.1 christos struct cmd_list_element *alias = NULL;
573 1.1 christos struct cmd_list_element *prefix_cmd = NULL;
574 1.1 christos struct cmd_list_element *cmd = NULL;
575 1.1 christos
576 1.1 christos char *start_ptr = NULL;
577 1.1 christos char *end_ptr = NULL;
578 1.1 christos int len;
579 1.1 christos char *replacement = NULL;
580 1.1 christos
581 1.1 christos if (text == NULL)
582 1.1 christos return;
583 1.1 christos
584 1.1 christos if (!lookup_cmd_composition (text, &alias, &prefix_cmd, &cmd))
585 1.1 christos {
586 1.1 christos printf_filtered (_("Can't find command '%s' to deprecate.\n"), text);
587 1.1 christos return;
588 1.1 christos }
589 1.1 christos
590 1.1 christos if (deprecate)
591 1.1 christos {
592 1.1 christos /* Look for a replacement command. */
593 1.1 christos start_ptr = strchr (text, '\"');
594 1.1 christos if (start_ptr != NULL)
595 1.1 christos {
596 1.1 christos start_ptr++;
597 1.1 christos end_ptr = strrchr (start_ptr, '\"');
598 1.1 christos if (end_ptr != NULL)
599 1.1 christos {
600 1.1 christos len = end_ptr - start_ptr;
601 1.1 christos start_ptr[len] = '\0';
602 1.1 christos replacement = xstrdup (start_ptr);
603 1.1 christos }
604 1.1 christos }
605 1.1 christos }
606 1.1 christos
607 1.1 christos if (!start_ptr || !end_ptr)
608 1.1 christos replacement = NULL;
609 1.1 christos
610 1.1 christos
611 1.1 christos /* If they used an alias, we only want to deprecate the alias.
612 1.1 christos
613 1.1 christos Note the MALLOCED_REPLACEMENT test. If the command's replacement
614 1.1 christos string was allocated at compile time we don't want to free the
615 1.1 christos memory. */
616 1.1 christos if (alias)
617 1.1 christos {
618 1.1 christos if (alias->flags & MALLOCED_REPLACEMENT)
619 1.1 christos xfree (alias->replacement);
620 1.1 christos
621 1.1 christos if (deprecate)
622 1.1 christos alias->flags |= (DEPRECATED_WARN_USER | CMD_DEPRECATED);
623 1.1 christos else
624 1.1 christos alias->flags &= ~(DEPRECATED_WARN_USER | CMD_DEPRECATED);
625 1.1 christos alias->replacement = replacement;
626 1.1 christos alias->flags |= MALLOCED_REPLACEMENT;
627 1.1 christos return;
628 1.1 christos }
629 1.1 christos else if (cmd)
630 1.1 christos {
631 1.1 christos if (cmd->flags & MALLOCED_REPLACEMENT)
632 1.1 christos xfree (cmd->replacement);
633 1.1 christos
634 1.1 christos if (deprecate)
635 1.1 christos cmd->flags |= (DEPRECATED_WARN_USER | CMD_DEPRECATED);
636 1.1 christos else
637 1.1 christos cmd->flags &= ~(DEPRECATED_WARN_USER | CMD_DEPRECATED);
638 1.1 christos cmd->replacement = replacement;
639 1.1 christos cmd->flags |= MALLOCED_REPLACEMENT;
640 1.1 christos return;
641 1.1 christos }
642 1.1 christos xfree (replacement);
643 1.1 christos }
644 1.1 christos
645 1.1 christos /* Maintenance set/show framework. */
646 1.1 christos
647 1.1 christos struct cmd_list_element *maintenance_set_cmdlist;
648 1.1 christos struct cmd_list_element *maintenance_show_cmdlist;
649 1.1 christos
650 1.1 christos static void
651 1.1 christos maintenance_set_cmd (char *args, int from_tty)
652 1.1 christos {
653 1.1 christos printf_unfiltered (_("\"maintenance set\" must be followed "
654 1.1 christos "by the name of a set command.\n"));
655 1.1 christos help_list (maintenance_set_cmdlist, "maintenance set ", -1, gdb_stdout);
656 1.1 christos }
657 1.1 christos
658 1.1 christos static void
659 1.1 christos maintenance_show_cmd (char *args, int from_tty)
660 1.1 christos {
661 1.1 christos cmd_show_list (maintenance_show_cmdlist, from_tty, "");
662 1.1 christos }
663 1.1 christos
664 1.1 christos /* Profiling support. */
665 1.1 christos
666 1.1 christos static int maintenance_profile_p;
667 1.1 christos static void
668 1.1 christos show_maintenance_profile_p (struct ui_file *file, int from_tty,
669 1.1 christos struct cmd_list_element *c, const char *value)
670 1.1 christos {
671 1.1 christos fprintf_filtered (file, _("Internal profiling is %s.\n"), value);
672 1.1 christos }
673 1.1 christos
674 1.1 christos #ifdef HAVE__ETEXT
675 1.1 christos extern char _etext;
676 1.1 christos #define TEXTEND &_etext
677 1.1 christos #elif defined (HAVE_ETEXT)
678 1.1 christos extern char etext;
679 1.1 christos #define TEXTEND &etext
680 1.1 christos #endif
681 1.1 christos
682 1.1 christos #if defined (HAVE_MONSTARTUP) && defined (HAVE__MCLEANUP) && defined (TEXTEND)
683 1.1 christos
684 1.1 christos static int profiling_state;
685 1.1 christos
686 1.1 christos static void
687 1.1 christos mcleanup_wrapper (void)
688 1.1 christos {
689 1.1 christos extern void _mcleanup (void);
690 1.1 christos
691 1.1 christos if (profiling_state)
692 1.1 christos _mcleanup ();
693 1.1 christos }
694 1.1 christos
695 1.1 christos static void
696 1.1 christos maintenance_set_profile_cmd (char *args, int from_tty,
697 1.1 christos struct cmd_list_element *c)
698 1.1 christos {
699 1.1 christos if (maintenance_profile_p == profiling_state)
700 1.1 christos return;
701 1.1 christos
702 1.1 christos profiling_state = maintenance_profile_p;
703 1.1 christos
704 1.1 christos if (maintenance_profile_p)
705 1.1 christos {
706 1.1 christos static int profiling_initialized;
707 1.1 christos
708 1.1 christos extern void monstartup (unsigned long, unsigned long);
709 1.1 christos extern int main();
710 1.1 christos
711 1.1 christos if (!profiling_initialized)
712 1.1 christos {
713 1.1 christos atexit (mcleanup_wrapper);
714 1.1 christos profiling_initialized = 1;
715 1.1 christos }
716 1.1 christos
717 1.1 christos /* "main" is now always the first function in the text segment, so use
718 1.1 christos its address for monstartup. */
719 1.1 christos monstartup ((unsigned long) &main, (unsigned long) TEXTEND);
720 1.1 christos }
721 1.1 christos else
722 1.1 christos {
723 1.1 christos extern void _mcleanup (void);
724 1.1 christos
725 1.1 christos _mcleanup ();
726 1.1 christos }
727 1.1 christos }
728 1.1 christos #else
729 1.1 christos static void
730 1.1 christos maintenance_set_profile_cmd (char *args, int from_tty,
731 1.1 christos struct cmd_list_element *c)
732 1.1 christos {
733 1.1 christos error (_("Profiling support is not available on this system."));
734 1.1 christos }
735 1.1 christos #endif
736 1.1 christos
737 1.1 christos /* If nonzero, display time usage both at startup and for each command. */
739 1.1 christos
740 1.1 christos static int per_command_time;
741 1.1 christos
742 1.1 christos /* If nonzero, display space usage both at startup and for each command. */
743 1.1 christos
744 1.1 christos static int per_command_space;
745 1.1 christos
746 1.1 christos /* If nonzero, display basic symtab stats for each command. */
747 1.1 christos
748 1.1 christos static int per_command_symtab;
749 1.1 christos
750 1.1 christos /* mt per-command commands. */
751 1.1 christos
752 1.1 christos static struct cmd_list_element *per_command_setlist;
753 1.1 christos static struct cmd_list_element *per_command_showlist;
754 1.1 christos
755 1.1 christos /* Records a run time and space usage to be used as a base for
756 1.1 christos reporting elapsed time or change in space. */
757 1.1 christos
758 1.1 christos struct cmd_stats
759 1.1 christos {
760 1.1 christos /* Zero if the saved time is from the beginning of GDB execution.
761 1.1 christos One if from the beginning of an individual command execution. */
762 1.1 christos int msg_type;
763 1.1 christos /* Track whether the stat was enabled at the start of the command
764 1.1 christos so that we can avoid printing anything if it gets turned on by
765 1.1 christos the current command. */
766 1.1 christos int time_enabled : 1;
767 1.1 christos int space_enabled : 1;
768 1.1 christos int symtab_enabled : 1;
769 1.1 christos long start_cpu_time;
770 1.1 christos struct timeval start_wall_time;
771 1.1 christos long start_space;
772 1.1 christos /* Total number of symtabs (over all objfiles). */
773 1.1 christos int start_nr_symtabs;
774 1.1 christos /* Of those, a count of just the primary ones. */
775 1.1 christos int start_nr_primary_symtabs;
776 1.1 christos /* Total number of blocks. */
777 1.1 christos int start_nr_blocks;
778 1.1 christos };
779 1.1 christos
780 1.1 christos /* Set whether to display time statistics to NEW_VALUE
781 1.1 christos (non-zero means true). */
782 1.1 christos
783 1.1 christos void
784 1.1 christos set_per_command_time (int new_value)
785 1.1 christos {
786 1.1 christos per_command_time = new_value;
787 1.1 christos }
788 1.1 christos
789 1.1 christos /* Set whether to display space statistics to NEW_VALUE
790 1.1 christos (non-zero means true). */
791 1.1 christos
792 1.1 christos void
793 1.1 christos set_per_command_space (int new_value)
794 1.1 christos {
795 1.1 christos per_command_space = new_value;
796 1.1 christos }
797 1.1 christos
798 1.1 christos /* Count the number of symtabs and blocks. */
799 1.1 christos
800 1.1 christos static void
801 1.1 christos count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_primary_symtabs_ptr,
802 1.1 christos int *nr_blocks_ptr)
803 1.1 christos {
804 1.1 christos struct objfile *o;
805 1.1 christos struct symtab *s;
806 1.1 christos int nr_symtabs = 0;
807 1.1 christos int nr_primary_symtabs = 0;
808 1.1 christos int nr_blocks = 0;
809 1.1 christos
810 1.1 christos ALL_SYMTABS (o, s)
811 1.1 christos {
812 1.1 christos ++nr_symtabs;
813 1.1 christos if (s->primary)
814 1.1 christos {
815 1.1 christos ++nr_primary_symtabs;
816 1.1 christos nr_blocks += BLOCKVECTOR_NBLOCKS (BLOCKVECTOR (s));
817 1.1 christos }
818 1.1 christos }
819 1.1 christos
820 1.1 christos *nr_symtabs_ptr = nr_symtabs;
821 1.1 christos *nr_primary_symtabs_ptr = nr_primary_symtabs;
822 1.1 christos *nr_blocks_ptr = nr_blocks;
823 1.1 christos }
824 1.1 christos
825 1.1 christos /* As indicated by display_time and display_space, report GDB's elapsed time
826 1.1 christos and space usage from the base time and space provided in ARG, which
827 1.1 christos must be a pointer to a struct cmd_stat. This function is intended
828 1.1 christos to be called as a cleanup. */
829 1.1 christos
830 1.1 christos static void
831 1.1 christos report_command_stats (void *arg)
832 1.1 christos {
833 1.1 christos struct cmd_stats *start_stats = (struct cmd_stats *) arg;
834 1.1 christos int msg_type = start_stats->msg_type;
835 1.1 christos
836 1.1 christos if (start_stats->time_enabled)
837 1.1 christos {
838 1.1 christos long cmd_time = get_run_time () - start_stats->start_cpu_time;
839 1.1 christos struct timeval now_wall_time, delta_wall_time, wait_time;
840 1.1 christos
841 1.1 christos gettimeofday (&now_wall_time, NULL);
842 1.1 christos timeval_sub (&delta_wall_time,
843 1.1 christos &now_wall_time, &start_stats->start_wall_time);
844 1.1 christos
845 1.1 christos /* Subtract time spend in prompt_for_continue from walltime. */
846 1.1 christos wait_time = get_prompt_for_continue_wait_time ();
847 1.1 christos timeval_sub (&delta_wall_time, &delta_wall_time, &wait_time);
848 1.1 christos
849 1.1 christos printf_unfiltered (msg_type == 0
850 1.1 christos ? _("Startup time: %ld.%06ld (cpu), %ld.%06ld (wall)\n")
851 1.1 christos : _("Command execution time: %ld.%06ld (cpu), %ld.%06ld (wall)\n"),
852 1.1 christos cmd_time / 1000000, cmd_time % 1000000,
853 1.1 christos (long) delta_wall_time.tv_sec,
854 1.1 christos (long) delta_wall_time.tv_usec);
855 1.1 christos }
856 1.1 christos
857 1.1 christos if (start_stats->space_enabled)
858 1.1 christos {
859 1.1 christos #ifdef HAVE_SBRK
860 1.1 christos char *lim = (char *) sbrk (0);
861 1.1 christos
862 1.1 christos long space_now = lim - lim_at_start;
863 1.1 christos long space_diff = space_now - start_stats->start_space;
864 1.1 christos
865 1.1 christos printf_unfiltered (msg_type == 0
866 1.1 christos ? _("Space used: %ld (%s%ld during startup)\n")
867 1.1 christos : _("Space used: %ld (%s%ld for this command)\n"),
868 1.1 christos space_now,
869 1.1 christos (space_diff >= 0 ? "+" : ""),
870 1.1 christos space_diff);
871 1.1 christos #endif
872 1.1 christos }
873 1.1 christos
874 1.1 christos if (start_stats->symtab_enabled)
875 1.1 christos {
876 1.1 christos int nr_symtabs, nr_primary_symtabs, nr_blocks;
877 1.1 christos
878 1.1 christos count_symtabs_and_blocks (&nr_symtabs, &nr_primary_symtabs, &nr_blocks);
879 1.1 christos printf_unfiltered (_("#symtabs: %d (+%d),"
880 1.1 christos " #primary symtabs: %d (+%d),"
881 1.1 christos " #blocks: %d (+%d)\n"),
882 1.1 christos nr_symtabs,
883 1.1 christos nr_symtabs - start_stats->start_nr_symtabs,
884 1.1 christos nr_primary_symtabs,
885 1.1 christos nr_primary_symtabs - start_stats->start_nr_primary_symtabs,
886 1.1 christos nr_blocks,
887 1.1 christos nr_blocks - start_stats->start_nr_blocks);
888 1.1 christos }
889 1.1 christos }
890 1.1 christos
891 1.1 christos /* Create a cleanup that reports time and space used since its creation.
892 1.1 christos MSG_TYPE is zero for gdb startup, otherwise it is one(1) to report
893 1.1 christos data for individual commands. */
894 1.1 christos
895 1.1 christos struct cleanup *
896 1.1 christos make_command_stats_cleanup (int msg_type)
897 1.1 christos {
898 1.1 christos struct cmd_stats *new_stat;
899 1.1 christos
900 1.1 christos /* Early exit if we're not reporting any stats. */
901 1.1 christos if (!per_command_time
902 1.1 christos && !per_command_space
903 1.1 christos && !per_command_symtab)
904 1.1 christos return make_cleanup (null_cleanup, 0);
905 1.1 christos
906 1.1 christos new_stat = XZALLOC (struct cmd_stats);
907 1.1 christos
908 1.1 christos new_stat->msg_type = msg_type;
909 1.1 christos
910 1.1 christos if (per_command_space)
911 1.1 christos {
912 1.1 christos #ifdef HAVE_SBRK
913 1.1 christos char *lim = (char *) sbrk (0);
914 1.1 christos new_stat->start_space = lim - lim_at_start;
915 1.1 christos new_stat->space_enabled = 1;
916 1.1 christos #endif
917 1.1 christos }
918 1.1 christos
919 1.1 christos if (per_command_time)
920 1.1 christos {
921 1.1 christos new_stat->start_cpu_time = get_run_time ();
922 1.1 christos gettimeofday (&new_stat->start_wall_time, NULL);
923 1.1 christos new_stat->time_enabled = 1;
924 1.1 christos }
925 1.1 christos
926 1.1 christos if (per_command_symtab)
927 1.1 christos {
928 1.1 christos int nr_symtabs, nr_primary_symtabs, nr_blocks;
929 1.1 christos
930 1.1 christos count_symtabs_and_blocks (&nr_symtabs, &nr_primary_symtabs, &nr_blocks);
931 1.1 christos new_stat->start_nr_symtabs = nr_symtabs;
932 1.1 christos new_stat->start_nr_primary_symtabs = nr_primary_symtabs;
933 1.1 christos new_stat->start_nr_blocks = nr_blocks;
934 1.1 christos new_stat->symtab_enabled = 1;
935 1.1 christos }
936 1.1 christos
937 1.1 christos /* Initalize timer to keep track of how long we waited for the user. */
938 1.1 christos reset_prompt_for_continue_wait_time ();
939 1.1 christos
940 1.1 christos return make_cleanup_dtor (report_command_stats, new_stat, xfree);
941 1.1 christos }
942 1.1 christos
943 1.1 christos /* Handle unknown "mt set per-command" arguments.
944 1.1 christos In this case have "mt set per-command on|off" affect every setting. */
945 1.1 christos
946 1.1 christos static void
947 1.1 christos set_per_command_cmd (char *args, int from_tty)
948 1.1 christos {
949 1.1 christos struct cmd_list_element *list;
950 1.1 christos size_t length;
951 1.1 christos int val;
952 1.1 christos
953 1.1 christos val = parse_cli_boolean_value (args);
954 1.1 christos if (val < 0)
955 1.1 christos error (_("Bad value for 'mt set per-command no'."));
956 1.1 christos
957 1.1 christos for (list = per_command_setlist; list != NULL; list = list->next)
958 1.1 christos if (list->var_type == var_boolean)
959 1.1 christos {
960 1.1 christos gdb_assert (list->type == set_cmd);
961 1.1 christos do_set_command (args, from_tty, list);
962 1.1 christos }
963 1.1 christos }
964 1.1 christos
965 1.1 christos /* Command "show per-command" displays summary of all the current
966 1.1 christos "show per-command " settings. */
967 1.1 christos
968 1.1 christos static void
969 1.1 christos show_per_command_cmd (char *args, int from_tty)
970 1.1 christos {
971 1.1 christos cmd_show_list (per_command_showlist, from_tty, "");
972 1.1 christos }
973 1.1 christos
974 1.1 christos void
976 1.1 christos _initialize_maint_cmds (void)
977 1.1 christos {
978 1.1 christos add_prefix_cmd ("maintenance", class_maintenance, maintenance_command, _("\
979 1.1 christos Commands for use by GDB maintainers.\n\
980 1.1 christos Includes commands to dump specific internal GDB structures in\n\
981 1.1 christos a human readable form, to cause GDB to deliberately dump core,\n\
982 1.1 christos to test internal functions such as the C++/ObjC demangler, etc."),
983 1.1 christos &maintenancelist, "maintenance ", 0,
984 1.1 christos &cmdlist);
985 1.1 christos
986 1.1 christos add_com_alias ("mt", "maintenance", class_maintenance, 1);
987 1.1 christos
988 1.1 christos add_prefix_cmd ("info", class_maintenance, maintenance_info_command, _("\
989 1.1 christos Commands for showing internal info about the program being debugged."),
990 1.1 christos &maintenanceinfolist, "maintenance info ", 0,
991 1.1 christos &maintenancelist);
992 1.1 christos add_alias_cmd ("i", "info", class_maintenance, 1, &maintenancelist);
993 1.1 christos
994 1.1 christos add_cmd ("sections", class_maintenance, maintenance_info_sections, _("\
995 1.1 christos List the BFD sections of the exec and core files. \n\
996 1.1 christos Arguments may be any combination of:\n\
997 1.1 christos [one or more section names]\n\
998 1.1 christos ALLOC LOAD RELOC READONLY CODE DATA ROM CONSTRUCTOR\n\
999 1.1 christos HAS_CONTENTS NEVER_LOAD COFF_SHARED_LIBRARY IS_COMMON\n\
1000 1.1 christos Sections matching any argument will be listed (no argument\n\
1001 1.1 christos implies all sections). In addition, the special argument\n\
1002 1.1 christos ALLOBJ\n\
1003 1.1 christos lists all sections from all object files, including shared libraries."),
1004 1.1 christos &maintenanceinfolist);
1005 1.1 christos
1006 1.1 christos add_prefix_cmd ("print", class_maintenance, maintenance_print_command,
1007 1.1 christos _("Maintenance command for printing GDB internal state."),
1008 1.1 christos &maintenanceprintlist, "maintenance print ", 0,
1009 1.1 christos &maintenancelist);
1010 1.1 christos
1011 1.1 christos add_prefix_cmd ("set", class_maintenance, maintenance_set_cmd, _("\
1012 1.1 christos Set GDB internal variables used by the GDB maintainer.\n\
1013 1.1 christos Configure variables internal to GDB that aid in GDB's maintenance"),
1014 1.1 christos &maintenance_set_cmdlist, "maintenance set ",
1015 1.1 christos 0/*allow-unknown*/,
1016 1.1 christos &maintenancelist);
1017 1.1 christos
1018 1.1 christos add_prefix_cmd ("show", class_maintenance, maintenance_show_cmd, _("\
1019 1.1 christos Show GDB internal variables used by the GDB maintainer.\n\
1020 1.1 christos Configure variables internal to GDB that aid in GDB's maintenance"),
1021 1.1 christos &maintenance_show_cmdlist, "maintenance show ",
1022 1.1 christos 0/*allow-unknown*/,
1023 1.1 christos &maintenancelist);
1024 1.1 christos
1025 1.1 christos #ifndef _WIN32
1026 1.1 christos add_cmd ("dump-me", class_maintenance, maintenance_dump_me, _("\
1027 1.1 christos Get fatal error; make debugger dump its core.\n\
1028 1.1 christos GDB sets its handling of SIGQUIT back to SIG_DFL and then sends\n\
1029 1.1 christos itself a SIGQUIT signal."),
1030 1.1 christos &maintenancelist);
1031 1.1 christos #endif
1032 1.1 christos
1033 1.1 christos add_cmd ("internal-error", class_maintenance,
1034 1.1 christos maintenance_internal_error, _("\
1035 1.1 christos Give GDB an internal error.\n\
1036 1.1 christos Cause GDB to behave as if an internal error was detected."),
1037 1.1 christos &maintenancelist);
1038 1.1 christos
1039 1.1 christos add_cmd ("internal-warning", class_maintenance,
1040 1.1 christos maintenance_internal_warning, _("\
1041 1.1 christos Give GDB an internal warning.\n\
1042 1.1 christos Cause GDB to behave as if an internal warning was reported."),
1043 1.1 christos &maintenancelist);
1044 1.1 christos
1045 1.1 christos add_cmd ("demangle", class_maintenance, maintenance_demangle, _("\
1046 1.1 christos Demangle a C++/ObjC mangled name.\n\
1047 1.1 christos Call internal GDB demangler routine to demangle a C++ link name\n\
1048 1.1 christos and prints the result."),
1049 1.1 christos &maintenancelist);
1050 1.1 christos
1051 1.1 christos add_prefix_cmd ("per-command", class_maintenance, set_per_command_cmd, _("\
1052 1.1 christos Per-command statistics settings."),
1053 1.1 christos &per_command_setlist, "set per-command ",
1054 1.1 christos 1/*allow-unknown*/, &maintenance_set_cmdlist);
1055 1.1 christos
1056 1.1 christos add_prefix_cmd ("per-command", class_maintenance, show_per_command_cmd, _("\
1057 1.1 christos Show per-command statistics settings."),
1058 1.1 christos &per_command_showlist, "show per-command ",
1059 1.1 christos 0/*allow-unknown*/, &maintenance_show_cmdlist);
1060 1.1 christos
1061 1.1 christos add_setshow_boolean_cmd ("time", class_maintenance,
1062 1.1 christos &per_command_time, _("\
1063 1.1 christos Set whether to display per-command execution time."), _("\
1064 1.1 christos Show whether to display per-command execution time."),
1065 1.1 christos _("\
1066 1.1 christos If enabled, the execution time for each command will be\n\
1067 1.1 christos displayed following the command's output."),
1068 1.1 christos NULL, NULL,
1069 1.1 christos &per_command_setlist, &per_command_showlist);
1070 1.1 christos
1071 1.1 christos add_setshow_boolean_cmd ("space", class_maintenance,
1072 1.1 christos &per_command_space, _("\
1073 1.1 christos Set whether to display per-command space usage."), _("\
1074 1.1 christos Show whether to display per-command space usage."),
1075 1.1 christos _("\
1076 1.1 christos If enabled, the space usage for each command will be\n\
1077 1.1 christos displayed following the command's output."),
1078 1.1 christos NULL, NULL,
1079 1.1 christos &per_command_setlist, &per_command_showlist);
1080 1.1 christos
1081 1.1 christos add_setshow_boolean_cmd ("symtab", class_maintenance,
1082 1.1 christos &per_command_symtab, _("\
1083 1.1 christos Set whether to display per-command symtab statistics."), _("\
1084 1.1 christos Show whether to display per-command symtab statistics."),
1085 1.1 christos _("\
1086 1.1 christos If enabled, the basic symtab statistics for each command will be\n\
1087 1.1 christos displayed following the command's output."),
1088 1.1 christos NULL, NULL,
1089 1.1 christos &per_command_setlist, &per_command_showlist);
1090 1.1 christos
1091 1.1 christos /* This is equivalent to "mt set per-command time on".
1092 1.1 christos Kept because some people are used to typing "mt time 1". */
1093 1.1 christos add_cmd ("time", class_maintenance, maintenance_time_display, _("\
1094 1.1 christos Set the display of time usage.\n\
1095 1.1 christos If nonzero, will cause the execution time for each command to be\n\
1096 1.1 christos displayed, following the command's output."),
1097 1.1 christos &maintenancelist);
1098 1.1 christos
1099 1.1 christos /* This is equivalent to "mt set per-command space on".
1100 1.1 christos Kept because some people are used to typing "mt space 1". */
1101 1.1 christos add_cmd ("space", class_maintenance, maintenance_space_display, _("\
1102 1.1 christos Set the display of space usage.\n\
1103 1.1 christos If nonzero, will cause the execution space for each command to be\n\
1104 1.1 christos displayed, following the command's output."),
1105 1.1 christos &maintenancelist);
1106 1.1 christos
1107 1.1 christos add_cmd ("type", class_maintenance, maintenance_print_type, _("\
1108 1.1 christos Print a type chain for a given symbol.\n\
1109 1.1 christos For each node in a type chain, print the raw data for each member of\n\
1110 1.1 christos the type structure, and the interpretation of the data."),
1111 1.1 christos &maintenanceprintlist);
1112 1.1 christos
1113 1.1 christos add_cmd ("statistics", class_maintenance, maintenance_print_statistics,
1114 1.1 christos _("Print statistics about internal gdb state."),
1115 1.1 christos &maintenanceprintlist);
1116 1.1 christos
1117 1.1 christos add_cmd ("architecture", class_maintenance,
1118 1.1 christos maintenance_print_architecture, _("\
1119 1.1 christos Print the internal architecture configuration.\n\
1120 1.1 christos Takes an optional file parameter."),
1121 1.1 christos &maintenanceprintlist);
1122 1.1 christos
1123 1.1 christos add_cmd ("translate-address", class_maintenance,
1124 1.1 christos maintenance_translate_address,
1125 1.1 christos _("Translate a section name and address to a symbol."),
1126 1.1 christos &maintenancelist);
1127 1.1 christos
1128 1.1 christos add_cmd ("deprecate", class_maintenance, maintenance_deprecate, _("\
1129 1.1 christos Deprecate a command. Note that this is just in here so the \n\
1130 1.1 christos testsuite can check the command deprecator. You probably shouldn't use this,\n\
1131 1.1 christos rather you should use the C function deprecate_cmd(). If you decide you \n\
1132 1.1 christos want to use it: maintenance deprecate 'commandname' \"replacement\". The \n\
1133 1.1 christos replacement is optional."), &maintenancelist);
1134 1.1 christos
1135 1.1 christos add_cmd ("undeprecate", class_maintenance, maintenance_undeprecate, _("\
1136 1.1 christos Undeprecate a command. Note that this is just in here so the \n\
1137 1.1 christos testsuite can check the command deprecator. You probably shouldn't use this,\n\
1138 1.1 christos If you decide you want to use it: maintenance undeprecate 'commandname'"),
1139 1.1 christos &maintenancelist);
1140 1.1 christos
1141 1.1 christos add_setshow_zinteger_cmd ("watchdog", class_maintenance, &watchdog, _("\
1142 1.1 christos Set watchdog timer."), _("\
1143 1.1 christos Show watchdog timer."), _("\
1144 1.1 christos When non-zero, this timeout is used instead of waiting forever for a target\n\
1145 1.1 christos to finish a low-level step or continue operation. If the specified amount\n\
1146 1.1 christos of time passes without a response from the target, an error occurs."),
1147 1.1 christos NULL,
1148 1.1 christos show_watchdog,
1149 1.1 christos &setlist, &showlist);
1150 1.1 christos
1151 1.1 christos add_setshow_boolean_cmd ("profile", class_maintenance,
1152 1.1 christos &maintenance_profile_p, _("\
1153 1.1 christos Set internal profiling."), _("\
1154 1.1 christos Show internal profiling."), _("\
1155 1.1 christos When enabled GDB is profiled."),
1156 1.1 christos maintenance_set_profile_cmd,
1157 1.1 christos show_maintenance_profile_p,
1158 1.1 christos &maintenance_set_cmdlist,
1159 &maintenance_show_cmdlist);
1160 }
1161