* core-aout.c (fetch_core_registers): Cast core_reg_size to int
[deliverable/binutils-gdb.git] / gdb / command.c
CommitLineData
7d9884b9
JG
1/* Handle lists of commands, their decoding and documentation, for GDB.
2 Copyright 1986, 1989, 1990, 1991 Free Software Foundation, Inc.
dd3b648e 3
99a7de40
JG
4This program is free software; you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation; either version 2 of the License, or
7(at your option) any later version.
dd3b648e 8
99a7de40
JG
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
dd3b648e 13
99a7de40
JG
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
6c9638b4 16Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
dd3b648e
RP
17
18#include "defs.h"
4369a140 19#include "gdbcmd.h"
dd3b648e
RP
20#include "symtab.h"
21#include "value.h"
b52cac6b 22#include "wait.h"
dd3b648e 23#include <ctype.h>
2b576293 24#include "gdb_string.h"
1a494973
C
25#ifdef HAVE_UNISTD_H
26#include <unistd.h>
27#endif
dd3b648e 28
1ab3bf1b
JG
29/* Prototypes for local functions */
30
31static void
32undef_cmd_error PARAMS ((char *, char *));
33
34static void
35show_user PARAMS ((char *, int));
36
37static void
199b2450 38show_user_1 PARAMS ((struct cmd_list_element *, GDB_FILE *));
1ab3bf1b
JG
39
40static void
41make_command PARAMS ((char *, int));
42
43static void
44shell_escape PARAMS ((char *, int));
45
46static int
47parse_binary_operation PARAMS ((char *));
48
49static void
199b2450 50print_doc_line PARAMS ((GDB_FILE *, char *));
dd3b648e 51
f936e20d
RP
52/* Add element named NAME.
53 CLASS is the top level category into which commands are broken down
54 for "help" purposes.
dd3b648e
RP
55 FUN should be the function to execute the command;
56 it will get a character string as argument, with leading
57 and trailing blanks already eliminated.
58
59 DOC is a documentation string for the command.
60 Its first line should be a complete sentence.
61 It should start with ? for a command that is an abbreviation
f936e20d
RP
62 or with * for a command that most users don't need to know about.
63
64 Add this command to command list *LIST. */
dd3b648e
RP
65
66struct cmd_list_element *
67add_cmd (name, class, fun, doc, list)
68 char *name;
69 enum command_class class;
1ab3bf1b 70 void (*fun) PARAMS ((char *, int));
dd3b648e
RP
71 char *doc;
72 struct cmd_list_element **list;
73{
74 register struct cmd_list_element *c
75 = (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element));
76
77 delete_cmd (name, list);
78 c->next = *list;
79 c->name = name;
80 c->class = class;
1ab3bf1b 81 c->function.cfunc = fun;
dd3b648e 82 c->doc = doc;
f56cc4e7
FF
83 c->hook = NULL;
84 c->prefixlist = NULL;
85 c->prefixname = NULL;
dd3b648e
RP
86 c->allow_unknown = 0;
87 c->abbrev_flag = 0;
dd3b648e 88 c->completer = make_symbol_completion_list;
f56cc4e7
FF
89 c->type = not_set_cmd;
90 c->var = NULL;
dd3b648e 91 c->var_type = var_boolean;
f56cc4e7
FF
92 c->enums = NULL;
93 c->user_commands = NULL;
94 c->hookee = NULL;
95 c->cmd_pointer = NULL;
dd3b648e
RP
96 *list = c;
97 return c;
98}
99
100/* Same as above, except that the abbrev_flag is set. */
101
1ab3bf1b
JG
102#if 0 /* Currently unused */
103
dd3b648e
RP
104struct cmd_list_element *
105add_abbrev_cmd (name, class, fun, doc, list)
106 char *name;
107 enum command_class class;
1ab3bf1b 108 void (*fun) PARAMS ((char *, int));
dd3b648e
RP
109 char *doc;
110 struct cmd_list_element **list;
111{
112 register struct cmd_list_element *c
113 = add_cmd (name, class, fun, doc, list);
114
115 c->abbrev_flag = 1;
116 return c;
117}
118
1ab3bf1b
JG
119#endif
120
dd3b648e
RP
121struct cmd_list_element *
122add_alias_cmd (name, oldname, class, abbrev_flag, list)
123 char *name;
124 char *oldname;
125 enum command_class class;
126 int abbrev_flag;
127 struct cmd_list_element **list;
128{
129 /* Must do this since lookup_cmd tries to side-effect its first arg */
130 char *copied_name;
131 register struct cmd_list_element *old;
132 register struct cmd_list_element *c;
133 copied_name = (char *) alloca (strlen (oldname) + 1);
134 strcpy (copied_name, oldname);
135 old = lookup_cmd (&copied_name, *list, "", 1, 1);
136
137 if (old == 0)
138 {
139 delete_cmd (name, list);
140 return 0;
141 }
142
1ab3bf1b 143 c = add_cmd (name, class, old->function.cfunc, old->doc, list);
dd3b648e
RP
144 c->prefixlist = old->prefixlist;
145 c->prefixname = old->prefixname;
146 c->allow_unknown = old->allow_unknown;
147 c->abbrev_flag = abbrev_flag;
a65841d7 148 c->cmd_pointer = old;
dd3b648e
RP
149 return c;
150}
151
152/* Like add_cmd but adds an element for a command prefix:
153 a name that should be followed by a subcommand to be looked up
154 in another command list. PREFIXLIST should be the address
155 of the variable containing that list. */
156
157struct cmd_list_element *
158add_prefix_cmd (name, class, fun, doc, prefixlist, prefixname,
159 allow_unknown, list)
160 char *name;
161 enum command_class class;
1ab3bf1b 162 void (*fun) PARAMS ((char *, int));
dd3b648e
RP
163 char *doc;
164 struct cmd_list_element **prefixlist;
165 char *prefixname;
166 int allow_unknown;
167 struct cmd_list_element **list;
168{
169 register struct cmd_list_element *c = add_cmd (name, class, fun, doc, list);
170 c->prefixlist = prefixlist;
171 c->prefixname = prefixname;
172 c->allow_unknown = allow_unknown;
173 return c;
174}
175
0efe20a6 176/* Like add_prefix_cmd but sets the abbrev_flag on the new command. */
dd3b648e
RP
177
178struct cmd_list_element *
179add_abbrev_prefix_cmd (name, class, fun, doc, prefixlist, prefixname,
1ab3bf1b 180 allow_unknown, list)
dd3b648e
RP
181 char *name;
182 enum command_class class;
1ab3bf1b 183 void (*fun) PARAMS ((char *, int));
dd3b648e
RP
184 char *doc;
185 struct cmd_list_element **prefixlist;
186 char *prefixname;
187 int allow_unknown;
188 struct cmd_list_element **list;
189{
190 register struct cmd_list_element *c = add_cmd (name, class, fun, doc, list);
191 c->prefixlist = prefixlist;
192 c->prefixname = prefixname;
193 c->allow_unknown = allow_unknown;
194 c->abbrev_flag = 1;
195 return c;
196}
197
e6357967 198/* This is an empty "cfunc". */
dd3b648e 199void
e6357967
JK
200not_just_help_class_command (args, from_tty)
201 char *args;
202 int from_tty;
203{
204}
205
206/* This is an empty "sfunc". */
207static void empty_sfunc PARAMS ((char *, int, struct cmd_list_element *));
208
209static void
210empty_sfunc (args, from_tty, c)
dd3b648e
RP
211 char *args;
212 int from_tty;
719d9abb 213 struct cmd_list_element *c;
dd3b648e
RP
214{
215}
216
217/* Add element named NAME to command list LIST (the list for set
218 or some sublist thereof).
219 CLASS is as in add_cmd.
220 VAR_TYPE is the kind of thing we are setting.
221 VAR is address of the variable being controlled by this command.
222 DOC is the documentation string. */
1ab3bf1b 223
dd3b648e
RP
224struct cmd_list_element *
225add_set_cmd (name, class, var_type, var, doc, list)
226 char *name;
227 enum command_class class;
228 var_types var_type;
229 char *var;
230 char *doc;
231 struct cmd_list_element **list;
232{
dd3b648e 233 struct cmd_list_element *c
719d9abb 234 = add_cmd (name, class, NO_FUNCTION, doc, list);
dd3b648e
RP
235
236 c->type = set_cmd;
237 c->var_type = var_type;
238 c->var = var;
719d9abb
JK
239 /* This needs to be something besides NO_FUNCTION so that this isn't
240 treated as a help class. */
e6357967 241 c->function.sfunc = empty_sfunc;
dd3b648e
RP
242 return c;
243}
244
236274b9
SG
245/* Add element named NAME to command list LIST (the list for set
246 or some sublist thereof).
247 CLASS is as in add_cmd.
248 ENUMLIST is a list of strings which may follow NAME.
249 VAR is address of the variable which will contain the matching string
250 (from ENUMLIST).
251 DOC is the documentation string. */
252
253struct cmd_list_element *
254add_set_enum_cmd (name, class, enumlist, var, doc, list)
255 char *name;
256 enum command_class class;
257 char *enumlist[];
258 char *var;
259 char *doc;
260 struct cmd_list_element **list;
261{
262 struct cmd_list_element *c
263 = add_set_cmd (name, class, var_enum, var, doc, list);
264
265 c->enums = enumlist;
266
267 return c;
268}
269
dd3b648e
RP
270/* Where SETCMD has already been added, add the corresponding show
271 command to LIST and return a pointer to it. */
272struct cmd_list_element *
273add_show_from_set (setcmd, list)
274 struct cmd_list_element *setcmd;
275 struct cmd_list_element **list;
276{
277 struct cmd_list_element *showcmd =
278 (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element));
279
4ed3a9ea 280 memcpy (showcmd, setcmd, sizeof (struct cmd_list_element));
dd3b648e
RP
281 delete_cmd (showcmd->name, list);
282 showcmd->type = show_cmd;
283
284 /* Replace "set " at start of docstring with "show ". */
285 if (setcmd->doc[0] == 'S' && setcmd->doc[1] == 'e'
286 && setcmd->doc[2] == 't' && setcmd->doc[3] == ' ')
58ae87f6 287 showcmd->doc = concat ("Show ", setcmd->doc + 4, NULL);
dd3b648e 288 else
199b2450 289 fprintf_unfiltered (gdb_stderr, "GDB internal error: Bad docstring for set command\n");
dd3b648e
RP
290
291 showcmd->next = *list;
292 *list = showcmd;
293 return showcmd;
294}
295
296/* Remove the command named NAME from the command list. */
297
298void
299delete_cmd (name, list)
300 char *name;
301 struct cmd_list_element **list;
302{
303 register struct cmd_list_element *c;
304 struct cmd_list_element *p;
305
2e4964ad 306 while (*list && STREQ ((*list)->name, name))
dd3b648e 307 {
a65841d7
JG
308 if ((*list)->hookee)
309 (*list)->hookee->hook = 0; /* Hook slips out of its mouth */
dd3b648e 310 p = (*list)->next;
be772100 311 free ((PTR)*list);
dd3b648e
RP
312 *list = p;
313 }
314
315 if (*list)
316 for (c = *list; c->next;)
317 {
2e4964ad 318 if (STREQ (c->next->name, name))
dd3b648e 319 {
a65841d7
JG
320 if (c->next->hookee)
321 c->next->hookee->hook = 0; /* hooked cmd gets away. */
dd3b648e 322 p = c->next->next;
be772100 323 free ((PTR)c->next);
dd3b648e
RP
324 c->next = p;
325 }
326 else
327 c = c->next;
328 }
329}
330
dd3b648e
RP
331/* This command really has to deal with two things:
332 * 1) I want documentation on *this string* (usually called by
333 * "help commandname").
334 * 2) I want documentation on *this list* (usually called by
335 * giving a command that requires subcommands. Also called by saying
336 * just "help".)
337 *
338 * I am going to split this into two seperate comamnds, help_cmd and
339 * help_list.
340 */
341
342void
343help_cmd (command, stream)
344 char *command;
199b2450 345 GDB_FILE *stream;
dd3b648e
RP
346{
347 struct cmd_list_element *c;
348 extern struct cmd_list_element *cmdlist;
349
350 if (!command)
351 {
352 help_list (cmdlist, "", all_classes, stream);
353 return;
354 }
355
356 c = lookup_cmd (&command, cmdlist, "", 0, 0);
357
358 if (c == 0)
359 return;
360
361 /* There are three cases here.
362 If c->prefixlist is nonzero, we have a prefix command.
363 Print its documentation, then list its subcommands.
364
365 If c->function is nonzero, we really have a command.
366 Print its documentation and return.
367
368 If c->function is zero, we have a class name.
369 Print its documentation (as if it were a command)
370 and then set class to the number of this class
371 so that the commands in the class will be listed. */
372
373 fputs_filtered (c->doc, stream);
374 fputs_filtered ("\n", stream);
375
1ab3bf1b 376 if (c->prefixlist == 0 && c->function.cfunc != NULL)
dd3b648e
RP
377 return;
378 fprintf_filtered (stream, "\n");
379
380 /* If this is a prefix command, print it's subcommands */
381 if (c->prefixlist)
382 help_list (*c->prefixlist, c->prefixname, all_commands, stream);
383
384 /* If this is a class name, print all of the commands in the class */
1ab3bf1b 385 if (c->function.cfunc == NULL)
dd3b648e 386 help_list (cmdlist, "", c->class, stream);
a65841d7
JG
387
388 if (c->hook)
389 fprintf_filtered (stream, "\nThis command has a hook defined: %s\n",
390 c->hook->name);
dd3b648e
RP
391}
392
393/*
394 * Get a specific kind of help on a command list.
395 *
396 * LIST is the list.
397 * CMDTYPE is the prefix to use in the title string.
398 * CLASS is the class with which to list the nodes of this list (see
399 * documentation for help_cmd_list below), As usual, ALL_COMMANDS for
400 * everything, ALL_CLASSES for just classes, and non-negative for only things
401 * in a specific class.
402 * and STREAM is the output stream on which to print things.
403 * If you call this routine with a class >= 0, it recurses.
404 */
405void
406help_list (list, cmdtype, class, stream)
407 struct cmd_list_element *list;
408 char *cmdtype;
409 enum command_class class;
199b2450 410 GDB_FILE *stream;
dd3b648e
RP
411{
412 int len;
413 char *cmdtype1, *cmdtype2;
414
415 /* If CMDTYPE is "foo ", CMDTYPE1 gets " foo" and CMDTYPE2 gets "foo sub" */
416 len = strlen (cmdtype);
417 cmdtype1 = (char *) alloca (len + 1);
418 cmdtype1[0] = 0;
419 cmdtype2 = (char *) alloca (len + 4);
420 cmdtype2[0] = 0;
421 if (len)
422 {
423 cmdtype1[0] = ' ';
424 strncpy (cmdtype1 + 1, cmdtype, len - 1);
425 cmdtype1[len] = 0;
426 strncpy (cmdtype2, cmdtype, len - 1);
427 strcpy (cmdtype2 + len - 1, " sub");
428 }
429
430 if (class == all_classes)
431 fprintf_filtered (stream, "List of classes of %scommands:\n\n", cmdtype2);
432 else
433 fprintf_filtered (stream, "List of %scommands:\n\n", cmdtype2);
434
435 help_cmd_list (list, class, cmdtype, (int)class >= 0, stream);
436
437 if (class == all_classes)
438 fprintf_filtered (stream, "\n\
439Type \"help%s\" followed by a class name for a list of commands in that class.",
440 cmdtype1);
441
442 fprintf_filtered (stream, "\n\
443Type \"help%s\" followed by %scommand name for full documentation.\n\
444Command name abbreviations are allowed if unambiguous.\n",
445 cmdtype1, cmdtype2);
446}
447
448/* Print only the first line of STR on STREAM. */
449static void
450print_doc_line (stream, str)
199b2450 451 GDB_FILE *stream;
dd3b648e
RP
452 char *str;
453{
454 static char *line_buffer = 0;
455 static int line_size;
456 register char *p;
457
458 if (!line_buffer)
459 {
460 line_size = 80;
461 line_buffer = (char *) xmalloc (line_size);
462 }
463
464 p = str;
465 while (*p && *p != '\n' && *p != '.' && *p != ',')
466 p++;
467 if (p - str > line_size - 1)
468 {
469 line_size = p - str + 1;
be772100 470 free ((PTR)line_buffer);
dd3b648e
RP
471 line_buffer = (char *) xmalloc (line_size);
472 }
473 strncpy (line_buffer, str, p - str);
474 line_buffer[p - str] = '\0';
475 if (islower (line_buffer[0]))
476 line_buffer[0] = toupper (line_buffer[0]);
477 fputs_filtered (line_buffer, stream);
478}
479
480/*
481 * Implement a help command on command list LIST.
482 * RECURSE should be non-zero if this should be done recursively on
483 * all sublists of LIST.
484 * PREFIX is the prefix to print before each command name.
485 * STREAM is the stream upon which the output should be written.
486 * CLASS should be:
487 * A non-negative class number to list only commands in that
488 * class.
489 * ALL_COMMANDS to list all commands in list.
490 * ALL_CLASSES to list all classes in list.
491 *
492 * Note that RECURSE will be active on *all* sublists, not just the
1ab3bf1b 493 * ones selected by the criteria above (ie. the selection mechanism
dd3b648e
RP
494 * is at the low level, not the high-level).
495 */
496void
497help_cmd_list (list, class, prefix, recurse, stream)
498 struct cmd_list_element *list;
499 enum command_class class;
500 char *prefix;
501 int recurse;
199b2450 502 GDB_FILE *stream;
dd3b648e
RP
503{
504 register struct cmd_list_element *c;
505
506 for (c = list; c; c = c->next)
507 {
508 if (c->abbrev_flag == 0 &&
509 (class == all_commands
1ab3bf1b
JG
510 || (class == all_classes && c->function.cfunc == NULL)
511 || (class == c->class && c->function.cfunc != NULL)))
dd3b648e
RP
512 {
513 fprintf_filtered (stream, "%s%s -- ", prefix, c->name);
514 print_doc_line (stream, c->doc);
515 fputs_filtered ("\n", stream);
516 }
517 if (recurse
518 && c->prefixlist != 0
519 && c->abbrev_flag == 0)
520 help_cmd_list (*c->prefixlist, class, c->prefixname, 1, stream);
521 }
522}
523\f
311592ff
FF
524/* This routine takes a line of TEXT and a CLIST in which to start the
525 lookup. When it returns it will have incremented the text pointer past
526 the section of text it matched, set *RESULT_LIST to point to the list in
527 which the last word was matched, and will return a pointer to the cmd
528 list element which the text matches. It will return NULL if no match at
529 all was possible. It will return -1 (cast appropriately, ick) if ambigous
530 matches are possible; in this case *RESULT_LIST will be set to point to
531 the list in which there are ambiguous choices (and *TEXT will be set to
532 the ambiguous text string).
dd3b648e 533
a65841d7
JG
534 If the located command was an abbreviation, this routine returns the base
535 command of the abbreviation.
536
dd3b648e
RP
537 It does no error reporting whatsoever; control will always return
538 to the superior routine.
539
311592ff
FF
540 In the case of an ambiguous return (-1), *RESULT_LIST will be set to point
541 at the prefix_command (ie. the best match) *or* (special case) will be NULL
542 if no prefix command was ever found. For example, in the case of "info a",
543 "info" matches without ambiguity, but "a" could be "args" or "address", so
544 *RESULT_LIST is set to the cmd_list_element for "info". So in this case
545 RESULT_LIST should not be interpeted as a pointer to the beginning of a
a32ebcfd
JK
546 list; it simply points to a specific command. In the case of an ambiguous
547 return *TEXT is advanced past the last non-ambiguous prefix (e.g.
548 "info t" can be "info types" or "info target"; upon return *TEXT has been
549 advanced past "info ").
dd3b648e
RP
550
551 If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise
552 affect the operation).
553
554 This routine does *not* modify the text pointed to by TEXT.
555
311592ff
FF
556 If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which
557 are actually help classes rather than commands (i.e. the function field of
558 the struct cmd_list_element is NULL). */
dd3b648e
RP
559
560struct cmd_list_element *
561lookup_cmd_1 (text, clist, result_list, ignore_help_classes)
562 char **text;
563 struct cmd_list_element *clist, **result_list;
564 int ignore_help_classes;
565{
566 char *p, *command;
567 int len, tmp, nfound;
568 struct cmd_list_element *found, *c;
569
570 while (**text == ' ' || **text == '\t')
571 (*text)++;
572
573 /* Treating underscores as part of command words is important
574 so that "set args_foo()" doesn't get interpreted as
575 "set args _foo()". */
576 for (p = *text;
577 *p && (isalnum(*p) || *p == '-' || *p == '_');
578 p++)
579 ;
580
581 /* If nothing but whitespace, return 0. */
582 if (p == *text)
583 return 0;
584
585 len = p - *text;
586
587 /* *text and p now bracket the first command word to lookup (and
588 it's length is len). We copy this into a local temporary,
589 converting to lower case as we go. */
590
591 command = (char *) alloca (len + 1);
592 for (tmp = 0; tmp < len; tmp++)
593 {
594 char x = (*text)[tmp];
5c71cf23 595 command[tmp] = isupper(x) ? tolower(x) : x;
dd3b648e
RP
596 }
597 command[len] = '\0';
598
599 /* Look it up. */
600 found = 0;
601 nfound = 0;
602 for (c = clist; c; c = c->next)
603 if (!strncmp (command, c->name, len)
1ab3bf1b 604 && (!ignore_help_classes || c->function.cfunc))
dd3b648e
RP
605 {
606 found = c;
607 nfound++;
608 if (c->name[len] == '\0')
609 {
610 nfound = 1;
611 break;
612 }
613 }
614
615 /* If nothing matches, we have a simple failure. */
616 if (nfound == 0)
617 return 0;
618
619 if (nfound > 1)
620 {
621 if (result_list != NULL)
622 /* Will be modified in calling routine
623 if we know what the prefix command is. */
624 *result_list = 0;
625 return (struct cmd_list_element *) -1; /* Ambiguous. */
626 }
627
628 /* We've matched something on this list. Move text pointer forward. */
629
630 *text = p;
a65841d7
JG
631
632 /* If this was an abbreviation, use the base command instead. */
633
634 if (found->cmd_pointer)
635 found = found->cmd_pointer;
636
637 /* If we found a prefix command, keep looking. */
638
dd3b648e
RP
639 if (found->prefixlist)
640 {
641 c = lookup_cmd_1 (text, *found->prefixlist, result_list,
642 ignore_help_classes);
643 if (!c)
644 {
645 /* Didn't find anything; this is as far as we got. */
646 if (result_list != NULL)
647 *result_list = clist;
648 return found;
649 }
650 else if (c == (struct cmd_list_element *) -1)
651 {
652 /* We've gotten this far properley, but the next step
653 is ambiguous. We need to set the result list to the best
654 we've found (if an inferior hasn't already set it). */
655 if (result_list != NULL)
656 if (!*result_list)
657 /* This used to say *result_list = *found->prefixlist
658 If that was correct, need to modify the documentation
659 at the top of this function to clarify what is supposed
660 to be going on. */
661 *result_list = found;
662 return c;
663 }
664 else
665 {
666 /* We matched! */
667 return c;
668 }
669 }
670 else
671 {
672 if (result_list != NULL)
673 *result_list = clist;
674 return found;
675 }
676}
677
81066208
JG
678/* All this hair to move the space to the front of cmdtype */
679
1ab3bf1b 680static void
81066208
JG
681undef_cmd_error (cmdtype, q)
682 char *cmdtype, *q;
683{
684 error ("Undefined %scommand: \"%s\". Try \"help%s%.*s\".",
685 cmdtype,
686 q,
687 *cmdtype? " ": "",
688 strlen(cmdtype)-1,
689 cmdtype);
690}
691
dd3b648e
RP
692/* Look up the contents of *LINE as a command in the command list LIST.
693 LIST is a chain of struct cmd_list_element's.
694 If it is found, return the struct cmd_list_element for that command
695 and update *LINE to point after the command name, at the first argument.
696 If not found, call error if ALLOW_UNKNOWN is zero
697 otherwise (or if error returns) return zero.
698 Call error if specified command is ambiguous,
699 unless ALLOW_UNKNOWN is negative.
700 CMDTYPE precedes the word "command" in the error message.
701
702 If INGNORE_HELP_CLASSES is nonzero, ignore any command list
703 elements which are actually help classes rather than commands (i.e.
704 the function field of the struct cmd_list_element is 0). */
705
706struct cmd_list_element *
707lookup_cmd (line, list, cmdtype, allow_unknown, ignore_help_classes)
708 char **line;
709 struct cmd_list_element *list;
710 char *cmdtype;
711 int allow_unknown;
712 int ignore_help_classes;
713{
714 struct cmd_list_element *last_list = 0;
715 struct cmd_list_element *c =
716 lookup_cmd_1 (line, list, &last_list, ignore_help_classes);
09973223
JK
717#if 0
718 /* This is wrong for complete_command. */
dd3b648e
RP
719 char *ptr = (*line) + strlen (*line) - 1;
720
721 /* Clear off trailing whitespace. */
722 while (ptr >= *line && (*ptr == ' ' || *ptr == '\t'))
723 ptr--;
724 *(ptr + 1) = '\0';
09973223 725#endif
dd3b648e
RP
726
727 if (!c)
728 {
729 if (!allow_unknown)
730 {
731 if (!*line)
732 error ("Lack of needed %scommand", cmdtype);
733 else
734 {
735 char *p = *line, *q;
736
737 while (isalnum(*p) || *p == '-')
738 p++;
739
740 q = (char *) alloca (p - *line + 1);
741 strncpy (q, *line, p - *line);
742 q[p-*line] = '\0';
81066208 743 undef_cmd_error (cmdtype, q);
dd3b648e
RP
744 }
745 }
746 else
747 return 0;
748 }
749 else if (c == (struct cmd_list_element *) -1)
750 {
751 /* Ambigous. Local values should be off prefixlist or called
752 values. */
753 int local_allow_unknown = (last_list ? last_list->allow_unknown :
754 allow_unknown);
755 char *local_cmdtype = last_list ? last_list->prefixname : cmdtype;
756 struct cmd_list_element *local_list =
757 (last_list ? *(last_list->prefixlist) : list);
758
759 if (local_allow_unknown < 0)
760 {
761 if (last_list)
762 return last_list; /* Found something. */
763 else
764 return 0; /* Found nothing. */
765 }
766 else
767 {
768 /* Report as error. */
769 int amb_len;
770 char ambbuf[100];
771
772 for (amb_len = 0;
773 ((*line)[amb_len] && (*line)[amb_len] != ' '
774 && (*line)[amb_len] != '\t');
775 amb_len++)
776 ;
777
778 ambbuf[0] = 0;
779 for (c = local_list; c; c = c->next)
780 if (!strncmp (*line, c->name, amb_len))
781 {
782 if (strlen (ambbuf) + strlen (c->name) + 6 < (int)sizeof ambbuf)
783 {
784 if (strlen (ambbuf))
785 strcat (ambbuf, ", ");
786 strcat (ambbuf, c->name);
787 }
788 else
789 {
790 strcat (ambbuf, "..");
791 break;
792 }
793 }
794 error ("Ambiguous %scommand \"%s\": %s.", local_cmdtype,
795 *line, ambbuf);
796 return 0; /* lint */
797 }
798 }
799 else
800 {
801 /* We've got something. It may still not be what the caller
802 wants (if this command *needs* a subcommand). */
803 while (**line == ' ' || **line == '\t')
804 (*line)++;
805
806 if (c->prefixlist && **line && !c->allow_unknown)
81066208 807 undef_cmd_error (c->prefixname, *line);
dd3b648e
RP
808
809 /* Seems to be what he wants. Return it. */
810 return c;
811 }
812 return 0;
813}
814
815#if 0
816/* Look up the contents of *LINE as a command in the command list LIST.
817 LIST is a chain of struct cmd_list_element's.
818 If it is found, return the struct cmd_list_element for that command
819 and update *LINE to point after the command name, at the first argument.
820 If not found, call error if ALLOW_UNKNOWN is zero
821 otherwise (or if error returns) return zero.
822 Call error if specified command is ambiguous,
823 unless ALLOW_UNKNOWN is negative.
824 CMDTYPE precedes the word "command" in the error message. */
825
826struct cmd_list_element *
827lookup_cmd (line, list, cmdtype, allow_unknown)
828 char **line;
829 struct cmd_list_element *list;
830 char *cmdtype;
831 int allow_unknown;
832{
833 register char *p;
834 register struct cmd_list_element *c, *found;
835 int nfound;
836 char ambbuf[100];
837 char *processed_cmd;
838 int i, cmd_len;
839
840 /* Skip leading whitespace. */
841
842 while (**line == ' ' || **line == '\t')
843 (*line)++;
844
845 /* Clear out trailing whitespace. */
846
847 p = *line + strlen (*line);
848 while (p != *line && (p[-1] == ' ' || p[-1] == '\t'))
849 p--;
850 *p = 0;
851
852 /* Find end of command name. */
853
854 p = *line;
5c71cf23 855 while (*p == '-' || isalnum(*p))
dd3b648e
RP
856 p++;
857
858 /* Look up the command name.
859 If exact match, keep that.
860 Otherwise, take command abbreviated, if unique. Note that (in my
861 opinion) a null string does *not* indicate ambiguity; simply the
862 end of the argument. */
863
864 if (p == *line)
865 {
866 if (!allow_unknown)
867 error ("Lack of needed %scommand", cmdtype);
868 return 0;
869 }
870
871 /* Copy over to a local buffer, converting to lowercase on the way.
872 This is in case the command being parsed is a subcommand which
873 doesn't match anything, and that's ok. We want the original
874 untouched for the routine of the original command. */
875
876 processed_cmd = (char *) alloca (p - *line + 1);
877 for (cmd_len = 0; cmd_len < p - *line; cmd_len++)
878 {
879 char x = (*line)[cmd_len];
5c71cf23
PB
880 if (isupper(x))
881 processed_cmd[cmd_len] = tolower(x);
dd3b648e
RP
882 else
883 processed_cmd[cmd_len] = x;
884 }
885 processed_cmd[cmd_len] = '\0';
886
887 /* Check all possibilities in the current command list. */
888 found = 0;
889 nfound = 0;
890 for (c = list; c; c = c->next)
891 {
892 if (!strncmp (processed_cmd, c->name, cmd_len))
893 {
894 found = c;
895 nfound++;
896 if (c->name[cmd_len] == 0)
897 {
898 nfound = 1;
899 break;
900 }
901 }
902 }
903
904 /* Report error for undefined command name. */
905
906 if (nfound != 1)
907 {
908 if (nfound > 1 && allow_unknown >= 0)
909 {
910 ambbuf[0] = 0;
911 for (c = list; c; c = c->next)
912 if (!strncmp (processed_cmd, c->name, cmd_len))
913 {
914 if (strlen (ambbuf) + strlen (c->name) + 6 < sizeof ambbuf)
915 {
916 if (strlen (ambbuf))
917 strcat (ambbuf, ", ");
918 strcat (ambbuf, c->name);
919 }
920 else
921 {
922 strcat (ambbuf, "..");
923 break;
924 }
925 }
926 error ("Ambiguous %scommand \"%s\": %s.", cmdtype,
927 processed_cmd, ambbuf);
928 }
929 else if (!allow_unknown)
930 error ("Undefined %scommand: \"%s\".", cmdtype, processed_cmd);
931 return 0;
932 }
933
934 /* Skip whitespace before the argument. */
935
936 while (*p == ' ' || *p == '\t') p++;
937 *line = p;
938
939 if (found->prefixlist && *p)
940 {
941 c = lookup_cmd (line, *found->prefixlist, found->prefixname,
942 found->allow_unknown);
943 if (c)
944 return c;
945 }
946
947 return found;
948}
949#endif
950
951/* Helper function for SYMBOL_COMPLETION_FUNCTION. */
952
953/* Return a vector of char pointers which point to the different
a32ebcfd
JK
954 possible completions in LIST of TEXT.
955
956 WORD points in the same buffer as TEXT, and completions should be
957 returned relative to this position. For example, suppose TEXT is "foo"
958 and we want to complete to "foobar". If WORD is "oo", return
959 "oobar"; if WORD is "baz/foo", return "baz/foobar". */
dd3b648e
RP
960
961char **
a32ebcfd 962complete_on_cmdlist (list, text, word)
dd3b648e
RP
963 struct cmd_list_element *list;
964 char *text;
a32ebcfd 965 char *word;
dd3b648e
RP
966{
967 struct cmd_list_element *ptr;
968 char **matchlist;
969 int sizeof_matchlist;
970 int matches;
971 int textlen = strlen (text);
972
973 sizeof_matchlist = 10;
974 matchlist = (char **) xmalloc (sizeof_matchlist * sizeof (char *));
975 matches = 0;
976
977 for (ptr = list; ptr; ptr = ptr->next)
978 if (!strncmp (ptr->name, text, textlen)
979 && !ptr->abbrev_flag
1ab3bf1b 980 && (ptr->function.cfunc
dd3b648e
RP
981 || ptr->prefixlist))
982 {
983 if (matches == sizeof_matchlist)
984 {
985 sizeof_matchlist *= 2;
986 matchlist = (char **) xrealloc ((char *)matchlist,
987 (sizeof_matchlist
988 * sizeof (char *)));
989 }
990
991 matchlist[matches] = (char *)
a32ebcfd
JK
992 xmalloc (strlen (word) + strlen (ptr->name) + 1);
993 if (word == text)
994 strcpy (matchlist[matches], ptr->name);
995 else if (word > text)
996 {
997 /* Return some portion of ptr->name. */
998 strcpy (matchlist[matches], ptr->name + (word - text));
999 }
1000 else
1001 {
1002 /* Return some of text plus ptr->name. */
1003 strncpy (matchlist[matches], word, text - word);
1004 matchlist[matches][text - word] = '\0';
1005 strcat (matchlist[matches], ptr->name);
1006 }
1007 ++matches;
dd3b648e
RP
1008 }
1009
1010 if (matches == 0)
1011 {
be772100 1012 free ((PTR)matchlist);
dd3b648e
RP
1013 matchlist = 0;
1014 }
1015 else
1016 {
1017 matchlist = (char **) xrealloc ((char *)matchlist, ((matches + 1)
1018 * sizeof (char *)));
1019 matchlist[matches] = (char *) 0;
1020 }
1021
1022 return matchlist;
1023}
1024
236274b9
SG
1025/* Helper function for SYMBOL_COMPLETION_FUNCTION. */
1026
1027/* Return a vector of char pointers which point to the different
1028 possible completions in CMD of TEXT.
1029
1030 WORD points in the same buffer as TEXT, and completions should be
1031 returned relative to this position. For example, suppose TEXT is "foo"
1032 and we want to complete to "foobar". If WORD is "oo", return
1033 "oobar"; if WORD is "baz/foo", return "baz/foobar". */
1034
1035char **
1036complete_on_enum (enumlist, text, word)
1037 char **enumlist;
1038 char *text;
1039 char *word;
1040{
1041 char **matchlist;
1042 int sizeof_matchlist;
1043 int matches;
1044 int textlen = strlen (text);
1045 int i;
1046 char *name;
1047
1048 sizeof_matchlist = 10;
1049 matchlist = (char **) xmalloc (sizeof_matchlist * sizeof (char *));
1050 matches = 0;
1051
b52cac6b 1052 for (i = 0; (name = enumlist[i]) != NULL; i++)
236274b9
SG
1053 if (strncmp (name, text, textlen) == 0)
1054 {
1055 if (matches == sizeof_matchlist)
1056 {
1057 sizeof_matchlist *= 2;
1058 matchlist = (char **) xrealloc ((char *)matchlist,
1059 (sizeof_matchlist
1060 * sizeof (char *)));
1061 }
1062
1063 matchlist[matches] = (char *)
1064 xmalloc (strlen (word) + strlen (name) + 1);
1065 if (word == text)
1066 strcpy (matchlist[matches], name);
1067 else if (word > text)
1068 {
1069 /* Return some portion of name. */
1070 strcpy (matchlist[matches], name + (word - text));
1071 }
1072 else
1073 {
1074 /* Return some of text plus name. */
1075 strncpy (matchlist[matches], word, text - word);
1076 matchlist[matches][text - word] = '\0';
1077 strcat (matchlist[matches], name);
1078 }
1079 ++matches;
1080 }
1081
1082 if (matches == 0)
1083 {
1084 free ((PTR)matchlist);
1085 matchlist = 0;
1086 }
1087 else
1088 {
1089 matchlist = (char **) xrealloc ((char *)matchlist, ((matches + 1)
1090 * sizeof (char *)));
1091 matchlist[matches] = (char *) 0;
1092 }
1093
1094 return matchlist;
1095}
1096
dd3b648e
RP
1097static int
1098parse_binary_operation (arg)
1099 char *arg;
1100{
1101 int length;
1102
1103 if (!arg || !*arg)
1104 return 1;
1105
1106 length = strlen (arg);
1107
1108 while (arg[length - 1] == ' ' || arg[length - 1] == '\t')
1109 length--;
1110
1111 if (!strncmp (arg, "on", length)
1112 || !strncmp (arg, "1", length)
1113 || !strncmp (arg, "yes", length))
1114 return 1;
1115 else
1116 if (!strncmp (arg, "off", length)
1117 || !strncmp (arg, "0", length)
1118 || !strncmp (arg, "no", length))
1119 return 0;
1120 else
1121 {
1122 error ("\"on\" or \"off\" expected.");
1123 return 0;
1124 }
1125}
1126
1127/* Do a "set" or "show" command. ARG is NULL if no argument, or the text
1128 of the argument, and FROM_TTY is nonzero if this command is being entered
1129 directly by the user (i.e. these are just like any other
1130 command). C is the command list element for the command. */
1131void
1132do_setshow_command (arg, from_tty, c)
1133 char *arg;
1134 int from_tty;
1135 struct cmd_list_element *c;
1136{
1137 if (c->type == set_cmd)
1138 {
1139 switch (c->var_type)
1140 {
1141 case var_string:
1142 {
1143 char *new;
1144 char *p;
1145 char *q;
1146 int ch;
1147
1148 if (arg == NULL)
1149 arg = "";
1150 new = (char *) xmalloc (strlen (arg) + 2);
1151 p = arg; q = new;
1ab3bf1b 1152 while ((ch = *p++) != '\000')
dd3b648e
RP
1153 {
1154 if (ch == '\\')
1155 {
1156 /* \ at end of argument is used after spaces
1157 so they won't be lost. */
72e35288
JK
1158 /* This is obsolete now that we no longer strip
1159 trailing whitespace and actually, the backslash
1160 didn't get here in my test, readline or
1161 something did something funky with a backslash
1162 right before a newline. */
dd3b648e
RP
1163 if (*p == 0)
1164 break;
1165 ch = parse_escape (&p);
1166 if (ch == 0)
1167 break; /* C loses */
1168 else if (ch > 0)
1169 *q++ = ch;
1170 }
1171 else
1172 *q++ = ch;
1173 }
72e35288 1174#if 0
dd3b648e
RP
1175 if (*(p - 1) != '\\')
1176 *q++ = ' ';
72e35288 1177#endif
dd3b648e
RP
1178 *q++ = '\0';
1179 new = (char *) xrealloc (new, q - new);
1180 if (*(char **)c->var != NULL)
1181 free (*(char **)c->var);
1182 *(char **) c->var = new;
1183 }
1184 break;
1185 case var_string_noescape:
1186 if (arg == NULL)
1187 arg = "";
1188 if (*(char **)c->var != NULL)
1189 free (*(char **)c->var);
1190 *(char **) c->var = savestring (arg, strlen (arg));
1191 break;
1192 case var_filename:
1193 if (arg == NULL)
1194 error_no_arg ("filename to set it to.");
1195 if (*(char **)c->var != NULL)
1196 free (*(char **)c->var);
1197 *(char **)c->var = tilde_expand (arg);
1198 break;
1199 case var_boolean:
1200 *(int *) c->var = parse_binary_operation (arg);
1201 break;
1202 case var_uinteger:
1203 if (arg == NULL)
1204 error_no_arg ("integer to set it to.");
4966c17c
JG
1205 *(unsigned int *) c->var = parse_and_eval_address (arg);
1206 if (*(unsigned int *) c->var == 0)
1207 *(unsigned int *) c->var = UINT_MAX;
dd3b648e 1208 break;
359a097f
JK
1209 case var_integer:
1210 {
1211 unsigned int val;
1212 if (arg == NULL)
1213 error_no_arg ("integer to set it to.");
1214 val = parse_and_eval_address (arg);
1215 if (val == 0)
1216 *(int *) c->var = INT_MAX;
1217 else if (val >= INT_MAX)
1218 error ("integer %u out of range", val);
1219 else
1220 *(int *) c->var = val;
1221 break;
1222 }
dd3b648e
RP
1223 case var_zinteger:
1224 if (arg == NULL)
1225 error_no_arg ("integer to set it to.");
1226 *(int *) c->var = parse_and_eval_address (arg);
1227 break;
236274b9
SG
1228 case var_enum:
1229 {
1230 int i;
1231 int len;
1232 int nmatches;
1233 char *match;
1234 char *p;
1235
1236 p = strchr (arg, ' ');
1237
1238 if (p)
1239 len = p - arg;
1240 else
1241 len = strlen (arg);
1242
1243 nmatches = 0;
1244 for (i = 0; c->enums[i]; i++)
1245 if (strncmp (arg, c->enums[i], len) == 0)
1246 {
1247 match = c->enums[i];
1248 nmatches++;
1249 }
1250
1251 if (nmatches <= 0)
1252 error ("Undefined item: \"%s\".", arg);
1253
1254 if (nmatches > 1)
1255 error ("Ambiguous item \"%s\".", arg);
1256
1257 *(char **)c->var = match;
1258 }
1259 break;
dd3b648e
RP
1260 default:
1261 error ("gdb internal error: bad var_type in do_setshow_command");
1262 }
1263 }
1264 else if (c->type == show_cmd)
1265 {
1266 /* Print doc minus "show" at start. */
199b2450 1267 print_doc_line (gdb_stdout, c->doc + 5);
dd3b648e 1268
199b2450 1269 fputs_filtered (" is ", gdb_stdout);
dd3b648e
RP
1270 wrap_here (" ");
1271 switch (c->var_type)
1272 {
1273 case var_string:
1274 {
1275 unsigned char *p;
199b2450 1276 fputs_filtered ("\"", gdb_stdout);
dd3b648e 1277 for (p = *(unsigned char **) c->var; *p != '\0'; p++)
199b2450
TL
1278 gdb_printchar (*p, gdb_stdout, '"');
1279 fputs_filtered ("\"", gdb_stdout);
dd3b648e
RP
1280 }
1281 break;
1282 case var_string_noescape:
1283 case var_filename:
236274b9 1284 case var_enum:
199b2450
TL
1285 fputs_filtered ("\"", gdb_stdout);
1286 fputs_filtered (*(char **) c->var, gdb_stdout);
1287 fputs_filtered ("\"", gdb_stdout);
dd3b648e
RP
1288 break;
1289 case var_boolean:
199b2450 1290 fputs_filtered (*(int *) c->var ? "on" : "off", gdb_stdout);
dd3b648e
RP
1291 break;
1292 case var_uinteger:
1293 if (*(unsigned int *) c->var == UINT_MAX) {
199b2450 1294 fputs_filtered ("unlimited", gdb_stdout);
dd3b648e
RP
1295 break;
1296 }
1297 /* else fall through */
1298 case var_zinteger:
199b2450 1299 fprintf_filtered (gdb_stdout, "%u", *(unsigned int *) c->var);
dd3b648e 1300 break;
359a097f
JK
1301 case var_integer:
1302 if (*(int *) c->var == INT_MAX)
1303 {
199b2450 1304 fputs_filtered ("unlimited", gdb_stdout);
359a097f
JK
1305 }
1306 else
199b2450 1307 fprintf_filtered (gdb_stdout, "%d", *(int *) c->var);
359a097f
JK
1308 break;
1309
dd3b648e
RP
1310 default:
1311 error ("gdb internal error: bad var_type in do_setshow_command");
1312 }
199b2450 1313 fputs_filtered (".\n", gdb_stdout);
dd3b648e
RP
1314 }
1315 else
1316 error ("gdb internal error: bad cmd_type in do_setshow_command");
1ab3bf1b 1317 (*c->function.sfunc) (NULL, from_tty, c);
dd3b648e
RP
1318}
1319
1320/* Show all the settings in a list of show commands. */
1321
1322void
1323cmd_show_list (list, from_tty, prefix)
1324 struct cmd_list_element *list;
1325 int from_tty;
1326 char *prefix;
1327{
1328 for (; list != NULL; list = list->next) {
1329 /* If we find a prefix, run its list, prefixing our output by its
1330 prefix (with "show " skipped). */
1331 if (list->prefixlist && !list->abbrev_flag)
1332 cmd_show_list (*list->prefixlist, from_tty, list->prefixname + 5);
1333 if (list->type == show_cmd)
1334 {
199b2450
TL
1335 fputs_filtered (prefix, gdb_stdout);
1336 fputs_filtered (list->name, gdb_stdout);
1337 fputs_filtered (": ", gdb_stdout);
dd3b648e
RP
1338 do_setshow_command ((char *)NULL, from_tty, list);
1339 }
1340 }
1341}
1342
e1ce8aa5 1343/* ARGSUSED */
dd3b648e
RP
1344static void
1345shell_escape (arg, from_tty)
1346 char *arg;
1347 int from_tty;
1348{
87237c52
JK
1349#ifdef CANT_FORK
1350 /* FIXME: what about errors (I don't know how GO32 system() handles
1351 them)? */
1352 system (arg);
1353#else /* Can fork. */
dd3b648e
RP
1354 int rc, status, pid;
1355 char *p, *user_shell;
dd3b648e
RP
1356
1357 if ((user_shell = (char *) getenv ("SHELL")) == NULL)
1358 user_shell = "/bin/sh";
1359
1360 /* Get the name of the shell for arg0 */
1ab3bf1b 1361 if ((p = strrchr (user_shell, '/')) == NULL)
dd3b648e
RP
1362 p = user_shell;
1363 else
1364 p++; /* Get past '/' */
1365
1366 if ((pid = fork()) == 0)
1367 {
1368 if (!arg)
1369 execl (user_shell, p, 0);
1370 else
1371 execl (user_shell, p, "-c", arg, 0);
1372
5b3591ab
JK
1373 fprintf_unfiltered (gdb_stderr, "Cannot execute %s: %s\n", user_shell,
1374 safe_strerror (errno));
1375 gdb_flush (gdb_stderr);
1376 _exit (0177);
dd3b648e
RP
1377 }
1378
1379 if (pid != -1)
1380 while ((rc = wait (&status)) != pid && rc != -1)
1381 ;
1382 else
1383 error ("Fork failed");
87237c52 1384#endif /* Can fork. */
dd3b648e
RP
1385}
1386
1387static void
1388make_command (arg, from_tty)
1389 char *arg;
1390 int from_tty;
1391{
1392 char *p;
1393
1394 if (arg == 0)
1395 p = "make";
1396 else
1397 {
1398 p = xmalloc (sizeof("make ") + strlen(arg));
1399 strcpy (p, "make ");
1400 strcpy (p + sizeof("make ")-1, arg);
1401 }
1402
1403 shell_escape (p, from_tty);
1404}
1405
3f2e006b 1406static void
4369a140 1407show_user_1 (c, stream)
3f2e006b 1408 struct cmd_list_element *c;
199b2450 1409 GDB_FILE *stream;
3f2e006b
JG
1410{
1411 register struct command_line *cmdlines;
1412
1413 cmdlines = c->user_commands;
1414 if (!cmdlines)
1415 return;
3021c40d
JG
1416 fputs_filtered ("User command ", stream);
1417 fputs_filtered (c->name, stream);
1418 fputs_filtered (":\n", stream);
59528079 1419
3f2e006b
JG
1420 while (cmdlines)
1421 {
59528079 1422 print_command_line (cmdlines, 4);
3f2e006b
JG
1423 cmdlines = cmdlines->next;
1424 }
1425 fputs_filtered ("\n", stream);
1426}
1427
1428/* ARGSUSED */
1429static void
4369a140 1430show_user (args, from_tty)
3f2e006b
JG
1431 char *args;
1432 int from_tty;
1433{
1434 struct cmd_list_element *c;
1435 extern struct cmd_list_element *cmdlist;
1436
1437 if (args)
1438 {
1439 c = lookup_cmd (&args, cmdlist, "", 0, 1);
1440 if (c->class != class_user)
1441 error ("Not a user command.");
199b2450 1442 show_user_1 (c, gdb_stdout);
3f2e006b
JG
1443 }
1444 else
1445 {
1446 for (c = cmdlist; c; c = c->next)
1447 {
1448 if (c->class == class_user)
199b2450 1449 show_user_1 (c, gdb_stdout);
3f2e006b
JG
1450 }
1451 }
1452}
1453
dd3b648e
RP
1454void
1455_initialize_command ()
1456{
1457 add_com ("shell", class_support, shell_escape,
1458 "Execute the rest of the line as a shell command. \n\
1459With no arguments, run an inferior shell.");
dd3b648e
RP
1460 add_com ("make", class_support, make_command,
1461 "Run the ``make'' program using the rest of the line as arguments.");
4369a140
JG
1462 add_cmd ("user", no_class, show_user,
1463 "Show definitions of user defined commands.\n\
3f2e006b 1464Argument is the name of the user defined command.\n\
4369a140 1465With no argument, show definitions of all user defined commands.", &showlist);
dd3b648e 1466}
This page took 0.425511 seconds and 4 git commands to generate.