Man page for "run" simulator, and install-man target for it.
[deliverable/binutils-gdb.git] / gdb / maint.c
CommitLineData
0239d9b3
FF
1/* Support for GDB maintenance commands.
2 Copyright (C) 1992 Free Software Foundation, Inc.
3 Written by Fred Fish at Cygnus Support.
4
5This file is part of GDB.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21
22#include "defs.h"
23
24#if MAINTENANCE_CMDS /* Entire file goes away if not including maint cmds */
25
26#include <signal.h>
27#include "command.h"
28#include "gdbcmd.h"
29#include "symtab.h"
30#include "gdbtypes.h"
311592ff 31#include "demangle.h"
b1eaba9a 32#include "gdbcore.h"
100f92e2
JK
33#include "expression.h" /* For language.h */
34#include "language.h"
0239d9b3
FF
35
36static void
37maintenance_command PARAMS ((char *, int));
38
39static void
40maintenance_dump_me PARAMS ((char *, int));
41
311592ff
FF
42static void
43maintenance_demangle PARAMS ((char *, int));
44
0239d9b3
FF
45/*
46
47LOCAL FUNCTION
48
49 maintenance_command -- access the maintenance subcommands
50
51SYNOPSIS
52
53 void maintenance_command (char *args, int from_tty)
54
55DESCRIPTION
56
57*/
58
59static void
60maintenance_command (args, from_tty)
61 char *args;
62 int from_tty;
63{
2e9309df
FF
64 printf ("\"maintenance\" must be followed by the name of a maintenance command.\n");
65 help_list (maintenancelist, "maintenance ", -1, stdout);
0239d9b3
FF
66}
67
68
69/* ARGSUSED */
70static void
71maintenance_dump_me (args, from_tty)
72 char *args;
73 int from_tty;
74{
75 if (query ("Should GDB dump core? "))
76 {
77 signal (SIGQUIT, SIG_DFL);
78 kill (getpid (), SIGQUIT);
79 }
80}
81
311592ff
FF
82/* Someday we should allow demangling for things other than just
83 explicit strings. For example, we might want to be able to
84 specify the address of a string in either GDB's process space
85 or the debuggee's process space, and have gdb fetch and demangle
86 that string. If we have a char* pointer "ptr" that points to
87 a string, we might want to be able to given just the name and
88 have GDB demangle and print what it points to, etc. (FIXME) */
89
90static void
91maintenance_demangle (args, from_tty)
92 char *args;
93 int from_tty;
94{
95 char *demangled;
96
97 if (args == NULL || *args == '\0')
98 {
99 printf ("\"maintenance demangle\" takes an argument to demangle.\n");
100 }
101 else
102 {
103 demangled = cplus_demangle (args, DMGL_ANSI | DMGL_PARAMS);
104 if (demangled != NULL)
105 {
106 printf ("%s\n", demangled);
107 free (demangled);
108 }
109 else
110 {
111 printf ("Can't demangle \"%s\"\n", args);
112 }
113 }
114}
115
0239d9b3
FF
116/* The "maintenance info" command is defined as a prefix, with allow_unknown 0.
117 Therefore, its own definition is called only for "maintenance info" with
118 no args. */
119
120/* ARGSUSED */
121static void
122maintenance_info_command (arg, from_tty)
123 char *arg;
124 int from_tty;
125{
126 printf ("\"maintenance info\" must be followed by the name of an info command.\n");
127 help_list (maintenanceinfolist, "maintenance info ", -1, stdout);
128}
129
b1eaba9a
SG
130static void
131print_section_table (abfd, asect, ignore)
132 bfd *abfd;
133 asection *asect;
134 PTR ignore;
135{
136 flagword flags;
137
138 flags = bfd_get_section_flags (abfd, asect);
139
140 printf_filtered (" %s",
5573d7d4
JK
141 local_hex_string_custom
142 ((unsigned long) bfd_section_vma (abfd, asect), "08l"));
b1eaba9a 143 printf_filtered ("->%s",
5573d7d4
JK
144 local_hex_string_custom
145 ((unsigned long) (bfd_section_vma (abfd, asect)
146 + bfd_section_size (abfd, asect)),
147 "08l"));
148 printf_filtered (" at %s",
149 local_hex_string_custom
150 ((unsigned long) asect->filepos, "08l"));
b1eaba9a
SG
151 printf_filtered (": %s", bfd_section_name (abfd, asect));
152
153 if (flags & SEC_ALLOC)
154 printf_filtered (" ALLOC");
155 if (flags & SEC_LOAD)
156 printf_filtered (" LOAD");
157 if (flags & SEC_RELOC)
158 printf_filtered (" RELOC");
159 if (flags & SEC_READONLY)
160 printf_filtered (" READONLY");
161 if (flags & SEC_CODE)
162 printf_filtered (" CODE");
163 if (flags & SEC_DATA)
164 printf_filtered (" DATA");
165 if (flags & SEC_ROM)
166 printf_filtered (" ROM");
167 if (flags & SEC_CONSTRUCTOR)
168 printf_filtered (" CONSTRUCTOR");
169 if (flags & SEC_HAS_CONTENTS)
170 printf_filtered (" HAS_CONTENTS");
171 if (flags & SEC_NEVER_LOAD)
172 printf_filtered (" NEVER_LOAD");
173 if (flags & SEC_SHARED_LIBRARY)
174 printf_filtered (" SHARED_LIBRARY");
175 if (flags & SEC_IS_COMMON)
176 printf_filtered (" IS_COMMON");
177
178 printf_filtered ("\n");
179}
180
181/* ARGSUSED */
182static void
183maintenance_info_sections (arg, from_tty)
184 char *arg;
185 int from_tty;
186{
187 if (exec_bfd)
188 {
189 printf_filtered ("Exec file:\n");
190 printf_filtered (" `%s', ", bfd_get_filename(exec_bfd));
191 wrap_here (" ");
192 printf_filtered ("file type %s.\n", bfd_get_target(exec_bfd));
193 bfd_map_over_sections(exec_bfd, print_section_table, 0);
194 }
195
196 if (core_bfd)
197 {
198 printf_filtered ("Core file:\n");
199 printf_filtered (" `%s', ", bfd_get_filename(core_bfd));
200 wrap_here (" ");
201 printf_filtered ("file type %s.\n", bfd_get_target(core_bfd));
202 bfd_map_over_sections(core_bfd, print_section_table, 0);
203 }
204}
205
311592ff
FF
206/* The "maintenance print" command is defined as a prefix, with allow_unknown
207 0. Therefore, its own definition is called only for "maintenance print"
208 with no args. */
209
210/* ARGSUSED */
211static void
212maintenance_print_command (arg, from_tty)
213 char *arg;
214 int from_tty;
215{
216 printf ("\"maintenance print\" must be followed by the name of a print command.\n");
217 help_list (maintenanceprintlist, "maintenance print ", -1, stdout);
218}
219
0239d9b3
FF
220/*
221
222GLOBAL FUNCTION
223
224 _initialize_maint_cmds -- initialize the process file system stuff
225
226SYNOPSIS
227
228 void _initialize_maint_cmds (void)
229
230DESCRIPTION
231
232 Do required initializations during gdb startup for using the
233 /proc file system interface.
234
235*/
236
237
238void
239_initialize_maint_cmds ()
240{
241 add_prefix_cmd ("maintenance", class_maintenance, maintenance_command,
242 "Commands for use by GDB maintainers.\n\
243Includes commands to dump specific internal GDB structures in\n\
311592ff
FF
244a human readable form, to cause GDB to deliberately dump core,\n\
245to test internal functions such as the C++ demangler, etc.",
2e9309df 246 &maintenancelist, "maintenance ", 0,
0239d9b3
FF
247 &cmdlist);
248
327f7197 249 add_com_alias ("mt", "maintenance", class_maintenance, 1);
311592ff 250
327f7197
JG
251 add_prefix_cmd ("info", class_maintenance, maintenance_info_command,
252 "Commands for showing internal info about the program being debugged.",
2e9309df 253 &maintenanceinfolist, "maintenance info ", 0,
0239d9b3
FF
254 &maintenancelist);
255
b1eaba9a
SG
256 add_cmd ("sections", class_maintenance, maintenance_info_sections,
257 "List the BFD sections of the exec and core files.",
258 &maintenanceinfolist);
259
311592ff
FF
260 add_prefix_cmd ("print", class_maintenance, maintenance_print_command,
261 "Maintenance command for printing GDB internal state.",
262 &maintenanceprintlist, "maintenance print ", 0,
263 &maintenancelist);
264
0239d9b3
FF
265 add_cmd ("dump-me", class_maintenance, maintenance_dump_me,
266 "Get fatal error; make debugger dump its core.\n\
267GDB sets it's handling of SIGQUIT back to SIG_DFL and then sends\n\
268itself a SIGQUIT signal.",
269 &maintenancelist);
270
311592ff
FF
271 add_cmd ("demangle", class_maintenance, maintenance_demangle,
272 "Demangle a C++ mangled name.\n\
273Call internal GDB demangler routine to demangle a C++ link name\n\
274and prints the result.",
275 &maintenancelist);
276
277 add_cmd ("type", class_maintenance, maintenance_print_type,
0239d9b3
FF
278 "Print a type chain for a given symbol.\n\
279For each node in a type chain, print the raw data for each member of\n\
280the type structure, and the interpretation of the data.",
311592ff 281 &maintenanceprintlist);
0239d9b3 282
311592ff 283 add_cmd ("symbols", class_maintenance, maintenance_print_symbols,
0239d9b3
FF
284 "Print dump of current symbol definitions.\n\
285Entries in the full symbol table are dumped to file OUTFILE.\n\
286If a SOURCE file is specified, dump only that file's symbols.",
311592ff 287 &maintenanceprintlist);
0239d9b3 288
311592ff 289 add_cmd ("msymbols", class_maintenance, maintenance_print_msymbols,
0239d9b3
FF
290 "Print dump of current minimal symbol definitions.\n\
291Entries in the minimal symbol table are dumped to file OUTFILE.\n\
292If a SOURCE file is specified, dump only that file's minimal symbols.",
311592ff 293 &maintenanceprintlist);
0239d9b3 294
311592ff 295 add_cmd ("psymbols", class_maintenance, maintenance_print_psymbols,
0239d9b3
FF
296 "Print dump of current partial symbol definitions.\n\
297Entries in the partial symbol table are dumped to file OUTFILE.\n\
298If a SOURCE file is specified, dump only that file's partial symbols.",
311592ff 299 &maintenanceprintlist);
0239d9b3 300
311592ff 301 add_cmd ("objfiles", class_maintenance, maintenance_print_objfiles,
0239d9b3 302 "Print dump of current object file definitions.",
311592ff 303 &maintenanceprintlist);
0239d9b3
FF
304
305}
306
307#endif /* MAINTENANCE_CMDS */
This page took 0.095733 seconds and 4 git commands to generate.