* cli/cli-cmds.c (compare_strings): New function.
[external/binutils.git] / gdb / cli / cli-cmds.c
1 /* GDB CLI commands.
2
3    Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
4
5    This file is part of GDB.
6
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.
11
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.
16
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., 59 Temple Place - Suite 330,
20    Boston, MA 02111-1307, USA.  */
21
22 #include "defs.h"
23 #include "completer.h"
24 #include "target.h"      /* For baud_rate, remote_debug and remote_timeout */
25 #include "gdb_wait.h"           /* For shell escape implementation */
26 #include "gdb_regex.h"          /* Used by apropos_command */
27 #include "filenames.h"          /* for DOSish file names */
28
29 #include "ui-out.h"
30
31 #include "top.h"
32 #include "cli/cli-decode.h"
33 #include "cli/cli-script.h"
34 #include "cli/cli-setshow.h"
35 #include "cli/cli-cmds.h"
36
37 #ifndef GDBINIT_FILENAME
38 #define GDBINIT_FILENAME        ".gdbinit"
39 #endif
40
41 /* From gdb/top.c */
42
43 extern void dont_repeat (void);
44
45 extern void set_verbose (char *, int, struct cmd_list_element *);
46
47 extern void show_history (char *, int);
48
49 extern void set_history (char *, int);
50
51 extern void show_commands (char *, int);
52
53 /* Prototypes for local functions */
54
55 static void complete_command (char *, int);
56
57 static void echo_command (char *, int);
58
59 static void pwd_command (char *, int);
60
61 static void show_version (char *, int);
62
63 static void validate_comname (char *);
64
65 static void help_command (char *, int);
66
67 static void show_command (char *, int);
68
69 static void info_command (char *, int);
70
71 static void show_debug (char *, int);
72
73 static void set_debug (char *, int);
74
75 static void show_user (char *, int);
76
77 static void make_command (char *, int);
78
79 static void shell_escape (char *, int);
80
81 void apropos_command (char *, int);
82 \f
83 /* Define all cmd_list_elements.  */
84
85 /* Chain containing all defined commands.  */
86
87 struct cmd_list_element *cmdlist;
88
89 /* Chain containing all defined info subcommands.  */
90
91 struct cmd_list_element *infolist;
92
93 /* Chain containing all defined enable subcommands. */
94
95 struct cmd_list_element *enablelist;
96
97 /* Chain containing all defined disable subcommands. */
98
99 struct cmd_list_element *disablelist;
100
101 /* Chain containing all defined toggle subcommands. */
102
103 struct cmd_list_element *togglelist;
104
105 /* Chain containing all defined stop subcommands. */
106
107 struct cmd_list_element *stoplist;
108
109 /* Chain containing all defined delete subcommands. */
110
111 struct cmd_list_element *deletelist;
112
113 /* Chain containing all defined "enable breakpoint" subcommands. */
114
115 struct cmd_list_element *enablebreaklist;
116
117 /* Chain containing all defined set subcommands */
118
119 struct cmd_list_element *setlist;
120
121 /* Chain containing all defined unset subcommands */
122
123 struct cmd_list_element *unsetlist;
124
125 /* Chain containing all defined show subcommands.  */
126
127 struct cmd_list_element *showlist;
128
129 /* Chain containing all defined \"set history\".  */
130
131 struct cmd_list_element *sethistlist;
132
133 /* Chain containing all defined \"show history\".  */
134
135 struct cmd_list_element *showhistlist;
136
137 /* Chain containing all defined \"unset history\".  */
138
139 struct cmd_list_element *unsethistlist;
140
141 /* Chain containing all defined maintenance subcommands. */
142
143 struct cmd_list_element *maintenancelist;
144
145 /* Chain containing all defined "maintenance info" subcommands. */
146
147 struct cmd_list_element *maintenanceinfolist;
148
149 /* Chain containing all defined "maintenance print" subcommands. */
150
151 struct cmd_list_element *maintenanceprintlist;
152
153 struct cmd_list_element *setprintlist;
154
155 struct cmd_list_element *showprintlist;
156
157 struct cmd_list_element *setdebuglist;
158
159 struct cmd_list_element *showdebuglist;
160
161 struct cmd_list_element *setchecklist;
162
163 struct cmd_list_element *showchecklist;
164 \f
165 /* Utility used everywhere when at least one argument is needed and
166    none is supplied. */
167
168 void
169 error_no_arg (char *why)
170 {
171   error ("Argument required (%s).", why);
172 }
173
174 /* The "info" command is defined as a prefix, with allow_unknown = 0.
175    Therefore, its own definition is called only for "info" with no args.  */
176
177 /* ARGSUSED */
178 static void
179 info_command (char *arg, int from_tty)
180 {
181   printf_unfiltered ("\"info\" must be followed by the name of an info command.\n");
182   help_list (infolist, "info ", -1, gdb_stdout);
183 }
184
185 /* The "show" command with no arguments shows all the settings.  */
186
187 /* ARGSUSED */
188 static void
189 show_command (char *arg, int from_tty)
190 {
191   cmd_show_list (showlist, from_tty, "");
192 }
193 \f
194 /* Provide documentation on command or list given by COMMAND.  FROM_TTY
195    is ignored.  */
196
197 /* ARGSUSED */
198 static void
199 help_command (char *command, int from_tty)
200 {
201   help_cmd (command, gdb_stdout);
202 }
203 \f
204 /* String compare function for qsort.  */
205 static int
206 compare_strings (const void *arg1, const void *arg2)
207 {
208   const char **s1 = (const char **) arg1;
209   const char **s2 = (const char **) arg2;
210   return strcmp (*s1, *s2);
211 }
212
213 /* The "complete" command is used by Emacs to implement completion.  */
214
215 /* ARGSUSED */
216 static void
217 complete_command (char *arg, int from_tty)
218 {
219   int i;
220   int argpoint;
221   char **completions;
222
223   dont_repeat ();
224
225   if (arg == NULL)
226     arg = "";
227   argpoint = strlen (arg);
228
229   completions = complete_line (arg, arg, argpoint);
230
231   if (completions)
232     {
233       int item, size;
234
235       for (size = 0; completions[size]; ++size)
236         ;
237       qsort (completions, size, sizeof (char *), compare_strings);
238
239       /* We do extra processing here since we only want to print each
240          unique item once.  */
241       item = 0;
242       while (item < size)
243         {
244           int next_item;
245           printf_unfiltered ("%s\n", completions[item]);
246           next_item = item + 1;
247           while (next_item < size
248                  && ! strcmp (completions[item], completions[next_item]))
249             {
250               xfree (completions[next_item]);
251               ++next_item;
252             }
253
254           xfree (completions[item]);
255           item = next_item;
256         }
257
258       xfree (completions);
259     }
260 }
261
262 int is_complete_command (void (*func) (char *args, int from_tty))
263 {
264   return func == complete_command;
265 }
266
267 /* ARGSUSED */
268 static void
269 show_version (char *args, int from_tty)
270 {
271   immediate_quit++;
272   print_gdb_version (gdb_stdout);
273   printf_filtered ("\n");
274   immediate_quit--;
275 }
276
277 /* Handle the quit command.  */
278
279 void
280 quit_command (char *args, int from_tty)
281 {
282   if (!quit_confirm ())
283     error ("Not confirmed.");
284   quit_force (args, from_tty);
285 }
286
287 /* ARGSUSED */
288 static void
289 pwd_command (char *args, int from_tty)
290 {
291   if (args)
292     error ("The \"pwd\" command does not take an argument: %s", args);
293   getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
294
295   if (!STREQ (gdb_dirbuf, current_directory))
296     printf_unfiltered ("Working directory %s\n (canonically %s).\n",
297                        current_directory, gdb_dirbuf);
298   else
299     printf_unfiltered ("Working directory %s.\n", current_directory);
300 }
301
302 void
303 cd_command (char *dir, int from_tty)
304 {
305   int len;
306   /* Found something other than leading repetitions of "/..".  */
307   int found_real_path;
308   char *p;
309
310   /* If the new directory is absolute, repeat is a no-op; if relative,
311      repeat might be useful but is more likely to be a mistake.  */
312   dont_repeat ();
313
314   if (dir == 0)
315     error_no_arg ("new working directory");
316
317   dir = tilde_expand (dir);
318   make_cleanup (xfree, dir);
319
320   if (chdir (dir) < 0)
321     perror_with_name (dir);
322
323 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
324   /* There's too much mess with DOSish names like "d:", "d:.",
325      "d:./foo" etc.  Instead of having lots of special #ifdef'ed code,
326      simply get the canonicalized name of the current directory.  */
327   dir = getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
328 #endif
329
330   len = strlen (dir);
331   if (IS_DIR_SEPARATOR (dir[len - 1]))
332     {
333       /* Remove the trailing slash unless this is a root directory
334          (including a drive letter on non-Unix systems).  */
335       if (!(len == 1)           /* "/" */
336 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
337           && !(len == 3 && dir[1] == ':') /* "d:/" */
338 #endif
339           )
340         len--;
341     }
342
343   dir = savestring (dir, len);
344   if (IS_ABSOLUTE_PATH (dir))
345     current_directory = dir;
346   else
347     {
348       if (IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1]))
349         current_directory = concat (current_directory, dir, NULL);
350       else
351         current_directory = concat (current_directory, SLASH_STRING, dir, NULL);
352       xfree (dir);
353     }
354
355   /* Now simplify any occurrences of `.' and `..' in the pathname.  */
356
357   found_real_path = 0;
358   for (p = current_directory; *p;)
359     {
360       if (IS_DIR_SEPARATOR (p[0]) && p[1] == '.'
361           && (p[2] == 0 || IS_DIR_SEPARATOR (p[2])))
362         strcpy (p, p + 2);
363       else if (IS_DIR_SEPARATOR (p[0]) && p[1] == '.' && p[2] == '.'
364                && (p[3] == 0 || IS_DIR_SEPARATOR (p[3])))
365         {
366           if (found_real_path)
367             {
368               /* Search backwards for the directory just before the "/.."
369                  and obliterate it and the "/..".  */
370               char *q = p;
371               while (q != current_directory && !IS_DIR_SEPARATOR (q[-1]))
372                 --q;
373
374               if (q == current_directory)
375                 /* current_directory is
376                    a relative pathname ("can't happen"--leave it alone).  */
377                 ++p;
378               else
379                 {
380                   strcpy (q - 1, p + 3);
381                   p = q - 1;
382                 }
383             }
384           else
385             /* We are dealing with leading repetitions of "/..", for example
386                "/../..", which is the Mach super-root.  */
387             p += 3;
388         }
389       else
390         {
391           found_real_path = 1;
392           ++p;
393         }
394     }
395
396   forget_cached_source_info ();
397
398   if (from_tty)
399     pwd_command ((char *) 0, 1);
400 }
401 \f
402 void
403 source_command (char *args, int from_tty)
404 {
405   FILE *stream;
406   struct cleanup *old_cleanups;
407   char *file = args;
408
409   if (file == NULL)
410     {
411       error ("source command requires pathname of file to source.");
412     }
413
414   file = tilde_expand (file);
415   old_cleanups = make_cleanup (xfree, file);
416
417   stream = fopen (file, FOPEN_RT);
418   if (!stream)
419     {
420       if (from_tty)
421         perror_with_name (file);
422       else
423         return;
424     }
425
426   script_from_file (stream, file);
427
428   do_cleanups (old_cleanups);
429 }
430
431 /* ARGSUSED */
432 static void
433 echo_command (char *text, int from_tty)
434 {
435   char *p = text;
436   register int c;
437
438   if (text)
439     while ((c = *p++) != '\0')
440       {
441         if (c == '\\')
442           {
443             /* \ at end of argument is used after spaces
444                so they won't be lost.  */
445             if (*p == 0)
446               return;
447
448             c = parse_escape (&p);
449             if (c >= 0)
450               printf_filtered ("%c", c);
451           }
452         else
453           printf_filtered ("%c", c);
454       }
455
456   /* Force this output to appear now.  */
457   wrap_here ("");
458   gdb_flush (gdb_stdout);
459 }
460
461 /* ARGSUSED */
462 static void
463 shell_escape (char *arg, int from_tty)
464 {
465 #ifdef CANT_FORK
466   /* If ARG is NULL, they want an inferior shell, but `system' just
467      reports if the shell is available when passed a NULL arg.  */
468   int rc = system (arg ? arg : "");
469
470   if (!arg)
471     arg = "inferior shell";
472
473   if (rc == -1)
474     {
475       fprintf_unfiltered (gdb_stderr, "Cannot execute %s: %s\n", arg,
476                           safe_strerror (errno));
477       gdb_flush (gdb_stderr);
478     }
479   else if (rc)
480     {
481       fprintf_unfiltered (gdb_stderr, "%s exited with status %d\n", arg, rc);
482       gdb_flush (gdb_stderr);
483     }
484 #ifdef GLOBAL_CURDIR
485   /* Make sure to return to the directory GDB thinks it is, in case the
486      shell command we just ran changed it.  */
487   chdir (current_directory);
488 #endif
489 #else /* Can fork.  */
490   int rc, status, pid;
491   char *p, *user_shell;
492
493   if ((user_shell = (char *) getenv ("SHELL")) == NULL)
494     user_shell = "/bin/sh";
495
496   /* Get the name of the shell for arg0 */
497   if ((p = strrchr (user_shell, '/')) == NULL)
498     p = user_shell;
499   else
500     p++;                        /* Get past '/' */
501
502   if ((pid = fork ()) == 0)
503     {
504       if (!arg)
505         execl (user_shell, p, 0);
506       else
507         execl (user_shell, p, "-c", arg, 0);
508
509       fprintf_unfiltered (gdb_stderr, "Cannot execute %s: %s\n", user_shell,
510                           safe_strerror (errno));
511       gdb_flush (gdb_stderr);
512       _exit (0177);
513     }
514
515   if (pid != -1)
516     while ((rc = wait (&status)) != pid && rc != -1)
517       ;
518   else
519     error ("Fork failed");
520 #endif /* Can fork.  */
521 }
522
523 static void
524 make_command (char *arg, int from_tty)
525 {
526   char *p;
527
528   if (arg == 0)
529     p = "make";
530   else
531     {
532       p = xmalloc (sizeof ("make ") + strlen (arg));
533       strcpy (p, "make ");
534       strcpy (p + sizeof ("make ") - 1, arg);
535     }
536
537   shell_escape (p, from_tty);
538 }
539
540 /* ARGSUSED */
541 static void
542 show_user (char *args, int from_tty)
543 {
544   struct cmd_list_element *c;
545   extern struct cmd_list_element *cmdlist;
546
547   if (args)
548     {
549       c = lookup_cmd (&args, cmdlist, "", 0, 1);
550       if (c->class != class_user)
551         error ("Not a user command.");
552       show_user_1 (c, gdb_stdout);
553     }
554   else
555     {
556       for (c = cmdlist; c; c = c->next)
557         {
558           if (c->class == class_user)
559             show_user_1 (c, gdb_stdout);
560         }
561     }
562 }
563
564 /* Search through names of commands and documentations for a certain
565    regular expression.
566 */
567 void 
568 apropos_command (char *searchstr, int from_tty)
569 {
570   extern struct cmd_list_element *cmdlist; /*This is the main command list*/
571   regex_t pattern;
572   char *pattern_fastmap;
573   char errorbuffer[512];
574   pattern_fastmap = xcalloc (256, sizeof (char));
575   if (searchstr == NULL)
576       error("REGEXP string is empty");
577
578   if (regcomp(&pattern,searchstr,REG_ICASE) == 0)
579     {
580       pattern.fastmap=pattern_fastmap;
581       re_compile_fastmap(&pattern);
582       apropos_cmd (gdb_stdout,cmdlist,&pattern,"");
583     }
584   else
585     {
586       regerror(regcomp(&pattern,searchstr,REG_ICASE),NULL,errorbuffer,512);
587       error("Error in regular expression:%s",errorbuffer);
588     }
589   xfree (pattern_fastmap);
590 }
591 \f
592 static void
593 set_debug (char *arg, int from_tty)
594 {
595   printf_unfiltered ("\"set debug\" must be followed by the name of a print subcommand.\n");
596   help_list (setdebuglist, "set debug ", -1, gdb_stdout);
597 }
598
599 static void
600 show_debug (char *args, int from_tty)
601 {
602   cmd_show_list (showdebuglist, from_tty, "");
603 }
604
605 void
606 init_cmd_lists (void)
607 {
608   cmdlist = NULL;
609   infolist = NULL;
610   enablelist = NULL;
611   disablelist = NULL;
612   togglelist = NULL;
613   stoplist = NULL;
614   deletelist = NULL;
615   enablebreaklist = NULL;
616   setlist = NULL;
617   unsetlist = NULL;
618   showlist = NULL;
619   sethistlist = NULL;
620   showhistlist = NULL;
621   unsethistlist = NULL;
622   maintenancelist = NULL;
623   maintenanceinfolist = NULL;
624   maintenanceprintlist = NULL;
625   setprintlist = NULL;
626   showprintlist = NULL;
627   setchecklist = NULL;
628   showchecklist = NULL;
629 }
630
631 \f
632 void
633 init_cli_cmds (void)
634 {
635   struct cmd_list_element *c;
636
637   /* Define the classes of commands.
638      They will appear in the help list in the reverse of this order.  */
639
640   add_cmd ("internals", class_maintenance, NULL,
641            "Maintenance commands.\n\
642 Some gdb commands are provided just for use by gdb maintainers.\n\
643 These commands are subject to frequent change, and may not be as\n\
644 well documented as user commands.",
645            &cmdlist);
646   add_cmd ("obscure", class_obscure, NULL, "Obscure features.", &cmdlist);
647   add_cmd ("aliases", class_alias, NULL, "Aliases of other commands.", &cmdlist);
648   add_cmd ("user-defined", class_user, NULL, "User-defined commands.\n\
649 The commands in this class are those defined by the user.\n\
650 Use the \"define\" command to define a command.", &cmdlist);
651   add_cmd ("support", class_support, NULL, "Support facilities.", &cmdlist);
652   if (!dbx_commands)
653     add_cmd ("status", class_info, NULL, "Status inquiries.", &cmdlist);
654   add_cmd ("files", class_files, NULL, "Specifying and examining files.", &cmdlist);
655   add_cmd ("breakpoints", class_breakpoint, NULL, "Making program stop at certain points.", &cmdlist);
656   add_cmd ("data", class_vars, NULL, "Examining data.", &cmdlist);
657   add_cmd ("stack", class_stack, NULL, "Examining the stack.\n\
658 The stack is made up of stack frames.  Gdb assigns numbers to stack frames\n\
659 counting from zero for the innermost (currently executing) frame.\n\n\
660 At any time gdb identifies one frame as the \"selected\" frame.\n\
661 Variable lookups are done with respect to the selected frame.\n\
662 When the program being debugged stops, gdb selects the innermost frame.\n\
663 The commands below can be used to select other frames by number or address.",
664            &cmdlist);
665   add_cmd ("running", class_run, NULL, "Running the program.", &cmdlist);
666
667   /* Define general commands. */
668
669   add_com ("pwd", class_files, pwd_command,
670         "Print working directory.  This is used for your program as well.");
671   c = add_cmd ("cd", class_files, cd_command,
672                "Set working directory to DIR for debugger and program being debugged.\n\
673 The change does not take effect for the program being debugged\n\
674 until the next time it is started.", &cmdlist);
675   c->completer = filename_completer;
676
677   add_com ("echo", class_support, echo_command,
678            "Print a constant string.  Give string as argument.\n\
679 C escape sequences may be used in the argument.\n\
680 No newline is added at the end of the argument;\n\
681 use \"\\n\" if you want a newline to be printed.\n\
682 Since leading and trailing whitespace are ignored in command arguments,\n\
683 if you want to print some you must use \"\\\" before leading whitespace\n\
684 to be printed or after trailing whitespace.");
685   add_com ("document", class_support, document_command,
686            "Document a user-defined command.\n\
687 Give command name as argument.  Give documentation on following lines.\n\
688 End with a line of just \"end\".");
689   add_com ("define", class_support, define_command,
690            "Define a new command name.  Command name is argument.\n\
691 Definition appears on following lines, one command per line.\n\
692 End with a line of just \"end\".\n\
693 Use the \"document\" command to give documentation for the new command.\n\
694 Commands defined in this way may have up to ten arguments.");
695
696   c = add_cmd ("source", class_support, source_command,
697                "Read commands from a file named FILE.\n\
698 Note that the file \"" GDBINIT_FILENAME "\" is read automatically in this way\n\
699 when gdb is started.", &cmdlist);
700   c->completer = filename_completer;
701
702   add_com ("quit", class_support, quit_command, "Exit gdb.");
703   c = add_com ("help", class_support, help_command, "Print list of commands.");
704   c->completer = command_completer;
705   add_com_alias ("q", "quit", class_support, 1);
706   add_com_alias ("h", "help", class_support, 1);
707
708   c = add_set_cmd ("verbose", class_support, var_boolean, (char *) &info_verbose,
709                    "Set ",
710                    &setlist),
711     add_show_from_set (c, &showlist);
712   set_cmd_sfunc (c, set_verbose);
713   set_verbose (NULL, 0, c);
714
715   add_prefix_cmd ("history", class_support, set_history,
716                   "Generic command for setting command history parameters.",
717                   &sethistlist, "set history ", 0, &setlist);
718   add_prefix_cmd ("history", class_support, show_history,
719                   "Generic command for showing command history parameters.",
720                   &showhistlist, "show history ", 0, &showlist);
721
722   add_show_from_set
723     (add_set_cmd ("expansion", no_class, var_boolean, (char *) &history_expansion_p,
724                   "Set history expansion on command input.\n\
725 Without an argument, history expansion is enabled.", &sethistlist),
726      &showhistlist);
727
728   add_prefix_cmd ("info", class_info, info_command,
729      "Generic command for showing things about the program being debugged.",
730                   &infolist, "info ", 0, &cmdlist);
731   add_com_alias ("i", "info", class_info, 1);
732
733   add_com ("complete", class_obscure, complete_command,
734            "List the completions for the rest of the line as a command.");
735
736   add_prefix_cmd ("show", class_info, show_command,
737                   "Generic command for showing things about the debugger.",
738                   &showlist, "show ", 0, &cmdlist);
739   /* Another way to get at the same thing.  */
740   add_info ("set", show_command, "Show all GDB settings.");
741
742   add_cmd ("commands", no_class, show_commands,
743            "Show the history of commands you typed.\n\
744 You can supply a command number to start with, or a `+' to start after\n\
745 the previous command number shown.",
746            &showlist);
747
748   add_cmd ("version", no_class, show_version,
749            "Show what version of GDB this is.", &showlist);
750
751   add_com ("while", class_support, while_command,
752            "Execute nested commands WHILE the conditional expression is non zero.\n\
753 The conditional expression must follow the word `while' and must in turn be\n\
754 followed by a new line.  The nested commands must be entered one per line,\n\
755 and should be terminated by the word `end'.");
756
757   add_com ("if", class_support, if_command,
758            "Execute nested commands once IF the conditional expression is non zero.\n\
759 The conditional expression must follow the word `if' and must in turn be\n\
760 followed by a new line.  The nested commands must be entered one per line,\n\
761 and should be terminated by the word 'else' or `end'.  If an else clause\n\
762 is used, the same rules apply to its nested commands as to the first ones.");
763
764   /* If target is open when baud changes, it doesn't take effect until the
765      next open (I think, not sure).  */
766   add_show_from_set (add_set_cmd ("remotebaud", no_class,
767                                   var_zinteger, (char *) &baud_rate,
768                                   "Set baud rate for remote serial I/O.\n\
769 This value is used to set the speed of the serial port when debugging\n\
770 using remote targets.", &setlist),
771                      &showlist);
772
773   c = add_set_cmd ("remotedebug", no_class, var_zinteger,
774                    (char *) &remote_debug,
775                    "Set debugging of remote protocol.\n\
776 When enabled, each packet sent or received with the remote target\n\
777 is displayed.", &setlist);
778   deprecate_cmd (c, "set debug remote");
779   deprecate_cmd (add_show_from_set (c, &showlist), "show debug remote");
780
781   add_show_from_set (add_set_cmd ("remote", no_class, var_zinteger,
782                                   (char *) &remote_debug,
783                                   "Set debugging of remote protocol.\n\
784 When enabled, each packet sent or received with the remote target\n\
785 is displayed.", &setdebuglist),
786                      &showdebuglist);
787
788   add_show_from_set (
789                       add_set_cmd ("remotetimeout", no_class, var_integer, (char *) &remote_timeout,
790                                    "Set timeout limit to wait for target to respond.\n\
791 This value is used to set the time limit for gdb to wait for a response\n\
792 from the target.", &setlist),
793                       &showlist);
794
795   add_prefix_cmd ("debug", no_class, set_debug,
796                   "Generic command for setting gdb debugging flags",
797                   &setdebuglist, "set debug ", 0, &setlist);
798
799   add_prefix_cmd ("debug", no_class, show_debug,
800                   "Generic command for showing gdb debugging flags",
801                   &showdebuglist, "show debug ", 0, &showlist);
802
803   c = add_com ("shell", class_support, shell_escape,
804                "Execute the rest of the line as a shell command.  \n\
805 With no arguments, run an inferior shell.");
806   c->completer = filename_completer;
807
808   /* NOTE: cagney/2000-03-20: Being able to enter ``(gdb) !ls'' would
809      be a really useful feature.  Unfortunately, the below wont do
810      this.  Instead it adds support for the form ``(gdb) ! ls''
811      (i.e. the space is required).  If the ``!'' command below is
812      added the complains about no ``!'' command would be replaced by
813      complains about how the ``!'' command is broken :-) */
814   if (xdb_commands)
815     add_com_alias ("!", "shell", class_support, 0);
816
817   c = add_com ("make", class_support, make_command,
818           "Run the ``make'' program using the rest of the line as arguments.");
819   c->completer = filename_completer;
820   add_cmd ("user", no_class, show_user,
821            "Show definitions of user defined commands.\n\
822 Argument is the name of the user defined command.\n\
823 With no argument, show definitions of all user defined commands.", &showlist);
824   add_com ("apropos", class_support, apropos_command, "Search for commands matching a REGEXP");
825 }