1 /* Top level `main' program for GDB, the GNU debugger.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994
3 Free Software Foundation, Inc.
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. */
23 #include "call-cmds.h"
28 #include "breakpoint.h"
30 #include "expression.h"
32 #include "terminal.h" /* For job_control. */
36 /* readline include files */
40 /* readline defines this. */
43 #include <sys/types.h>
45 /* What is this for? X_OK? */
54 #include <sys/param.h>
58 #ifdef SET_STACK_LIMIT_HUGE
60 #include <sys/resource.h>
62 int original_stack_limit
;
65 /* Prototypes for local functions */
68 symbol_completion_function
PARAMS ((char *, int));
71 command_loop
PARAMS ((void));
74 command_loop_marker
PARAMS ((int));
77 print_gdb_version
PARAMS ((GDB_FILE
*));
80 quit_command
PARAMS ((char *, int));
83 init_main
PARAMS ((void));
86 init_history
PARAMS ((void));
89 init_cmd_lists
PARAMS ((void));
92 float_handler
PARAMS ((int));
95 source_command
PARAMS ((char *, int));
97 static void cd_command
PARAMS ((char *, int));
100 print_gnu_advertisement
PARAMS ((void));
103 init_signals
PARAMS ((void));
106 read_command_file
PARAMS ((FILE *));
109 set_verbose
PARAMS ((char *, int, struct cmd_list_element
*));
112 show_history
PARAMS ((char *, int));
115 set_history
PARAMS ((char *, int));
118 set_history_size_command
PARAMS ((char *, int, struct cmd_list_element
*));
121 show_commands
PARAMS ((char *, int));
124 echo_command
PARAMS ((char *, int));
127 pwd_command
PARAMS ((char *, int));
130 show_version
PARAMS ((char *, int));
133 document_command
PARAMS ((char *, int));
136 define_command
PARAMS ((char *, int));
139 validate_comname
PARAMS ((char *));
142 help_command
PARAMS ((char *, int));
145 show_command
PARAMS ((char *, int));
148 info_command
PARAMS ((char *, int));
151 complete_command
PARAMS ((char *, int));
154 do_nothing
PARAMS ((int));
157 quit_cover
PARAMS ((char *));
160 disconnect
PARAMS ((int));
163 source_cleanup
PARAMS ((FILE *));
165 /* If this definition isn't overridden by the header files, assume
166 that isatty and fileno exist on this system. */
168 #define ISATTY(FP) (isatty (fileno (FP)))
171 /* Initialization file name for gdb. This is overridden in some configs. */
173 #ifndef GDBINIT_FILENAME
174 #define GDBINIT_FILENAME ".gdbinit"
176 static char gdbinit
[] = GDBINIT_FILENAME
;
177 static int inhibit_gdbinit
= 0;
179 #define ALL_CLEANUPS ((struct cleanup *)0)
181 /* Version number of GDB, as a string. */
183 extern char *version
;
185 /* Canonical host name as a string. */
187 extern char *host_name
;
189 /* Canonical target name as a string. */
191 extern char *target_name
;
193 extern char lang_frame_mismatch_warn
[]; /* language.c */
195 /* Flag for whether we want all the "from_tty" gubbish printed. */
197 int caution
= 1; /* Default is yes, sigh. */
200 * Define all cmd_list_element's
203 /* Chain containing all defined commands. */
205 struct cmd_list_element
*cmdlist
;
207 /* Chain containing all defined info subcommands. */
209 struct cmd_list_element
*infolist
;
211 /* Chain containing all defined enable subcommands. */
213 struct cmd_list_element
*enablelist
;
215 /* Chain containing all defined disable subcommands. */
217 struct cmd_list_element
*disablelist
;
219 /* Chain containing all defined delete subcommands. */
221 struct cmd_list_element
*deletelist
;
223 /* Chain containing all defined "enable breakpoint" subcommands. */
225 struct cmd_list_element
*enablebreaklist
;
227 /* Chain containing all defined set subcommands */
229 struct cmd_list_element
*setlist
;
231 /* Chain containing all defined unset subcommands */
233 struct cmd_list_element
*unsetlist
;
235 /* Chain containing all defined show subcommands. */
237 struct cmd_list_element
*showlist
;
239 /* Chain containing all defined \"set history\". */
241 struct cmd_list_element
*sethistlist
;
243 /* Chain containing all defined \"show history\". */
245 struct cmd_list_element
*showhistlist
;
247 /* Chain containing all defined \"unset history\". */
249 struct cmd_list_element
*unsethistlist
;
251 /* Chain containing all defined maintenance subcommands. */
254 struct cmd_list_element
*maintenancelist
;
257 /* Chain containing all defined "maintenance info" subcommands. */
260 struct cmd_list_element
*maintenanceinfolist
;
263 /* Chain containing all defined "maintenance print" subcommands. */
266 struct cmd_list_element
*maintenanceprintlist
;
269 struct cmd_list_element
*setprintlist
;
271 struct cmd_list_element
*showprintlist
;
273 struct cmd_list_element
*setchecklist
;
275 struct cmd_list_element
*showchecklist
;
277 /* stdio stream that command input is being read from. Set to stdin normally.
278 Set by source_command to the file we are sourcing. Set to NULL if we are
279 executing a user-defined command. */
283 /* Current working directory. */
285 char *current_directory
;
287 /* The directory name is actually stored here (usually). */
288 static char dirbuf
[1024];
290 /* Function to call before reading a command, if nonzero.
291 The function receives two args: an input stream,
292 and a prompt string. */
294 void (*window_hook
) PARAMS ((FILE *, char *));
296 extern int mapped_symbol_files
;
297 extern int readnow_symbol_files
;
302 /* gdb prints this when reading a command interactively */
305 /* Buffer used for reading command lines, and the size
306 allocated for it so far. */
311 /* Nonzero if the current command is modified by "server ". This
312 affects things like recording into the command history, comamnds
313 repeating on RETURN, etc. This is so a user interface (emacs, GUI,
314 whatever) can issue its own commands and also send along commands
315 from the user, and have the user not notice that the user interface
316 is issuing commands too. */
319 /* Baud rate specified for talking to serial target systems. Default
320 is left as -1, so targets can choose their own defaults. */
321 /* FIXME: This means that "show remotebaud" and gr_files_info can print -1
322 or (unsigned int)-1. This is a Bad User Interface. */
326 /* Non-zero tells remote* modules to output debugging info. */
328 int remote_debug
= 0;
330 /* Signal to catch ^Z typed while reading a command: SIGTSTP or SIGCONT. */
334 #define STOP_SIGNAL SIGTSTP
335 static void stop_sig
PARAMS ((int));
339 /* Some System V have job control but not sigsetmask(). */
340 #if !defined (HAVE_SIGSETMASK)
342 #define HAVE_SIGSETMASK 1
344 #define HAVE_SIGSETMASK 0
348 #if 0 == (HAVE_SIGSETMASK)
349 #define sigsetmask(n)
352 /* Where to go for return_to_top_level (RETURN_ERROR). */
353 static jmp_buf error_return
;
354 /* Where to go for return_to_top_level (RETURN_QUIT). */
355 static jmp_buf quit_return
;
357 /* Temporary variable for SET_TOP_LEVEL. */
358 static int top_level_val
;
360 /* Do a setjmp on error_return and quit_return. catch_errors is
361 generally a cleaner way to do this, but main() would look pretty
362 ugly if it had to use catch_errors each time. */
364 #define SET_TOP_LEVEL() \
365 (((top_level_val = setjmp (error_return)) \
366 ? (PTR) 0 : (PTR) memcpy (quit_return, error_return, sizeof (jmp_buf))) \
369 /* Return for reason REASON. This generally gets back to the command
370 loop, but can be caught via catch_errors. */
373 return_to_top_level (reason
)
374 enum return_reason reason
;
379 /* Perhaps it would be cleaner to do this via the cleanup chain (not sure
380 I can think of a reason why that is vital, though). */
381 bpstat_clear_actions(stop_bpstat
); /* Clear queued breakpoint commands */
383 disable_current_display ();
384 do_cleanups (ALL_CLEANUPS
);
385 (NORETURN
void) longjmp
386 (reason
== RETURN_ERROR
? error_return
: quit_return
, 1);
389 /* Call FUNC with arg ARGS, catching any errors. If there is no
390 error, return the value returned by FUNC. If there is an error,
391 print ERRSTRING, print the specific error message, then return
394 Must not be called with immediate_quit in effect (bad things might
395 happen, say we got a signal in the middle of a memcpy to quit_return).
396 This is an OK restriction; with very few exceptions immediate_quit can
397 be replaced by judicious use of QUIT.
399 MASK specifies what to catch; it is normally set to
400 RETURN_MASK_ALL, if for no other reason than that the code which
401 calls catch_errors might not be set up to deal with a quit which
402 isn't caught. But if the code can deal with it, it generally
403 should be RETURN_MASK_ERROR, unless for some reason it is more
404 useful to abort only the portion of the operation inside the
405 catch_errors. Note that quit should return to the command line
406 fairly quickly, even if some further processing is being done. */
409 catch_errors (func
, args
, errstring
, mask
)
410 int (*func
) PARAMS ((char *));
419 struct cleanup
*saved_cleanup_chain
;
420 char *saved_error_pre_print
;
422 saved_cleanup_chain
= save_cleanups ();
423 saved_error_pre_print
= error_pre_print
;
425 if (mask
& RETURN_MASK_ERROR
)
426 memcpy ((char *)saved_error
, (char *)error_return
, sizeof (jmp_buf));
427 if (mask
& RETURN_MASK_QUIT
)
428 memcpy (saved_quit
, quit_return
, sizeof (jmp_buf));
429 error_pre_print
= errstring
;
431 if (setjmp (tmp_jmp
) == 0)
433 if (mask
& RETURN_MASK_ERROR
)
434 memcpy (error_return
, tmp_jmp
, sizeof (jmp_buf));
435 if (mask
& RETURN_MASK_QUIT
)
436 memcpy (quit_return
, tmp_jmp
, sizeof (jmp_buf));
437 val
= (*func
) (args
);
442 restore_cleanups (saved_cleanup_chain
);
444 error_pre_print
= saved_error_pre_print
;
445 if (mask
& RETURN_MASK_ERROR
)
446 memcpy (error_return
, saved_error
, sizeof (jmp_buf));
447 if (mask
& RETURN_MASK_QUIT
)
448 memcpy (quit_return
, saved_quit
, sizeof (jmp_buf));
452 /* Handler for SIGHUP. */
458 catch_errors (quit_cover
, NULL
,
459 "Could not kill the program being debugged", RETURN_MASK_ALL
);
460 signal (SIGHUP
, SIG_DFL
);
461 kill (getpid (), SIGHUP
);
464 /* Just a little helper function for disconnect(). */
470 caution
= 0; /* Throw caution to the wind -- we're exiting.
471 This prevents asking the user dumb questions. */
472 quit_command((char *)0, 0);
476 /* Line number we are currently in in a file which is being sourced. */
477 static int source_line_number
;
479 /* Name of the file we are sourcing. */
480 static char *source_file_name
;
482 /* Buffer containing the error_pre_print used by the source stuff.
484 static char *source_error
;
485 static int source_error_allocated
;
487 /* Something to glom on to the start of error_pre_print if source_file_name
489 static char *source_pre_error
;
491 /* Clean up on error during a "source" command (or execution of a
492 user-defined command). */
495 source_cleanup (stream
)
498 /* Restore the previous input stream. */
502 /* Read commands from STREAM. */
504 read_command_file (stream
)
507 struct cleanup
*cleanups
;
509 cleanups
= make_cleanup (source_cleanup
, instream
);
512 do_cleanups (cleanups
);
521 static int quiet
= 0;
522 static int batch
= 0;
524 /* Pointers to various arguments from command line. */
526 char *execarg
= NULL
;
527 char *corearg
= NULL
;
531 /* These are static so that we can take their address in an initializer. */
532 static int print_help
;
533 static int print_version
;
535 /* Pointers to all arguments of --command option. */
537 /* Allocated size of cmdarg. */
539 /* Number of elements of cmdarg used. */
542 /* Indices of all arguments of --directory option. */
544 /* Allocated size. */
546 /* Number of elements used. */
549 struct stat homebuf
, cwdbuf
;
550 char *homedir
, *homeinit
;
554 /* This needs to happen before the first use of malloc. */
555 init_malloc ((PTR
) NULL
);
557 #if defined (ALIGN_STACK_ON_STARTUP)
558 i
= (int) &count
& 0x3;
563 /* If error() is called from initialization code, just exit */
564 if (SET_TOP_LEVEL ()) {
569 cmdarg
= (char **) xmalloc (cmdsize
* sizeof (*cmdarg
));
572 dirarg
= (char **) xmalloc (dirsize
* sizeof (*dirarg
));
576 line
= (char *) xmalloc (linesize
);
577 line
[0] = '\0'; /* Terminate saved (now empty) cmd line */
580 getcwd (dirbuf
, sizeof (dirbuf
));
581 current_directory
= dirbuf
;
583 #ifdef SET_STACK_LIMIT_HUGE
587 /* Set the stack limit huge so that alloca (particularly stringtab
588 * in dbxread.c) does not fail. */
589 getrlimit (RLIMIT_STACK
, &rlim
);
590 original_stack_limit
= rlim
.rlim_cur
;
591 rlim
.rlim_cur
= rlim
.rlim_max
;
592 setrlimit (RLIMIT_STACK
, &rlim
);
594 #endif /* SET_STACK_LIMIT_HUGE */
596 /* Parse arguments and options. */
599 /* When var field is 0, use flag field to record the equivalent
600 short option (or arbitrary numbers starting at 10 for those
601 with no equivalent). */
602 static struct option long_options
[] =
604 {"readnow", no_argument
, &readnow_symbol_files
, 1},
605 {"r", no_argument
, &readnow_symbol_files
, 1},
606 {"mapped", no_argument
, &mapped_symbol_files
, 1},
607 {"m", no_argument
, &mapped_symbol_files
, 1},
608 {"quiet", no_argument
, &quiet
, 1},
609 {"q", no_argument
, &quiet
, 1},
610 {"silent", no_argument
, &quiet
, 1},
611 {"nx", no_argument
, &inhibit_gdbinit
, 1},
612 {"n", no_argument
, &inhibit_gdbinit
, 1},
613 {"batch", no_argument
, &batch
, 1},
614 {"epoch", no_argument
, &epoch_interface
, 1},
616 /* This is a synonym for "--annotate=1". --annotate is now preferred,
617 but keep this here for a long time because people will be running
618 emacses which use --fullname. */
619 {"fullname", no_argument
, 0, 'f'},
620 {"f", no_argument
, 0, 'f'},
622 {"annotate", required_argument
, 0, 12},
623 {"help", no_argument
, &print_help
, 1},
624 {"se", required_argument
, 0, 10},
625 {"symbols", required_argument
, 0, 's'},
626 {"s", required_argument
, 0, 's'},
627 {"exec", required_argument
, 0, 'e'},
628 {"e", required_argument
, 0, 'e'},
629 {"core", required_argument
, 0, 'c'},
630 {"c", required_argument
, 0, 'c'},
631 {"command", required_argument
, 0, 'x'},
632 {"version", no_argument
, &print_version
, 1},
633 {"x", required_argument
, 0, 'x'},
634 {"directory", required_argument
, 0, 'd'},
635 {"cd", required_argument
, 0, 11},
636 {"tty", required_argument
, 0, 't'},
637 {"baud", required_argument
, 0, 'b'},
638 {"b", required_argument
, 0, 'b'},
639 /* Allow machine descriptions to add more options... */
640 #ifdef ADDITIONAL_OPTIONS
643 {0, no_argument
, 0, 0},
650 c
= getopt_long_only (argc
, argv
, "",
651 long_options
, &option_index
);
655 /* Long option that takes an argument. */
656 if (c
== 0 && long_options
[option_index
].flag
== 0)
657 c
= long_options
[option_index
].val
;
662 /* Long option that just sets a flag. */
672 /* FIXME: what if the syntax is wrong (e.g. not digits)? */
673 annotation_level
= atoi (optarg
);
676 annotation_level
= 1;
688 cmdarg
[ncmd
++] = optarg
;
692 cmdarg
= (char **) xrealloc ((char *)cmdarg
,
693 cmdsize
* sizeof (*cmdarg
));
697 dirarg
[ndir
++] = optarg
;
701 dirarg
= (char **) xrealloc ((char *)dirarg
,
702 dirsize
* sizeof (*dirarg
));
716 i
= strtol (optarg
, &p
, 0);
717 if (i
== 0 && p
== optarg
)
719 /* Don't use *_filtered or warning() (which relies on
720 current_target) until after initialize_all_files(). */
724 "warning: could not set baud rate to `%s'.\n", optarg
);
730 #ifdef ADDITIONAL_OPTION_CASES
731 ADDITIONAL_OPTION_CASES
734 fprintf_unfiltered (gdb_stderr
,
735 "Use `%s --help' for a complete list of options.\n",
741 /* OK, that's all the options. The other arguments are filenames. */
743 for (; optind
< argc
; optind
++)
747 symarg
= argv
[optind
];
748 execarg
= argv
[optind
];
751 corearg
= argv
[optind
];
754 fprintf_unfiltered (gdb_stderr
,
755 "Excess command line arguments ignored. (%s%s)\n",
756 argv
[optind
], (optind
== argc
- 1) ? "" : " ...");
763 /* Run the init function of each source file */
765 init_cmd_lists (); /* This needs to be done first */
766 initialize_all_files ();
767 init_main (); /* But that omits this file! Do it now */
770 /* Do these (and anything which might call wrap_here or *_filtered)
771 after initialize_all_files. */
774 print_gdb_version (gdb_stdout
);
776 printf_filtered ("\n");
782 /* --version is intentionally not documented here, because we
783 are printing the version here, and the help is long enough
786 print_gdb_version (gdb_stdout
);
787 /* Make sure the output gets printed. */
789 printf_filtered ("\n");
791 /* But don't use *_filtered here. We don't want to prompt for continue
792 no matter how small the screen or how much we're going to print. */
794 This is the GNU debugger. Usage:\n\
795 gdb [options] [executable-file [core-file or process-id]]\n\
797 --help Print this message.\n\
798 --quiet Do not print version number on startup.\n\
799 --fullname Output information used by emacs-GDB interface.\n\
800 --epoch Output information used by epoch emacs-GDB interface.\n\
801 --batch Exit after processing options.\n\
802 --nx Do not read .gdbinit file.\n\
803 --tty=TTY Use TTY for input/output by the program being debugged.\n\
804 --cd=DIR Change current directory to DIR.\n\
805 --directory=DIR Search for source files in DIR.\n\
806 --command=FILE Execute GDB commands from FILE.\n\
807 --symbols=SYMFILE Read symbols from SYMFILE.\n\
808 --exec=EXECFILE Use EXECFILE as the executable.\n\
809 --se=FILE Use FILE as symbol file and executable file.\n\
810 --core=COREFILE Analyze the core dump COREFILE.\n\
811 -b BAUDRATE Set serial port baud rate used for remote debugging.\n\
812 --mapped Use mapped symbol files if supported on this system.\n\
813 --readnow Fully read symbol files on first access.\n\
815 #ifdef ADDITIONAL_OPTION_HELP
816 fputs_unfiltered (ADDITIONAL_OPTION_HELP
, gdb_stdout
);
818 fputs_unfiltered ("\n\
819 For more information, type \"help\" from within GDB, or consult the\n\
820 GDB manual (available as on-line info or a printed manual).\n", gdb_stdout
);
826 /* Print all the junk at the top, with trailing "..." if we are about
827 to read a symbol file (possibly slowly). */
828 print_gnu_advertisement ();
829 print_gdb_version (gdb_stdout
);
831 printf_filtered ("..");
833 gdb_flush (gdb_stdout
); /* Force to screen during slow operations */
836 error_pre_print
= "\n\n";
837 /* We may get more than one warning, don't double space all of them... */
838 warning_pre_print
= "\nwarning: ";
840 /* We need a default language for parsing expressions, so simple things like
841 "set width 0" won't fail if no language is explicitly set in a config file
842 or implicitly set by reading an executable during startup. */
843 set_language (language_c
);
844 expected_language
= current_language
; /* don't warn about the change. */
846 /* Read and execute $HOME/.gdbinit file, if it exists. This is done
847 *before* all the command line arguments are processed; it sets
848 global parameters, which are independent of what file you are
849 debugging or what directory you are in. */
850 homedir
= getenv ("HOME");
853 homeinit
= (char *) alloca (strlen (getenv ("HOME")) +
854 strlen (gdbinit
) + 10);
855 strcpy (homeinit
, getenv ("HOME"));
856 strcat (homeinit
, "/");
857 strcat (homeinit
, gdbinit
);
858 if (!inhibit_gdbinit
&& access (homeinit
, R_OK
) == 0)
860 if (!SET_TOP_LEVEL ())
861 source_command (homeinit
, 0);
863 do_cleanups (ALL_CLEANUPS
);
865 /* Do stats; no need to do them elsewhere since we'll only
866 need them if homedir is set. Make sure that they are
867 zero in case one of them fails (this guarantees that they
868 won't match if either exists). */
870 memset (&homebuf
, 0, sizeof (struct stat
));
871 memset (&cwdbuf
, 0, sizeof (struct stat
));
873 stat (homeinit
, &homebuf
);
874 stat (gdbinit
, &cwdbuf
); /* We'll only need this if
878 /* Now perform all the actions indicated by the arguments. */
881 if (!SET_TOP_LEVEL ())
883 cd_command (cdarg
, 0);
886 do_cleanups (ALL_CLEANUPS
);
888 for (i
= 0; i
< ndir
; i
++)
889 if (!SET_TOP_LEVEL ())
890 directory_command (dirarg
[i
], 0);
892 do_cleanups (ALL_CLEANUPS
);
896 && STREQ (execarg
, symarg
))
898 /* The exec file and the symbol-file are the same. If we can't open
899 it, better only print one error message. */
900 if (!SET_TOP_LEVEL ())
902 exec_file_command (execarg
, !batch
);
903 symbol_file_command (symarg
, 0);
909 if (!SET_TOP_LEVEL ())
910 exec_file_command (execarg
, !batch
);
912 if (!SET_TOP_LEVEL ())
913 symbol_file_command (symarg
, 0);
915 do_cleanups (ALL_CLEANUPS
);
917 /* After the symbol file has been read, print a newline to get us
918 beyond the copyright line... But errors should still set off
919 the error message with a (single) blank line. */
921 printf_filtered ("\n");
922 error_pre_print
= "\n";
923 warning_pre_print
= "\nwarning: ";
926 if (!SET_TOP_LEVEL ())
927 core_file_command (corearg
, !batch
);
928 else if (isdigit (corearg
[0]) && !SET_TOP_LEVEL ())
929 attach_command (corearg
, !batch
);
930 do_cleanups (ALL_CLEANUPS
);
933 if (!SET_TOP_LEVEL ())
934 tty_command (ttyarg
, !batch
);
935 do_cleanups (ALL_CLEANUPS
);
937 #ifdef ADDITIONAL_OPTION_HANDLER
938 ADDITIONAL_OPTION_HANDLER
;
941 /* Error messages should no longer be distinguished with extra output. */
943 warning_pre_print
= "warning: ";
945 /* Read the .gdbinit file in the current directory, *if* it isn't
946 the same as the $HOME/.gdbinit file (it should exist, also). */
949 || memcmp ((char *) &homebuf
, (char *) &cwdbuf
, sizeof (struct stat
)))
950 if (!inhibit_gdbinit
&& access (gdbinit
, R_OK
) == 0)
952 if (!SET_TOP_LEVEL ())
953 source_command (gdbinit
, 0);
955 do_cleanups (ALL_CLEANUPS
);
957 for (i
= 0; i
< ncmd
; i
++)
959 if (!SET_TOP_LEVEL ())
961 if (cmdarg
[i
][0] == '-' && cmdarg
[i
][1] == '\0')
962 read_command_file (stdin
);
964 source_command (cmdarg
[i
], !batch
);
965 do_cleanups (ALL_CLEANUPS
);
970 /* Read in the old history after all the command files have been read. */
975 /* We have hit the end of the batch file. */
979 /* Do any host- or target-specific hacks. This is used for i960 targets
980 to force the user to set a nindy target and spec its parameters. */
982 #ifdef BEFORE_MAIN_LOOP_HOOK
983 BEFORE_MAIN_LOOP_HOOK
;
986 /* The command loop. */
990 if (!SET_TOP_LEVEL ())
992 do_cleanups (ALL_CLEANUPS
); /* Do complete cleanup */
994 quit_command ((char *)0, instream
== stdin
);
997 /* No exit -- exit is through quit_command. */
1001 execute_user_command (c
, args
)
1002 struct cmd_list_element
*c
;
1005 register struct command_line
*cmdlines
;
1006 struct cleanup
*old_chain
;
1009 error ("User-defined commands cannot take arguments.");
1011 cmdlines
= c
->user_commands
;
1016 /* Set the instream to 0, indicating execution of a
1017 user-defined function. */
1018 old_chain
= make_cleanup (source_cleanup
, instream
);
1019 instream
= (FILE *) 0;
1022 execute_command (cmdlines
->line
, 0);
1023 cmdlines
= cmdlines
->next
;
1025 do_cleanups (old_chain
);
1028 /* Execute the line P as a command.
1029 Pass FROM_TTY as second argument to the defining function. */
1032 execute_command (p
, from_tty
)
1036 register struct cmd_list_element
*c
;
1037 register enum language flang
;
1038 static int warned
= 0;
1042 /* This can happen when command_line_input hits end of file. */
1046 while (*p
== ' ' || *p
== '\t') p
++;
1051 c
= lookup_cmd (&p
, cmdlist
, "", 0, 1);
1052 /* Pass null arg rather than an empty one. */
1055 /* If this command has been hooked, run the hook first. */
1057 execute_user_command (c
->hook
, (char *)0);
1059 if (c
->class == class_user
)
1060 execute_user_command (c
, arg
);
1061 else if (c
->type
== set_cmd
|| c
->type
== show_cmd
)
1062 do_setshow_command (arg
, from_tty
& caution
, c
);
1063 else if (c
->function
.cfunc
== NO_FUNCTION
)
1064 error ("That is not a command, just a help topic.");
1066 (*c
->function
.cfunc
) (arg
, from_tty
& caution
);
1069 /* Tell the user if the language has changed (except first time). */
1070 if (current_language
!= expected_language
)
1072 if (language_mode
== language_mode_auto
) {
1073 language_info (1); /* Print what changed. */
1078 /* Warn the user if the working language does not match the
1079 language of the current frame. Only warn the user if we are
1080 actually running the program, i.e. there is a stack. */
1081 /* FIXME: This should be cacheing the frame and only running when
1082 the frame changes. */
1083 if (target_has_stack
)
1085 flang
= get_frame_language ();
1087 && flang
!= language_unknown
1088 && flang
!= current_language
->la_language
)
1090 printf_filtered ("%s\n", lang_frame_mismatch_warn
);
1098 command_loop_marker (foo
)
1103 /* Read commands from `instream' and execute them
1104 until end of file or error reading instream. */
1108 struct cleanup
*old_chain
;
1110 int stdin_is_tty
= ISATTY (stdin
);
1112 while (!feof (instream
))
1114 if (window_hook
&& instream
== stdin
)
1115 (*window_hook
) (instream
, prompt
);
1118 if (instream
== stdin
&& stdin_is_tty
)
1119 reinitialize_more_filter ();
1120 old_chain
= make_cleanup (command_loop_marker
, 0);
1121 command
= command_line_input (instream
== stdin
? prompt
: (char *) NULL
,
1125 execute_command (command
, instream
== stdin
);
1126 /* Do any commands attached to breakpoint we stopped at. */
1127 bpstat_do_actions (&stop_bpstat
);
1128 do_cleanups (old_chain
);
1132 /* Commands call this if they do not want to be repeated by null lines. */
1140 /* If we aren't reading from standard input, we are saving the last
1141 thing read from stdin in line and don't want to delete it. Null lines
1142 won't repeat here in any case. */
1143 if (instream
== stdin
)
1147 /* Read a line from the stream "instream" without command line editing.
1149 It prints PRROMPT once at the start.
1150 Action is compatible with "readline", e.g. space for the result is
1151 malloc'd and should be freed by the caller.
1153 A NULL return means end of file. */
1155 gdb_readline (prrompt
)
1160 int input_index
= 0;
1161 int result_size
= 80;
1165 /* Don't use a _filtered function here. It causes the assumed
1166 character position to be off, since the newline we read from
1167 the user is not accounted for. */
1168 fputs_unfiltered (prrompt
, gdb_stdout
);
1169 gdb_flush (gdb_stdout
);
1172 result
= (char *) xmalloc (result_size
);
1176 /* Read from stdin if we are executing a user defined command.
1177 This is the right thing for prompt_for_continue, at least. */
1178 c
= fgetc (instream
? instream
: stdin
);
1182 if (input_index
> 0)
1183 /* The last line does not end with a newline. Return it, and
1184 if we are called again fgetc will still return EOF and
1185 we'll return NULL then. */
1194 result
[input_index
++] = c
;
1195 while (input_index
>= result_size
)
1198 result
= (char *) xrealloc (result
, result_size
);
1202 result
[input_index
++] = '\0';
1206 /* Variables which control command line editing and history
1207 substitution. These variables are given default values at the end
1209 static int command_editing_p
;
1210 static int history_expansion_p
;
1211 static int write_history_p
;
1212 static int history_size
;
1213 static char *history_filename
;
1215 /* readline uses the word breaks for two things:
1216 (1) In figuring out where to point the TEXT parameter to the
1217 rl_completion_entry_function. Since we don't use TEXT for much,
1218 it doesn't matter a lot what the word breaks are for this purpose, but
1219 it does affect how much stuff M-? lists.
1220 (2) If one of the matches contains a word break character, readline
1221 will quote it. That's why we switch between
1222 gdb_completer_word_break_characters and
1223 gdb_completer_command_word_break_characters. I'm not sure when
1224 we need this behavior (perhaps for funky characters in C++ symbols?). */
1226 /* Variables which are necessary for fancy command line editing. */
1227 char *gdb_completer_word_break_characters
=
1228 " \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,-";
1230 /* When completing on command names, we remove '-' from the list of
1231 word break characters, since we use it in command names. If the
1232 readline library sees one in any of the current completion strings,
1233 it thinks that the string needs to be quoted and automatically supplies
1235 char *gdb_completer_command_word_break_characters
=
1236 " \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,";
1238 /* Characters that can be used to quote completion strings. Note that we
1239 can't include '"' because the gdb C parser treats such quoted sequences
1241 char *gdb_completer_quote_characters
=
1244 /* Functions that are used as part of the fancy command line editing. */
1246 /* This can be used for functions which don't want to complete on symbols
1247 but don't want to complete on anything else either. */
1250 noop_completer (text
, prefix
)
1257 /* Complete on filenames. */
1259 filename_completer (text
, word
)
1263 /* From readline. */
1264 extern char *filename_completion_function ();
1265 int subsequent_name
;
1267 int return_val_used
;
1268 int return_val_alloced
;
1270 return_val_used
= 0;
1271 /* Small for testing. */
1272 return_val_alloced
= 1;
1273 return_val
= (char **) xmalloc (return_val_alloced
* sizeof (char *));
1275 subsequent_name
= 0;
1279 p
= filename_completion_function (text
, subsequent_name
);
1280 if (return_val_used
>= return_val_alloced
)
1282 return_val_alloced
*= 2;
1284 (char **) xrealloc (return_val
,
1285 return_val_alloced
* sizeof (char *));
1289 return_val
[return_val_used
++] = p
;
1292 /* Like emacs, don't complete on old versions. Especially useful
1293 in the "source" command. */
1294 if (p
[strlen (p
) - 1] == '~')
1300 /* Return exactly p. */
1301 return_val
[return_val_used
++] = p
;
1302 else if (word
> text
)
1304 /* Return some portion of p. */
1305 q
= xmalloc (strlen (p
) + 5);
1306 strcpy (q
, p
+ (word
- text
));
1307 return_val
[return_val_used
++] = q
;
1312 /* Return some of TEXT plus p. */
1313 q
= xmalloc (strlen (p
) + (text
- word
) + 5);
1314 strncpy (q
, word
, text
- word
);
1315 q
[text
- word
] = '\0';
1317 return_val
[return_val_used
++] = q
;
1321 subsequent_name
= 1;
1324 /* There is no way to do this just long enough to affect quote inserting
1325 without also affecting the next completion. This should be fixed in
1327 /* Insure that readline does the right thing
1328 with respect to inserting quotes. */
1329 rl_completer_word_break_characters
= "";
1334 /* Here are some useful test cases for completion. FIXME: These should
1335 be put in the test suite. They should be tested with both M-? and TAB.
1337 "show output-" "radix"
1338 "show output" "-radix"
1339 "p" ambiguous (commands starting with p--path, print, printf, etc.)
1340 "p " ambiguous (all symbols)
1341 "info t foo" no completions
1342 "info t " no completions
1343 "info t" ambiguous ("info target", "info terminal", etc.)
1344 "info ajksdlfk" no completions
1345 "info ajksdlfk " no completions
1347 "info " ambiguous (all info commands)
1348 "p \"a" no completions (string constant)
1349 "p 'a" ambiguous (all symbols starting with a)
1350 "p b-a" ambiguous (all symbols starting with a)
1351 "p b-" ambiguous (all symbols)
1352 "file Make" "file" (word break hard to screw up here)
1353 "file ../gdb.stabs/we" "ird" (needs to not break word at slash)
1356 /* Generate completions one by one for the completer. Each time we are
1357 called return another potential completion to the caller. The function
1358 is misnamed; it just completes on commands or passes the buck to the
1359 command's completer function; the stuff specific to symbol completion
1360 is in make_symbol_completion_list.
1362 TEXT is readline's idea of the "word" we are looking at; we don't really
1363 like readline's ideas about word breaking so we ignore it.
1365 MATCHES is the number of matches that have currently been collected from
1366 calling this completion function. When zero, then we need to initialize,
1367 otherwise the initialization has already taken place and we can just
1368 return the next potential completion string.
1370 Returns NULL if there are no more completions, else a pointer to a string
1371 which is a possible completion.
1373 RL_LINE_BUFFER is available to be looked at; it contains the entire text
1374 of the line. RL_POINT is the offset in that line of the cursor. You
1375 should pretend that the line ends at RL_POINT. */
1378 symbol_completion_function (text
, matches
)
1382 static char **list
= (char **)NULL
; /* Cache of completions */
1383 static int index
; /* Next cached completion */
1384 char *output
= NULL
;
1385 char *tmp_command
, *p
;
1386 /* Pointer within tmp_command which corresponds to text. */
1388 struct cmd_list_element
*c
, *result_list
;
1392 /* The caller is beginning to accumulate a new set of completions, so
1393 we need to find all of them now, and cache them for returning one at
1394 a time on future calls. */
1398 /* Free the storage used by LIST, but not by the strings inside.
1399 This is because rl_complete_internal () frees the strings. */
1405 /* Choose the default set of word break characters to break completions.
1406 If we later find out that we are doing completions on command strings
1407 (as opposed to strings supplied by the individual command completer
1408 functions, which can be any string) then we will switch to the
1409 special word break set for command strings, which leaves out the
1410 '-' character used in some commands. */
1412 rl_completer_word_break_characters
=
1413 gdb_completer_word_break_characters
;
1415 /* Decide whether to complete on a list of gdb commands or on symbols. */
1416 tmp_command
= (char *) alloca (rl_point
+ 1);
1419 strncpy (tmp_command
, rl_line_buffer
, rl_point
);
1420 tmp_command
[rl_point
] = '\0';
1421 /* Since text always contains some number of characters leading up
1422 to rl_point, we can find the equivalent position in tmp_command
1423 by subtracting that many characters from the end of tmp_command. */
1424 word
= tmp_command
+ rl_point
- strlen (text
);
1428 /* An empty line we want to consider ambiguous; that is, it
1429 could be any command. */
1430 c
= (struct cmd_list_element
*) -1;
1435 c
= lookup_cmd_1 (&p
, cmdlist
, &result_list
, 1);
1438 /* Move p up to the next interesting thing. */
1439 while (*p
== ' ' || *p
== '\t')
1446 /* It is an unrecognized command. So there are no
1447 possible completions. */
1450 else if (c
== (struct cmd_list_element
*) -1)
1454 /* lookup_cmd_1 advances p up to the first ambiguous thing, but
1455 doesn't advance over that thing itself. Do so now. */
1457 while (*q
&& (isalnum (*q
) || *q
== '-' || *q
== '_'))
1459 if (q
!= tmp_command
+ rl_point
)
1461 /* There is something beyond the ambiguous
1462 command, so there are no possible completions. For
1463 example, "info t " or "info t foo" does not complete
1464 to anything, because "info t" can be "info target" or
1470 /* We're trying to complete on the command which was ambiguous.
1471 This we can deal with. */
1474 list
= complete_on_cmdlist (*result_list
->prefixlist
, p
,
1479 list
= complete_on_cmdlist (cmdlist
, p
, word
);
1481 /* Insure that readline does the right thing with respect to
1482 inserting quotes. */
1483 rl_completer_word_break_characters
=
1484 gdb_completer_command_word_break_characters
;
1489 /* We've recognized a full command. */
1491 if (p
== tmp_command
+ rl_point
)
1493 /* There is no non-whitespace in the line beyond the command. */
1495 if (p
[-1] == ' ' || p
[-1] == '\t')
1497 /* The command is followed by whitespace; we need to complete
1498 on whatever comes after command. */
1501 /* It is a prefix command; what comes after it is
1502 a subcommand (e.g. "info "). */
1503 list
= complete_on_cmdlist (*c
->prefixlist
, p
, word
);
1505 /* Insure that readline does the right thing
1506 with respect to inserting quotes. */
1507 rl_completer_word_break_characters
=
1508 gdb_completer_command_word_break_characters
;
1512 /* It is a normal command; what comes after it is
1513 completed by the command's completer function. */
1514 list
= (*c
->completer
) (p
, word
);
1519 /* The command is not followed by whitespace; we need to
1520 complete on the command itself. e.g. "p" which is a
1521 command itself but also can complete to "print", "ptype"
1525 /* Find the command we are completing on. */
1527 while (q
> tmp_command
)
1529 if (isalnum (q
[-1]) || q
[-1] == '-' || q
[-1] == '_')
1535 list
= complete_on_cmdlist (result_list
, q
, word
);
1537 /* Insure that readline does the right thing
1538 with respect to inserting quotes. */
1539 rl_completer_word_break_characters
=
1540 gdb_completer_command_word_break_characters
;
1545 /* There is non-whitespace beyond the command. */
1547 if (c
->prefixlist
&& !c
->allow_unknown
)
1549 /* It is an unrecognized subcommand of a prefix command,
1550 e.g. "info adsfkdj". */
1555 /* It is a normal command. */
1556 list
= (*c
->completer
) (p
, word
);
1562 /* If we found a list of potential completions during initialization then
1563 dole them out one at a time. The vector of completions is NULL
1564 terminated, so after returning the last one, return NULL (and continue
1565 to do so) each time we are called after that, until a new list is
1570 output
= list
[index
];
1578 /* Can't do this because readline hasn't yet checked the word breaks
1579 for figuring out whether to insert a quote. */
1581 /* Make sure the word break characters are set back to normal for the
1582 next time that readline tries to complete something. */
1583 rl_completer_word_break_characters
=
1584 gdb_completer_word_break_characters
;
1590 /* Skip over a possibly quoted word (as defined by the quote characters
1591 and word break characters the completer uses). Returns pointer to the
1592 location after the "word". */
1598 char quote_char
= '\0';
1601 for (scan
= str
; *scan
!= '\0'; scan
++)
1603 if (quote_char
!= '\0')
1605 /* Ignore everything until the matching close quote char */
1606 if (*scan
== quote_char
)
1608 /* Found matching close quote. */
1613 else if (strchr (gdb_completer_quote_characters
, *scan
))
1615 /* Found start of a quoted string. */
1618 else if (strchr (gdb_completer_word_break_characters
, *scan
))
1632 #if STOP_SIGNAL == SIGTSTP
1633 signal (SIGTSTP
, SIG_DFL
);
1635 kill (getpid (), SIGTSTP
);
1636 signal (SIGTSTP
, stop_sig
);
1638 signal (STOP_SIGNAL
, stop_sig
);
1640 printf_unfiltered ("%s", prompt
);
1641 gdb_flush (gdb_stdout
);
1643 /* Forget about any previous command -- null line now will do nothing. */
1646 #endif /* STOP_SIGNAL */
1648 /* Initialize signal handlers. */
1658 signal (SIGINT
, request_quit
);
1660 /* If we initialize SIGQUIT to SIG_IGN, then the SIG_IGN will get
1661 passed to the inferior, which we don't want. It would be
1662 possible to do a "signal (SIGQUIT, SIG_DFL)" after we fork, but
1663 on BSD4.3 systems using vfork, that can affect the
1664 GDB process as well as the inferior (the signal handling tables
1665 might be in memory, shared between the two). Since we establish
1666 a handler for SIGQUIT, when we call exec it will set the signal
1667 to SIG_DFL for us. */
1668 signal (SIGQUIT
, do_nothing
);
1669 if (signal (SIGHUP
, do_nothing
) != SIG_IGN
)
1670 signal (SIGHUP
, disconnect
);
1671 signal (SIGFPE
, float_handler
);
1673 #if defined(SIGWINCH) && defined(SIGWINCH_HANDLER)
1674 signal (SIGWINCH
, SIGWINCH_HANDLER
);
1678 /* Read one line from the command input stream `instream'
1679 into the local static buffer `linebuffer' (whose current length
1681 The buffer is made bigger as necessary.
1682 Returns the address of the start of the line.
1684 NULL is returned for end of file.
1686 *If* the instream == stdin & stdin is a terminal, the line read
1687 is copied into the file line saver (global var char *line,
1688 length linesize) so that it can be duplicated.
1690 This routine either uses fancy command line editing or
1691 simple input as the user has requested. */
1694 command_line_input (prrompt
, repeat
)
1698 static char *linebuffer
= 0;
1699 static unsigned linelength
= 0;
1703 char *local_prompt
= prrompt
;
1708 if (annotation_level
> 1 && prrompt
!= NULL
)
1710 local_prompt
= alloca (strlen (prrompt
) + 20);
1711 strcpy (local_prompt
, prrompt
);
1712 strcat (local_prompt
, "\n\032\032prompt\n");
1715 if (linebuffer
== 0)
1718 linebuffer
= (char *) xmalloc (linelength
);
1723 /* Control-C quits instantly if typed while in this loop
1724 since it should not wait until the user types a newline. */
1728 signal (STOP_SIGNAL
, stop_sig
);
1733 /* Reports are that some Sys V's don't flush gdb_stdout/err on reads
1734 from stdin, when stdin/out are sockets rather than ttys. So we
1735 have to do it ourselves, to make emacs-gdb and xxgdb work.
1736 On other machines, doing this once per input should be a cheap nop. */
1737 gdb_flush (gdb_stdout
);
1738 gdb_flush (gdb_stderr
);
1740 if (source_file_name
!= NULL
)
1742 ++source_line_number
;
1743 sprintf (source_error
,
1744 "%s%s:%d: Error in sourced command file:\n",
1747 source_line_number
);
1748 error_pre_print
= source_error
;
1751 if (annotation_level
> 1 && instream
== stdin
)
1752 printf_unfiltered ("\n\032\032pre-prompt\n");
1754 /* Don't use fancy stuff if not talking to stdin. */
1755 if (command_editing_p
&& instream
== stdin
1756 && ISATTY (instream
))
1757 rl
= readline (local_prompt
);
1759 rl
= gdb_readline (local_prompt
);
1761 if (annotation_level
> 1 && instream
== stdin
)
1762 printf_unfiltered ("\n\032\032post-prompt\n");
1764 if (!rl
|| rl
== (char *) EOF
)
1769 if (strlen(rl
) + 1 + (p
- linebuffer
) > linelength
)
1771 linelength
= strlen(rl
) + 1 + (p
- linebuffer
);
1772 nline
= (char *) xrealloc (linebuffer
, linelength
);
1773 p
+= nline
- linebuffer
;
1777 /* Copy line. Don't copy null at end. (Leaves line alone
1778 if this was just a newline) */
1782 free (rl
); /* Allocated in readline. */
1784 if (p
== linebuffer
|| *(p
- 1) != '\\')
1787 p
--; /* Put on top of '\'. */
1788 local_prompt
= (char *) 0;
1793 signal (STOP_SIGNAL
, SIG_DFL
);
1800 #define SERVER_COMMAND_LENGTH 7
1802 (p
- linebuffer
> SERVER_COMMAND_LENGTH
)
1803 && STREQN (linebuffer
, "server ", SERVER_COMMAND_LENGTH
);
1806 /* Note that we don't set `line'. Between this and the check in
1807 dont_repeat, this insures that repeating will still do the
1810 return linebuffer
+ SERVER_COMMAND_LENGTH
;
1813 /* Do history expansion if that is wished. */
1814 if (history_expansion_p
&& instream
== stdin
1815 && ISATTY (instream
))
1817 char *history_value
;
1820 *p
= '\0'; /* Insert null now. */
1821 expanded
= history_expand (linebuffer
, &history_value
);
1824 /* Print the changes. */
1825 printf_unfiltered ("%s\n", history_value
);
1827 /* If there was an error, call this function again. */
1830 free (history_value
);
1831 return command_line_input (prrompt
, repeat
);
1833 if (strlen (history_value
) > linelength
)
1835 linelength
= strlen (history_value
) + 1;
1836 linebuffer
= (char *) xrealloc (linebuffer
, linelength
);
1838 strcpy (linebuffer
, history_value
);
1839 p
= linebuffer
+ strlen(linebuffer
);
1840 free (history_value
);
1844 /* If we just got an empty line, and that is supposed
1845 to repeat the previous command, return the value in the
1849 if (p
== linebuffer
)
1852 while (*p1
== ' ' || *p1
== '\t')
1860 /* Add line to history if appropriate. */
1861 if (instream
== stdin
1862 && ISATTY (stdin
) && *linebuffer
)
1863 add_history (linebuffer
);
1865 /* Note: lines consisting soley of comments are added to the command
1866 history. This is useful when you type a command, and then
1867 realize you don't want to execute it quite yet. You can comment
1868 out the command and then later fetch it from the value history
1869 and remove the '#'. The kill ring is probably better, but some
1870 people are in the habit of commenting things out. */
1872 while ((c
= *p1
++) != '\0')
1875 while ((c
= *p1
++) != '"')
1877 /* Make sure an escaped '"' doesn't make us think the string
1885 while ((c
= *p1
++) != '\'')
1887 /* Make sure an escaped '\'' doesn't make us think the string
1896 /* Found a comment. */
1902 /* Save into global buffer if appropriate. */
1905 if (linelength
> linesize
)
1907 line
= xrealloc (line
, linelength
);
1908 linesize
= linelength
;
1910 strcpy (line
, linebuffer
);
1917 /* Read lines from the input stream
1918 and accumulate them in a chain of struct command_line's
1919 which is then returned. */
1921 struct command_line
*
1922 read_command_lines ()
1924 struct command_line
*first
= 0;
1925 register struct command_line
*next
, *tail
= 0;
1926 register char *p
, *p1
;
1927 struct cleanup
*old_chain
= 0;
1932 p
= command_line_input ((char *) NULL
, instream
== stdin
);
1934 /* Treat end of file like "end". */
1937 /* Remove leading and trailing blanks. */
1938 while (*p
== ' ' || *p
== '\t') p
++;
1939 p1
= p
+ strlen (p
);
1940 while (p1
!= p
&& (p1
[-1] == ' ' || p1
[-1] == '\t')) p1
--;
1942 /* Is this "end"? */
1943 if (p1
- p
== 3 && !strncmp (p
, "end", 3))
1946 /* No => add this line to the chain of command lines. */
1947 next
= (struct command_line
*) xmalloc (sizeof (struct command_line
));
1948 next
->line
= savestring (p
, p1
- p
);
1956 /* We just read the first line.
1957 From now on, arrange to throw away the lines we have
1958 if we quit or get an error while inside this function. */
1960 old_chain
= make_cleanup (free_command_lines
, &first
);
1967 /* Now we are about to return the chain to our caller,
1968 so freeing it becomes his responsibility. */
1970 discard_cleanups (old_chain
);
1974 /* Free a chain of struct command_line's. */
1977 free_command_lines (lptr
)
1978 struct command_line
**lptr
;
1980 register struct command_line
*l
= *lptr
;
1981 register struct command_line
*next
;
1992 /* Add an element to the list of info subcommands. */
1995 add_info (name
, fun
, doc
)
1997 void (*fun
) PARAMS ((char *, int));
2000 add_cmd (name
, no_class
, fun
, doc
, &infolist
);
2003 /* Add an alias to the list of info subcommands. */
2006 add_info_alias (name
, oldname
, abbrev_flag
)
2011 add_alias_cmd (name
, oldname
, 0, abbrev_flag
, &infolist
);
2014 /* The "info" command is defined as a prefix, with allow_unknown = 0.
2015 Therefore, its own definition is called only for "info" with no args. */
2019 info_command (arg
, from_tty
)
2023 printf_unfiltered ("\"info\" must be followed by the name of an info command.\n");
2024 help_list (infolist
, "info ", -1, gdb_stdout
);
2027 /* The "complete" command is used by Emacs to implement completion. */
2031 complete_command (arg
, from_tty
)
2042 rl_line_buffer
[0] = '\0';
2047 strcpy (rl_line_buffer
, arg
);
2048 rl_point
= strlen (arg
);
2051 for (completion
= symbol_completion_function (rl_line_buffer
, i
= 0);
2053 completion
= symbol_completion_function (rl_line_buffer
, ++i
))
2054 printf_unfiltered ("%s\n", completion
);
2057 /* The "show" command with no arguments shows all the settings. */
2061 show_command (arg
, from_tty
)
2065 cmd_show_list (showlist
, from_tty
, "");
2068 /* Add an element to the list of commands. */
2071 add_com (name
, class, fun
, doc
)
2073 enum command_class
class;
2074 void (*fun
) PARAMS ((char *, int));
2077 add_cmd (name
, class, fun
, doc
, &cmdlist
);
2080 /* Add an alias or abbreviation command to the list of commands. */
2083 add_com_alias (name
, oldname
, class, abbrev_flag
)
2086 enum command_class
class;
2089 add_alias_cmd (name
, oldname
, class, abbrev_flag
, &cmdlist
);
2096 error ("Argument required (%s).", why
);
2101 help_command (command
, from_tty
)
2103 int from_tty
; /* Ignored */
2105 help_cmd (command
, gdb_stdout
);
2109 validate_comname (comname
)
2115 error_no_arg ("name of command to define");
2120 if (!isalnum(*p
) && *p
!= '-')
2121 error ("Junk in argument list: \"%s\"", p
);
2126 /* This is just a placeholder in the command data structures. */
2128 user_defined_command (ignore
, from_tty
)
2135 define_command (comname
, from_tty
)
2139 register struct command_line
*cmds
;
2140 register struct cmd_list_element
*c
, *newc
, *hookc
= 0;
2141 char *tem
= comname
;
2142 #define HOOK_STRING "hook-"
2145 validate_comname (comname
);
2147 /* Look it up, and verify that we got an exact match. */
2148 c
= lookup_cmd (&tem
, cmdlist
, "", -1, 1);
2149 if (c
&& !STREQ (comname
, c
->name
))
2154 if (c
->class == class_user
|| c
->class == class_alias
)
2155 tem
= "Redefine command \"%s\"? ";
2157 tem
= "Really redefine built-in command \"%s\"? ";
2158 if (!query (tem
, c
->name
))
2159 error ("Command \"%s\" not redefined.", c
->name
);
2162 /* If this new command is a hook, then mark the command which it
2163 is hooking. Note that we allow hooking `help' commands, so that
2164 we can hook the `stop' pseudo-command. */
2166 if (!strncmp (comname
, HOOK_STRING
, HOOK_LEN
))
2168 /* Look up cmd it hooks, and verify that we got an exact match. */
2169 tem
= comname
+HOOK_LEN
;
2170 hookc
= lookup_cmd (&tem
, cmdlist
, "", -1, 0);
2171 if (hookc
&& !STREQ (comname
+HOOK_LEN
, hookc
->name
))
2175 warning ("Your new `%s' command does not hook any existing command.",
2177 if (!query ("Proceed? ", (char *)0))
2178 error ("Not confirmed.");
2182 comname
= savestring (comname
, strlen (comname
));
2184 /* If the rest of the commands will be case insensitive, this one
2185 should behave in the same manner. */
2186 for (tem
= comname
; *tem
; tem
++)
2187 if (isupper(*tem
)) *tem
= tolower(*tem
);
2191 printf_unfiltered ("Type commands for definition of \"%s\".\n\
2192 End with a line saying just \"end\".\n", comname
);
2193 gdb_flush (gdb_stdout
);
2196 cmds
= read_command_lines ();
2198 if (c
&& c
->class == class_user
)
2199 free_command_lines (&c
->user_commands
);
2201 newc
= add_cmd (comname
, class_user
, user_defined_command
,
2202 (c
&& c
->class == class_user
)
2203 ? c
->doc
: savestring ("User-defined.", 13), &cmdlist
);
2204 newc
->user_commands
= cmds
;
2206 /* If this new command is a hook, then mark both commands as being
2210 hookc
->hook
= newc
; /* Target gets hooked. */
2211 newc
->hookee
= hookc
; /* We are marked as hooking target cmd. */
2216 document_command (comname
, from_tty
)
2220 struct command_line
*doclines
;
2221 register struct cmd_list_element
*c
;
2222 char *tem
= comname
;
2224 validate_comname (comname
);
2226 c
= lookup_cmd (&tem
, cmdlist
, "", 0, 1);
2228 if (c
->class != class_user
)
2229 error ("Command \"%s\" is built-in.", comname
);
2232 printf_unfiltered ("Type documentation for \"%s\".\n\
2233 End with a line saying just \"end\".\n", comname
);
2235 doclines
= read_command_lines ();
2237 if (c
->doc
) free (c
->doc
);
2240 register struct command_line
*cl1
;
2241 register int len
= 0;
2243 for (cl1
= doclines
; cl1
; cl1
= cl1
->next
)
2244 len
+= strlen (cl1
->line
) + 1;
2246 c
->doc
= (char *) xmalloc (len
+ 1);
2249 for (cl1
= doclines
; cl1
; cl1
= cl1
->next
)
2251 strcat (c
->doc
, cl1
->line
);
2253 strcat (c
->doc
, "\n");
2257 free_command_lines (&doclines
);
2261 print_gnu_advertisement()
2263 printf_unfiltered ("\
2264 GDB is free software and you are welcome to distribute copies of it\n\
2265 under certain conditions; type \"show copying\" to see the conditions.\n\
2266 There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\
2271 print_gdb_version (stream
)
2274 fprintf_filtered (stream
, "\
2275 GDB %s (%s", version
, host_name
);
2277 if (!STREQ (host_name
, target_name
))
2278 fprintf_filtered (stream
, " --target %s", target_name
);
2280 fprintf_filtered (stream
, "), ");
2282 fprintf_filtered (stream
, "Copyright 1994 Free Software Foundation, Inc.");
2287 show_version (args
, from_tty
)
2292 print_gnu_advertisement ();
2293 print_gdb_version (gdb_stdout
);
2294 printf_filtered ("\n");
2298 /* xgdb calls this to reprint the usual GDB prompt. Obsolete now that xgdb
2304 printf_unfiltered ("%s", prompt
);
2305 gdb_flush (gdb_stdout
);
2309 quit_command (args
, from_tty
)
2313 if (inferior_pid
!= 0 && target_has_execution
)
2317 if (query ("The program is running. Quit anyway (and detach it)? "))
2318 target_detach (args
, from_tty
);
2320 error ("Not confirmed.");
2324 if (query ("The program is running. Quit anyway (and kill it)? "))
2327 error ("Not confirmed.");
2330 /* UDI wants this, to kill the TIP. */
2333 /* Save the history information if it is appropriate to do so. */
2334 if (write_history_p
&& history_filename
)
2335 write_history (history_filename
);
2340 /* Returns whether GDB is running on a terminal and whether the user
2341 desires that questions be asked of them on that terminal. */
2344 input_from_terminal_p ()
2346 return gdb_has_a_terminal () && (instream
== stdin
) & caution
;
2351 pwd_command (args
, from_tty
)
2355 if (args
) error ("The \"pwd\" command does not take an argument: %s", args
);
2356 getcwd (dirbuf
, sizeof (dirbuf
));
2358 if (!STREQ (dirbuf
, current_directory
))
2359 printf_unfiltered ("Working directory %s\n (canonically %s).\n",
2360 current_directory
, dirbuf
);
2362 printf_unfiltered ("Working directory %s.\n", current_directory
);
2366 cd_command (dir
, from_tty
)
2371 /* Found something other than leading repetitions of "/..". */
2372 int found_real_path
;
2375 /* If the new directory is absolute, repeat is a no-op; if relative,
2376 repeat might be useful but is more likely to be a mistake. */
2380 error_no_arg ("new working directory");
2382 dir
= tilde_expand (dir
);
2383 make_cleanup (free
, dir
);
2385 if (chdir (dir
) < 0)
2386 perror_with_name (dir
);
2389 dir
= savestring (dir
, len
- (len
> 1 && dir
[len
-1] == '/'));
2391 current_directory
= dir
;
2394 if (current_directory
[0] == '/' && current_directory
[1] == '\0')
2395 current_directory
= concat (current_directory
, dir
, NULL
);
2397 current_directory
= concat (current_directory
, "/", dir
, NULL
);
2401 /* Now simplify any occurrences of `.' and `..' in the pathname. */
2403 found_real_path
= 0;
2404 for (p
= current_directory
; *p
;)
2406 if (p
[0] == '/' && p
[1] == '.' && (p
[2] == 0 || p
[2] == '/'))
2408 else if (p
[0] == '/' && p
[1] == '.' && p
[2] == '.'
2409 && (p
[3] == 0 || p
[3] == '/'))
2411 if (found_real_path
)
2413 /* Search backwards for the directory just before the "/.."
2414 and obliterate it and the "/..". */
2416 while (q
!= current_directory
&& q
[-1] != '/')
2419 if (q
== current_directory
)
2420 /* current_directory is
2421 a relative pathname ("can't happen"--leave it alone). */
2425 strcpy (q
- 1, p
+ 3);
2430 /* We are dealing with leading repetitions of "/..", for example
2431 "/../..", which is the Mach super-root. */
2436 found_real_path
= 1;
2441 forget_cached_source_info ();
2444 pwd_command ((char *) 0, 1);
2447 struct source_cleanup_lines_args
{
2450 char *old_pre_error
;
2451 char *old_error_pre_print
;
2455 source_cleanup_lines (args
)
2458 struct source_cleanup_lines_args
*p
=
2459 (struct source_cleanup_lines_args
*)args
;
2460 source_line_number
= p
->old_line
;
2461 source_file_name
= p
->old_file
;
2462 source_pre_error
= p
->old_pre_error
;
2463 error_pre_print
= p
->old_error_pre_print
;
2468 source_command (args
, from_tty
)
2473 struct cleanup
*old_cleanups
;
2475 struct source_cleanup_lines_args old_lines
;
2480 error ("source command requires pathname of file to source.");
2483 file
= tilde_expand (file
);
2484 old_cleanups
= make_cleanup (free
, file
);
2486 stream
= fopen (file
, FOPEN_RT
);
2488 perror_with_name (file
);
2490 make_cleanup (fclose
, stream
);
2492 old_lines
.old_line
= source_line_number
;
2493 old_lines
.old_file
= source_file_name
;
2494 old_lines
.old_pre_error
= source_pre_error
;
2495 old_lines
.old_error_pre_print
= error_pre_print
;
2496 make_cleanup (source_cleanup_lines
, &old_lines
);
2497 source_line_number
= 0;
2498 source_file_name
= file
;
2499 source_pre_error
= error_pre_print
== NULL
? "" : error_pre_print
;
2500 source_pre_error
= savestring (source_pre_error
, strlen (source_pre_error
));
2501 make_cleanup (free
, source_pre_error
);
2502 /* This will get set every time we read a line. So it won't stay "" for
2504 error_pre_print
= "";
2506 needed_length
= strlen (source_file_name
) + strlen (source_pre_error
) + 80;
2507 if (source_error_allocated
< needed_length
)
2509 source_error_allocated
*= 2;
2510 if (source_error_allocated
< needed_length
)
2511 source_error_allocated
= needed_length
;
2512 if (source_error
== NULL
)
2513 source_error
= xmalloc (source_error_allocated
);
2515 source_error
= xrealloc (source_error
, source_error_allocated
);
2518 read_command_file (stream
);
2520 do_cleanups (old_cleanups
);
2525 echo_command (text
, from_tty
)
2533 while ((c
= *p
++) != '\0')
2537 /* \ at end of argument is used after spaces
2538 so they won't be lost. */
2542 c
= parse_escape (&p
);
2544 printf_filtered ("%c", c
);
2547 printf_filtered ("%c", c
);
2550 /* Force this output to appear now. */
2552 gdb_flush (gdb_stdout
);
2556 /* Functions to manipulate command line editing control variables. */
2558 /* Number of commands to print in each call to show_commands. */
2559 #define Hist_print 10
2561 show_commands (args
, from_tty
)
2565 /* Index for history commands. Relative to history_base. */
2568 /* Number of the history entry which we are planning to display next.
2569 Relative to history_base. */
2572 /* The first command in the history which doesn't exist (i.e. one more
2573 than the number of the last command). Relative to history_base. */
2576 extern HIST_ENTRY
*history_get
PARAMS ((int));
2578 /* Print out some of the commands from the command history. */
2579 /* First determine the length of the history list. */
2580 hist_len
= history_size
;
2581 for (offset
= 0; offset
< history_size
; offset
++)
2583 if (!history_get (history_base
+ offset
))
2592 if (args
[0] == '+' && args
[1] == '\0')
2593 /* "info editing +" should print from the stored position. */
2596 /* "info editing <exp>" should print around command number <exp>. */
2597 num
= (parse_and_eval_address (args
) - history_base
) - Hist_print
/ 2;
2599 /* "show commands" means print the last Hist_print commands. */
2602 num
= hist_len
- Hist_print
;
2608 /* If there are at least Hist_print commands, we want to display the last
2609 Hist_print rather than, say, the last 6. */
2610 if (hist_len
- num
< Hist_print
)
2612 num
= hist_len
- Hist_print
;
2617 for (offset
= num
; offset
< num
+ Hist_print
&& offset
< hist_len
; offset
++)
2619 printf_filtered ("%5d %s\n", history_base
+ offset
,
2620 (history_get (history_base
+ offset
))->line
);
2623 /* The next command we want to display is the next one that we haven't
2627 /* If the user repeats this command with return, it should do what
2628 "show commands +" does. This is unnecessary if arg is null,
2629 because "show commands +" is not useful after "show commands". */
2630 if (from_tty
&& args
)
2637 /* Called by do_setshow_command. */
2640 set_history_size_command (args
, from_tty
, c
)
2643 struct cmd_list_element
*c
;
2645 if (history_size
== INT_MAX
)
2646 unstifle_history ();
2647 else if (history_size
>= 0)
2648 stifle_history (history_size
);
2651 history_size
= INT_MAX
;
2652 error ("History size must be non-negative");
2658 set_history (args
, from_tty
)
2662 printf_unfiltered ("\"set history\" must be followed by the name of a history subcommand.\n");
2663 help_list (sethistlist
, "set history ", -1, gdb_stdout
);
2668 show_history (args
, from_tty
)
2672 cmd_show_list (showhistlist
, from_tty
, "");
2675 int info_verbose
= 0; /* Default verbose msgs off */
2677 /* Called by do_setshow_command. An elaborate joke. */
2680 set_verbose (args
, from_tty
, c
)
2683 struct cmd_list_element
*c
;
2685 char *cmdname
= "verbose";
2686 struct cmd_list_element
*showcmd
;
2688 showcmd
= lookup_cmd_1 (&cmdname
, showlist
, NULL
, 1);
2692 c
->doc
= "Set verbose printing of informational messages.";
2693 showcmd
->doc
= "Show verbose printing of informational messages.";
2697 c
->doc
= "Set verbosity.";
2698 showcmd
->doc
= "Show verbosity.";
2703 float_handler (signo
)
2706 /* This message is based on ANSI C, section 4.7. Note that integer
2707 divide by zero causes this, so "float" is a misnomer. */
2708 signal (SIGFPE
, float_handler
);
2709 error ("Erroneous arithmetic operation.");
2712 /* Return whether we are running a batch file or from terminal. */
2716 return !(instream
== stdin
&& ISATTY (stdin
));
2728 enablebreaklist
= NULL
;
2733 showhistlist
= NULL
;
2734 unsethistlist
= NULL
;
2735 #if MAINTENANCE_CMDS
2736 maintenancelist
= NULL
;
2737 maintenanceinfolist
= NULL
;
2738 maintenanceprintlist
= NULL
;
2740 setprintlist
= NULL
;
2741 showprintlist
= NULL
;
2742 setchecklist
= NULL
;
2743 showchecklist
= NULL
;
2746 /* Init the history buffer. Note that we are called after the init file(s)
2747 * have been read so that the user can change the history file via his
2748 * .gdbinit file (for instance). The GDBHISTFILE environment variable
2749 * overrides all of this.
2757 tmpenv
= getenv ("HISTSIZE");
2759 history_size
= atoi (tmpenv
);
2760 else if (!history_size
)
2763 stifle_history (history_size
);
2765 tmpenv
= getenv ("GDBHISTFILE");
2767 history_filename
= savestring (tmpenv
, strlen(tmpenv
));
2768 else if (!history_filename
) {
2769 /* We include the current directory so that if the user changes
2770 directories the file written will be the same as the one
2772 history_filename
= concat (current_directory
, "/.gdb_history", NULL
);
2774 read_history (history_filename
);
2780 struct cmd_list_element
*c
;
2782 #ifdef DEFAULT_PROMPT
2783 prompt
= savestring (DEFAULT_PROMPT
, strlen(DEFAULT_PROMPT
));
2785 prompt
= savestring ("(gdb) ", 6);
2788 /* Set the important stuff up for command editing. */
2789 command_editing_p
= 1;
2790 history_expansion_p
= 0;
2791 write_history_p
= 0;
2793 /* Setup important stuff for command line editing. */
2794 rl_completion_entry_function
= (int (*)()) symbol_completion_function
;
2795 rl_completer_word_break_characters
= gdb_completer_word_break_characters
;
2796 rl_completer_quote_characters
= gdb_completer_quote_characters
;
2797 rl_readline_name
= "gdb";
2799 /* Define the classes of commands.
2800 They will appear in the help list in the reverse of this order. */
2802 add_cmd ("internals", class_maintenance
, NO_FUNCTION
,
2803 "Maintenance commands.\n\
2804 Some gdb commands are provided just for use by gdb maintainers.\n\
2805 These commands are subject to frequent change, and may not be as\n\
2806 well documented as user commands.",
2808 add_cmd ("obscure", class_obscure
, NO_FUNCTION
, "Obscure features.", &cmdlist
);
2809 add_cmd ("aliases", class_alias
, NO_FUNCTION
, "Aliases of other commands.", &cmdlist
);
2810 add_cmd ("user-defined", class_user
, NO_FUNCTION
, "User-defined commands.\n\
2811 The commands in this class are those defined by the user.\n\
2812 Use the \"define\" command to define a command.", &cmdlist
);
2813 add_cmd ("support", class_support
, NO_FUNCTION
, "Support facilities.", &cmdlist
);
2814 add_cmd ("status", class_info
, NO_FUNCTION
, "Status inquiries.", &cmdlist
);
2815 add_cmd ("files", class_files
, NO_FUNCTION
, "Specifying and examining files.", &cmdlist
);
2816 add_cmd ("breakpoints", class_breakpoint
, NO_FUNCTION
, "Making program stop at certain points.", &cmdlist
);
2817 add_cmd ("data", class_vars
, NO_FUNCTION
, "Examining data.", &cmdlist
);
2818 add_cmd ("stack", class_stack
, NO_FUNCTION
, "Examining the stack.\n\
2819 The stack is made up of stack frames. Gdb assigns numbers to stack frames\n\
2820 counting from zero for the innermost (currently executing) frame.\n\n\
2821 At any time gdb identifies one frame as the \"selected\" frame.\n\
2822 Variable lookups are done with respect to the selected frame.\n\
2823 When the program being debugged stops, gdb selects the innermost frame.\n\
2824 The commands below can be used to select other frames by number or address.",
2826 add_cmd ("running", class_run
, NO_FUNCTION
, "Running the program.", &cmdlist
);
2828 add_com ("pwd", class_files
, pwd_command
,
2829 "Print working directory. This is used for your program as well.");
2830 c
= add_cmd ("cd", class_files
, cd_command
,
2831 "Set working directory to DIR for debugger and program being debugged.\n\
2832 The change does not take effect for the program being debugged\n\
2833 until the next time it is started.", &cmdlist
);
2834 c
->completer
= filename_completer
;
2837 (add_set_cmd ("prompt", class_support
, var_string
, (char *)&prompt
,
2842 add_com ("echo", class_support
, echo_command
,
2843 "Print a constant string. Give string as argument.\n\
2844 C escape sequences may be used in the argument.\n\
2845 No newline is added at the end of the argument;\n\
2846 use \"\\n\" if you want a newline to be printed.\n\
2847 Since leading and trailing whitespace are ignored in command arguments,\n\
2848 if you want to print some you must use \"\\\" before leading whitespace\n\
2849 to be printed or after trailing whitespace.");
2850 add_com ("document", class_support
, document_command
,
2851 "Document a user-defined command.\n\
2852 Give command name as argument. Give documentation on following lines.\n\
2853 End with a line of just \"end\".");
2854 add_com ("define", class_support
, define_command
,
2855 "Define a new command name. Command name is argument.\n\
2856 Definition appears on following lines, one command per line.\n\
2857 End with a line of just \"end\".\n\
2858 Use the \"document\" command to give documentation for the new command.\n\
2859 Commands defined in this way do not take arguments.");
2862 c
= add_cmd ("source", class_support
, source_command
,
2863 "Read commands from a file named FILE.\n\
2864 Note that the file \"" GDBINIT_FILENAME
"\" is read automatically in this way\n\
2865 when gdb is started.", &cmdlist
);
2867 /* Punt file name, we can't help it easily. */
2868 c
= add_cmd ("source", class_support
, source_command
,
2869 "Read commands from a file named FILE.\n\
2870 Note that the file \".gdbinit\" is read automatically in this way\n\
2871 when gdb is started.", &cmdlist
);
2873 c
->completer
= filename_completer
;
2875 add_com ("quit", class_support
, quit_command
, "Exit gdb.");
2876 add_com ("help", class_support
, help_command
, "Print list of commands.");
2877 add_com_alias ("q", "quit", class_support
, 1);
2878 add_com_alias ("h", "help", class_support
, 1);
2881 c
= add_set_cmd ("verbose", class_support
, var_boolean
, (char *)&info_verbose
,
2884 add_show_from_set (c
, &showlist
);
2885 c
->function
.sfunc
= set_verbose
;
2886 set_verbose (NULL
, 0, c
);
2889 (add_set_cmd ("editing", class_support
, var_boolean
, (char *)&command_editing_p
,
2890 "Set editing of command lines as they are typed.\n\
2891 Use \"on\" to enable to enable the editing, and \"off\" to disable it.\n\
2892 Without an argument, command line editing is enabled. To edit, use\n\
2893 EMACS-like or VI-like commands like control-P or ESC.", &setlist
),
2896 add_prefix_cmd ("history", class_support
, set_history
,
2897 "Generic command for setting command history parameters.",
2898 &sethistlist
, "set history ", 0, &setlist
);
2899 add_prefix_cmd ("history", class_support
, show_history
,
2900 "Generic command for showing command history parameters.",
2901 &showhistlist
, "show history ", 0, &showlist
);
2904 (add_set_cmd ("expansion", no_class
, var_boolean
, (char *)&history_expansion_p
,
2905 "Set history expansion on command input.\n\
2906 Without an argument, history expansion is enabled.", &sethistlist
),
2910 (add_set_cmd ("save", no_class
, var_boolean
, (char *)&write_history_p
,
2911 "Set saving of the history record on exit.\n\
2912 Use \"on\" to enable to enable the saving, and \"off\" to disable it.\n\
2913 Without an argument, saving is enabled.", &sethistlist
),
2916 c
= add_set_cmd ("size", no_class
, var_integer
, (char *)&history_size
,
2917 "Set the size of the command history, \n\
2918 ie. the number of previous commands to keep a record of.", &sethistlist
);
2919 add_show_from_set (c
, &showhistlist
);
2920 c
->function
.sfunc
= set_history_size_command
;
2923 (add_set_cmd ("filename", no_class
, var_filename
, (char *)&history_filename
,
2924 "Set the filename in which to record the command history\n\
2925 (the list of previous commands of which a record is kept).", &sethistlist
),
2929 (add_set_cmd ("confirm", class_support
, var_boolean
,
2931 "Set whether to confirm potentially dangerous operations.",
2935 add_prefix_cmd ("info", class_info
, info_command
,
2936 "Generic command for showing things about the program being debugged.",
2937 &infolist
, "info ", 0, &cmdlist
);
2938 add_com_alias ("i", "info", class_info
, 1);
2940 add_com ("complete", class_obscure
, complete_command
,
2941 "List the completions for the rest of the line as a command.");
2943 add_prefix_cmd ("show", class_info
, show_command
,
2944 "Generic command for showing things about the debugger.",
2945 &showlist
, "show ", 0, &cmdlist
);
2946 /* Another way to get at the same thing. */
2947 add_info ("set", show_command
, "Show all GDB settings.");
2949 add_cmd ("commands", no_class
, show_commands
,
2950 "Show the the history of commands you typed.\n\
2951 You can supply a command number to start with, or a `+' to start after\n\
2952 the previous command number shown.",
2955 add_cmd ("version", no_class
, show_version
,
2956 "Show what version of GDB this is.", &showlist
);
2958 /* If target is open when baud changes, it doesn't take effect until the
2959 next open (I think, not sure). */
2960 add_show_from_set (add_set_cmd ("remotebaud", no_class
,
2961 var_zinteger
, (char *)&baud_rate
,
2962 "Set baud rate for remote serial I/O.\n\
2963 This value is used to set the speed of the serial port when debugging\n\
2964 using remote targets.", &setlist
),
2968 add_set_cmd ("remotedebug", no_class
, var_zinteger
, (char *)&remote_debug
,
2969 "Set debugging of remote protocol.\n\
2970 When enabled, each packet sent or received with the remote target\n\
2971 is displayed.", &setlist
),