1 /* Support for GDB maintenance commands.
2 Copyright (C) 1992 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 */
35 maintenance_command PARAMS ((char *, int));
38 maintenance_dump_me PARAMS ((char *, int));
41 maintenance_demangle PARAMS ((char *, int));
47 maintenance_command -- access the maintenance subcommands
51 void maintenance_command (char *args, int from_tty)
58 maintenance_command (args, from_tty)
62 printf ("\"maintenance\" must be followed by the name of a maintenance command.\n");
63 help_list (maintenancelist, "maintenance ", -1, stdout);
69 maintenance_dump_me (args, from_tty)
73 if (query ("Should GDB dump core? "))
75 signal (SIGQUIT, SIG_DFL);
76 kill (getpid (), SIGQUIT);
80 /* Someday we should allow demangling for things other than just
81 explicit strings. For example, we might want to be able to
82 specify the address of a string in either GDB's process space
83 or the debuggee's process space, and have gdb fetch and demangle
84 that string. If we have a char* pointer "ptr" that points to
85 a string, we might want to be able to given just the name and
86 have GDB demangle and print what it points to, etc. (FIXME) */
89 maintenance_demangle (args, from_tty)
95 if (args == NULL || *args == '\0')
97 printf ("\"maintenance demangle\" takes an argument to demangle.\n");
101 demangled = cplus_demangle (args, DMGL_ANSI | DMGL_PARAMS);
102 if (demangled != NULL)
104 printf ("%s\n", demangled);
109 printf ("Can't demangle \"%s\"\n", args);
114 /* The "maintenance info" command is defined as a prefix, with allow_unknown 0.
115 Therefore, its own definition is called only for "maintenance info" with
120 maintenance_info_command (arg, from_tty)
124 printf ("\"maintenance info\" must be followed by the name of an info command.\n");
125 help_list (maintenanceinfolist, "maintenance info ", -1, stdout);
129 print_section_table (abfd, asect, ignore)
136 flags = bfd_get_section_flags (abfd, asect);
138 printf_filtered (" %s",
139 local_hex_string_custom
140 ((unsigned long) bfd_section_vma (abfd, asect), "08l"));
141 printf_filtered ("->%s",
142 local_hex_string_custom
143 ((unsigned long) (bfd_section_vma (abfd, asect)
144 + bfd_section_size (abfd, asect)),
146 printf_filtered (" at %s",
147 local_hex_string_custom
148 ((unsigned long) asect->filepos, "08l"));
149 printf_filtered (": %s", bfd_section_name (abfd, asect));
151 if (flags & SEC_ALLOC)
152 printf_filtered (" ALLOC");
153 if (flags & SEC_LOAD)
154 printf_filtered (" LOAD");
155 if (flags & SEC_RELOC)
156 printf_filtered (" RELOC");
157 if (flags & SEC_READONLY)
158 printf_filtered (" READONLY");
159 if (flags & SEC_CODE)
160 printf_filtered (" CODE");
161 if (flags & SEC_DATA)
162 printf_filtered (" DATA");
164 printf_filtered (" ROM");
165 if (flags & SEC_CONSTRUCTOR)
166 printf_filtered (" CONSTRUCTOR");
167 if (flags & SEC_HAS_CONTENTS)
168 printf_filtered (" HAS_CONTENTS");
169 if (flags & SEC_NEVER_LOAD)
170 printf_filtered (" NEVER_LOAD");
171 if (flags & SEC_SHARED_LIBRARY)
172 printf_filtered (" SHARED_LIBRARY");
173 if (flags & SEC_IS_COMMON)
174 printf_filtered (" IS_COMMON");
176 printf_filtered ("\n");
181 maintenance_info_sections (arg, from_tty)
187 printf_filtered ("Exec file:\n");
188 printf_filtered (" `%s', ", bfd_get_filename(exec_bfd));
190 printf_filtered ("file type %s.\n", bfd_get_target(exec_bfd));
191 bfd_map_over_sections(exec_bfd, print_section_table, 0);
196 printf_filtered ("Core file:\n");
197 printf_filtered (" `%s', ", bfd_get_filename(core_bfd));
199 printf_filtered ("file type %s.\n", bfd_get_target(core_bfd));
200 bfd_map_over_sections(core_bfd, print_section_table, 0);
204 /* The "maintenance print" command is defined as a prefix, with allow_unknown
205 0. Therefore, its own definition is called only for "maintenance print"
210 maintenance_print_command (arg, from_tty)
214 printf ("\"maintenance print\" must be followed by the name of a print command.\n");
215 help_list (maintenanceprintlist, "maintenance print ", -1, stdout);
222 _initialize_maint_cmds -- initialize the process file system stuff
226 void _initialize_maint_cmds (void)
230 Do required initializations during gdb startup for using the
231 /proc file system interface.
237 _initialize_maint_cmds ()
239 add_prefix_cmd ("maintenance", class_maintenance, maintenance_command,
240 "Commands for use by GDB maintainers.\n\
241 Includes commands to dump specific internal GDB structures in\n\
242 a human readable form, to cause GDB to deliberately dump core,\n\
243 to test internal functions such as the C++ demangler, etc.",
244 &maintenancelist, "maintenance ", 0,
247 add_com_alias ("mt", "maintenance", class_maintenance, 1);
249 add_prefix_cmd ("info", class_maintenance, maintenance_info_command,
250 "Commands for showing internal info about the program being debugged.",
251 &maintenanceinfolist, "maintenance info ", 0,
254 add_cmd ("sections", class_maintenance, maintenance_info_sections,
255 "List the BFD sections of the exec and core files.",
256 &maintenanceinfolist);
258 add_prefix_cmd ("print", class_maintenance, maintenance_print_command,
259 "Maintenance command for printing GDB internal state.",
260 &maintenanceprintlist, "maintenance print ", 0,
263 add_cmd ("dump-me", class_maintenance, maintenance_dump_me,
264 "Get fatal error; make debugger dump its core.\n\
265 GDB sets it's handling of SIGQUIT back to SIG_DFL and then sends\n\
266 itself a SIGQUIT signal.",
269 add_cmd ("demangle", class_maintenance, maintenance_demangle,
270 "Demangle a C++ mangled name.\n\
271 Call internal GDB demangler routine to demangle a C++ link name\n\
272 and prints the result.",
275 add_cmd ("type", class_maintenance, maintenance_print_type,
276 "Print a type chain for a given symbol.\n\
277 For each node in a type chain, print the raw data for each member of\n\
278 the type structure, and the interpretation of the data.",
279 &maintenanceprintlist);
281 add_cmd ("symbols", class_maintenance, maintenance_print_symbols,
282 "Print dump of current symbol definitions.\n\
283 Entries in the full symbol table are dumped to file OUTFILE.\n\
284 If a SOURCE file is specified, dump only that file's symbols.",
285 &maintenanceprintlist);
287 add_cmd ("msymbols", class_maintenance, maintenance_print_msymbols,
288 "Print dump of current minimal symbol definitions.\n\
289 Entries in the minimal symbol table are dumped to file OUTFILE.\n\
290 If a SOURCE file is specified, dump only that file's minimal symbols.",
291 &maintenanceprintlist);
293 add_cmd ("psymbols", class_maintenance, maintenance_print_psymbols,
294 "Print dump of current partial symbol definitions.\n\
295 Entries in the partial symbol table are dumped to file OUTFILE.\n\
296 If a SOURCE file is specified, dump only that file's partial symbols.",
297 &maintenanceprintlist);
299 add_cmd ("objfiles", class_maintenance, maintenance_print_objfiles,
300 "Print dump of current object file definitions.",
301 &maintenanceprintlist);
305 #endif /* MAINTENANCE_CMDS */