1 /* Support for GDB maintenance commands.
2 Copyright 1992, 1993, 1994 Free Software Foundation, Inc.
3 Written by Fred Fish at Cygnus Support.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
24 #if MAINTENANCE_CMDS /* Entire file goes away if not including maint cmds */
33 #include "expression.h" /* For language.h */
36 static void maintenance_command
PARAMS ((char *, int));
38 static void maintenance_dump_me
PARAMS ((char *, int));
40 static void maintenance_demangle
PARAMS ((char *, int));
42 static void maintenance_time_display
PARAMS ((char *, int));
44 static void maintenance_space_display
PARAMS ((char *, int));
50 maintenance_command -- access the maintenance subcommands
54 void maintenance_command (char *args, int from_tty)
61 maintenance_command (args
, from_tty
)
65 printf_unfiltered ("\"maintenance\" must be followed by the name of a maintenance command.\n");
66 help_list (maintenancelist
, "maintenance ", -1, gdb_stdout
);
72 maintenance_dump_me (args
, from_tty
)
76 if (query ("Should GDB dump core? "))
78 signal (SIGQUIT
, SIG_DFL
);
79 kill (getpid (), SIGQUIT
);
83 /* Someday we should allow demangling for things other than just
84 explicit strings. For example, we might want to be able to
85 specify the address of a string in either GDB's process space
86 or the debuggee's process space, and have gdb fetch and demangle
87 that string. If we have a char* pointer "ptr" that points to
88 a string, we might want to be able to given just the name and
89 have GDB demangle and print what it points to, etc. (FIXME) */
92 maintenance_demangle (args
, from_tty
)
98 if (args
== NULL
|| *args
== '\0')
100 printf_unfiltered ("\"maintenance demangle\" takes an argument to demangle.\n");
104 demangled
= cplus_demangle (args
, DMGL_ANSI
| DMGL_PARAMS
);
105 if (demangled
!= NULL
)
107 printf_unfiltered ("%s\n", demangled
);
112 printf_unfiltered ("Can't demangle \"%s\"\n", args
);
118 maintenance_time_display (args
, from_tty
)
122 extern int display_time
;
124 if (args
== NULL
|| *args
== '\0')
125 printf_unfiltered ("\"maintenance time\" takes a numeric argument.\n");
127 display_time
= strtol (args
, NULL
, 10);
131 maintenance_space_display (args
, from_tty
)
135 extern int display_space
;
137 if (args
== NULL
|| *args
== '\0')
138 printf_unfiltered ("\"maintenance space\" takes a numeric argument.\n");
140 display_space
= strtol (args
, NULL
, 10);
143 /* The "maintenance info" command is defined as a prefix, with allow_unknown 0.
144 Therefore, its own definition is called only for "maintenance info" with
149 maintenance_info_command (arg
, from_tty
)
153 printf_unfiltered ("\"maintenance info\" must be followed by the name of an info command.\n");
154 help_list (maintenanceinfolist
, "maintenance info ", -1, gdb_stdout
);
158 print_section_table (abfd
, asect
, ignore
)
165 flags
= bfd_get_section_flags (abfd
, asect
);
167 /* FIXME-32x64: Need print_address_numeric with field width. */
168 printf_filtered (" %s",
169 local_hex_string_custom
170 ((unsigned long) bfd_section_vma (abfd
, asect
), "08l"));
171 printf_filtered ("->%s",
172 local_hex_string_custom
173 ((unsigned long) (bfd_section_vma (abfd
, asect
)
174 + bfd_section_size (abfd
, asect
)),
176 printf_filtered (" at %s",
177 local_hex_string_custom
178 ((unsigned long) asect
->filepos
, "08l"));
179 printf_filtered (": %s", bfd_section_name (abfd
, asect
));
181 if (flags
& SEC_ALLOC
)
182 printf_filtered (" ALLOC");
183 if (flags
& SEC_LOAD
)
184 printf_filtered (" LOAD");
185 if (flags
& SEC_RELOC
)
186 printf_filtered (" RELOC");
187 if (flags
& SEC_READONLY
)
188 printf_filtered (" READONLY");
189 if (flags
& SEC_CODE
)
190 printf_filtered (" CODE");
191 if (flags
& SEC_DATA
)
192 printf_filtered (" DATA");
194 printf_filtered (" ROM");
195 if (flags
& SEC_CONSTRUCTOR
)
196 printf_filtered (" CONSTRUCTOR");
197 if (flags
& SEC_HAS_CONTENTS
)
198 printf_filtered (" HAS_CONTENTS");
199 if (flags
& SEC_NEVER_LOAD
)
200 printf_filtered (" NEVER_LOAD");
201 if (flags
& SEC_COFF_SHARED_LIBRARY
)
202 printf_filtered (" COFF_SHARED_LIBRARY");
203 if (flags
& SEC_IS_COMMON
)
204 printf_filtered (" IS_COMMON");
206 printf_filtered ("\n");
211 maintenance_info_sections (arg
, from_tty
)
217 printf_filtered ("Exec file:\n");
218 printf_filtered (" `%s', ", bfd_get_filename(exec_bfd
));
220 printf_filtered ("file type %s.\n", bfd_get_target(exec_bfd
));
221 bfd_map_over_sections(exec_bfd
, print_section_table
, 0);
226 printf_filtered ("Core file:\n");
227 printf_filtered (" `%s', ", bfd_get_filename(core_bfd
));
229 printf_filtered ("file type %s.\n", bfd_get_target(core_bfd
));
230 bfd_map_over_sections(core_bfd
, print_section_table
, 0);
234 /* The "maintenance print" command is defined as a prefix, with allow_unknown
235 0. Therefore, its own definition is called only for "maintenance print"
240 maintenance_print_command (arg
, from_tty
)
244 printf_unfiltered ("\"maintenance print\" must be followed by the name of a print command.\n");
245 help_list (maintenanceprintlist
, "maintenance print ", -1, gdb_stdout
);
248 #endif /* MAINTENANCE_CMDS */
251 _initialize_maint_cmds ()
253 #if MAINTENANCE_CMDS /* Entire file goes away if not including maint cmds */
254 add_prefix_cmd ("maintenance", class_maintenance
, maintenance_command
,
255 "Commands for use by GDB maintainers.\n\
256 Includes commands to dump specific internal GDB structures in\n\
257 a human readable form, to cause GDB to deliberately dump core,\n\
258 to test internal functions such as the C++ demangler, etc.",
259 &maintenancelist
, "maintenance ", 0,
262 add_com_alias ("mt", "maintenance", class_maintenance
, 1);
264 add_prefix_cmd ("info", class_maintenance
, maintenance_info_command
,
265 "Commands for showing internal info about the program being debugged.",
266 &maintenanceinfolist
, "maintenance info ", 0,
269 add_cmd ("sections", class_maintenance
, maintenance_info_sections
,
270 "List the BFD sections of the exec and core files.",
271 &maintenanceinfolist
);
273 add_prefix_cmd ("print", class_maintenance
, maintenance_print_command
,
274 "Maintenance command for printing GDB internal state.",
275 &maintenanceprintlist
, "maintenance print ", 0,
278 add_cmd ("dump-me", class_maintenance
, maintenance_dump_me
,
279 "Get fatal error; make debugger dump its core.\n\
280 GDB sets it's handling of SIGQUIT back to SIG_DFL and then sends\n\
281 itself a SIGQUIT signal.",
284 add_cmd ("demangle", class_maintenance
, maintenance_demangle
,
285 "Demangle a C++ mangled name.\n\
286 Call internal GDB demangler routine to demangle a C++ link name\n\
287 and prints the result.",
290 add_cmd ("time", class_maintenance
, maintenance_time_display
,
291 "Set the display of time usage.\n\
292 If nonzero, will cause the execution time for each command to be\n\
293 displayed, following the command's output.",
296 add_cmd ("space", class_maintenance
, maintenance_space_display
,
297 "Set the display of space usage.\n\
298 If nonzero, will cause the execution space for each command to be\n\
299 displayed, following the command's output.",
302 add_cmd ("type", class_maintenance
, maintenance_print_type
,
303 "Print a type chain for a given symbol.\n\
304 For each node in a type chain, print the raw data for each member of\n\
305 the type structure, and the interpretation of the data.",
306 &maintenanceprintlist
);
308 add_cmd ("symbols", class_maintenance
, maintenance_print_symbols
,
309 "Print dump of current symbol definitions.\n\
310 Entries in the full symbol table are dumped to file OUTFILE.\n\
311 If a SOURCE file is specified, dump only that file's symbols.",
312 &maintenanceprintlist
);
314 add_cmd ("msymbols", class_maintenance
, maintenance_print_msymbols
,
315 "Print dump of current minimal symbol definitions.\n\
316 Entries in the minimal symbol table are dumped to file OUTFILE.\n\
317 If a SOURCE file is specified, dump only that file's minimal symbols.",
318 &maintenanceprintlist
);
320 add_cmd ("psymbols", class_maintenance
, maintenance_print_psymbols
,
321 "Print dump of current partial symbol definitions.\n\
322 Entries in the partial symbol table are dumped to file OUTFILE.\n\
323 If a SOURCE file is specified, dump only that file's partial symbols.",
324 &maintenanceprintlist
);
326 add_cmd ("objfiles", class_maintenance
, maintenance_print_objfiles
,
327 "Print dump of current object file definitions.",
328 &maintenanceprintlist
);
330 add_cmd ("check-symtabs", class_maintenance
, maintenance_check_symtabs
,
331 "Check consistency of psymtabs and symtabs.",
333 #endif /* MAINTENANCE_CMDS */