1 /* Top level `main' program for GDB, the GNU debugger.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
28 #include "breakpoint.h"
33 /* readline include files */
37 /* readline defines this. */
41 #include <sys/types.h>
50 #include <sys/param.h>
54 #ifdef SET_STACK_LIMIT_HUGE
56 #include <sys/resource.h>
58 int original_stack_limit
;
62 /* If this definition isn't overridden by the header files, assume
63 that isatty and fileno exist on this system. */
65 #define ISATTY(FP) (isatty (fileno (FP)))
68 /* Initialization file name for gdb. This is overridden in some configs. */
70 #ifndef GDBINIT_FILENAME
71 #define GDBINIT_FILENAME ".gdbinit"
73 char gdbinit
[] = GDBINIT_FILENAME
;
75 #define ALL_CLEANUPS ((struct cleanup *)0)
77 /* Version number of GDB, as a string. */
81 /* Message to be printed before the error message, when an error occurs. */
83 extern char *error_pre_print
;
85 extern char lang_frame_mismatch_warn
[]; /* language.c */
87 /* Whether GDB's stdin is on a terminal. */
89 extern int gdb_has_a_terminal
; /* inflow.c */
91 /* Flag for whether we want all the "from_tty" gubbish printed. */
93 int caution
= 1; /* Default is yes, sigh. */
96 * Define all cmd_list_element's
99 /* Chain containing all defined commands. */
101 struct cmd_list_element
*cmdlist
;
103 /* Chain containing all defined info subcommands. */
105 struct cmd_list_element
*infolist
;
107 /* Chain containing all defined enable subcommands. */
109 struct cmd_list_element
*enablelist
;
111 /* Chain containing all defined disable subcommands. */
113 struct cmd_list_element
*disablelist
;
115 /* Chain containing all defined delete subcommands. */
117 struct cmd_list_element
*deletelist
;
119 /* Chain containing all defined "enable breakpoint" subcommands. */
121 struct cmd_list_element
*enablebreaklist
;
123 /* Chain containing all defined set subcommands */
125 struct cmd_list_element
*setlist
;
127 /* Chain containing all defined show subcommands. */
128 struct cmd_list_element
*showlist
;
130 /* Chain containing all defined \"set history\". */
132 struct cmd_list_element
*sethistlist
;
134 /* Chain containing all defined \"show history\". */
135 struct cmd_list_element
*showhistlist
;
137 /* Chain containing all defined \"unset history\". */
139 struct cmd_list_element
*unsethistlist
;
141 /* stdio stream that command input is being read from. */
145 /* Current working directory. */
147 char *current_directory
;
149 /* The directory name is actually stored here (usually). */
150 static char dirbuf
[1024];
152 /* Function to call before reading a command, if nonzero.
153 The function receives two args: an input stream,
154 and a prompt string. */
156 void (*window_hook
) ();
158 extern int frame_file_full_name
;
162 /* The external commands we call... */
163 extern void init_source_path ();
164 extern void directory_command ();
165 extern void exec_file_command ();
166 extern void symbol_file_command ();
167 extern void core_file_command ();
168 extern void tty_command ();
170 extern void help_list ();
171 extern void initialize_all_files ();
172 extern void init_malloc ();
174 /* Forward declarations for this file */
175 void free_command_lines ();
176 char *gdb_readline ();
177 char *command_line_input ();
178 static void initialize_history ();
179 static void initialize_main ();
180 static void initialize_cmd_lists ();
181 static void init_signals ();
182 static void quit_command ();
183 void command_loop ();
184 static void source_command ();
185 static void print_gdb_version ();
186 static void print_gnu_advertisement ();
187 static void float_handler ();
188 static void cd_command ();
189 static void read_command_file ();
193 /* gdb prints this when reading a command interactively */
196 /* Buffer used for reading command lines, and the size
197 allocated for it so far. */
202 /* Baud rate specified for talking to serial target systems. Default
203 is left as a zero pointer, so targets can choose their own defaults. */
207 /* Signal to catch ^Z typed while reading a command: SIGTSTP or SIGCONT. */
211 #define STOP_SIGNAL SIGTSTP
215 /* Some System V have job control but not sigsetmask(). */
216 #if !defined (HAVE_SIGSETMASK)
217 #define HAVE_SIGSETMASK !defined (USG)
220 #if 0 == (HAVE_SIGSETMASK)
221 #define sigsetmask(n)
224 /* This is how `error' returns to command level. */
226 jmp_buf to_top_level
;
229 return_to_top_level ()
233 bpstat_clear_actions(stop_bpstat
); /* Clear queued breakpoint commands */
234 clear_momentary_breakpoints ();
235 disable_current_display ();
236 do_cleanups (ALL_CLEANUPS
);
237 longjmp (to_top_level
, 1);
240 /* Call FUNC with arg ARGS, catching any errors.
241 If there is no error, return the value returned by FUNC.
242 If there is an error, print ERRSTRING, print the specific error message,
246 catch_errors (func
, args
, errstring
)
253 struct cleanup
*saved_cleanup_chain
;
254 char *saved_error_pre_print
;
256 saved_cleanup_chain
= save_cleanups ();
257 saved_error_pre_print
= error_pre_print
;
259 bcopy (to_top_level
, saved
, sizeof (jmp_buf));
260 error_pre_print
= errstring
;
262 if (setjmp (to_top_level
) == 0)
263 val
= (*func
) (args
);
267 restore_cleanups (saved_cleanup_chain
);
269 error_pre_print
= saved_error_pre_print
;
270 bcopy (saved
, to_top_level
, sizeof (jmp_buf));
274 /* Handler for SIGHUP. */
279 kill_inferior_fast ();
280 signal (SIGHUP
, SIG_DFL
);
281 kill (getpid (), SIGHUP
);
284 /* Clean up on error during a "source" command (or execution of a
285 user-defined command). */
288 source_cleanup (stream
)
291 /* Restore the previous input stream. */
295 /* Read commands from STREAM. */
297 read_command_file (stream
)
300 struct cleanup
*cleanups
;
302 cleanups
= make_cleanup (source_cleanup
, instream
);
305 do_cleanups (cleanups
);
314 static int inhibit_gdbinit
= 0;
315 static int quiet
= 0;
316 static int batch
= 0;
318 /* Pointers to various arguments from command line. */
320 char *execarg
= NULL
;
321 char *corearg
= NULL
;
325 /* Pointers to all arguments of +command option. */
327 /* Allocated size of cmdarg. */
329 /* Number of elements of cmdarg used. */
332 /* Indices of all arguments of +directory option. */
334 /* Allocated size. */
336 /* Number of elements used. */
341 /* This needs to happen before the first use of malloc. */
344 #if defined (ALIGN_STACK_ON_STARTUP)
345 i
= (int) &count
& 0x3;
350 /* If error() is called from initialization code, just exit */
351 if (setjmp (to_top_level
)) {
356 cmdarg
= (char **) xmalloc (cmdsize
* sizeof (*cmdarg
));
359 dirarg
= (char **) xmalloc (dirsize
* sizeof (*dirarg
));
363 line
= (char *) xmalloc (linesize
);
364 line
[0] = '\0'; /* Terminate saved (now empty) cmd line */
367 getcwd (dirbuf
, sizeof (dirbuf
));
368 current_directory
= dirbuf
;
370 #ifdef SET_STACK_LIMIT_HUGE
374 /* Set the stack limit huge so that alloca (particularly stringtab
375 * in dbxread.c) does not fail. */
376 getrlimit (RLIMIT_STACK
, &rlim
);
377 original_stack_limit
= rlim
.rlim_cur
;
378 rlim
.rlim_cur
= rlim
.rlim_max
;
379 setrlimit (RLIMIT_STACK
, &rlim
);
381 #endif /* SET_STACK_LIMIT_HUGE */
383 /* Parse arguments and options. */
386 static int print_help
;
387 /* When var field is 0, use flag field to record the equivalent
388 short option (or arbitrary numbers starting at 10 for those
389 with no equivalent). */
390 static struct option long_options
[] =
392 {"quiet", no_argument
, &quiet
, 1},
393 {"q", no_argument
, &quiet
, 1},
394 {"nx", no_argument
, &inhibit_gdbinit
, 1},
395 {"n", no_argument
, &inhibit_gdbinit
, 1},
396 {"batch", no_argument
, &batch
, 1},
397 {"epoch", no_argument
, &epoch_interface
, 1},
398 {"fullname", no_argument
, &frame_file_full_name
, 1},
399 {"f", no_argument
, &frame_file_full_name
, 1},
400 {"help", no_argument
, &print_help
, 1},
401 {"se", required_argument
, 0, 10},
402 {"symbols", required_argument
, 0, 's'},
403 {"s", required_argument
, 0, 's'},
404 {"exec", required_argument
, 0, 'e'},
405 {"e", required_argument
, 0, 'e'},
406 {"core", required_argument
, 0, 'c'},
407 {"c", required_argument
, 0, 'c'},
408 {"command", required_argument
, 0, 'x'},
409 {"x", required_argument
, 0, 'x'},
410 {"directory", required_argument
, 0, 'd'},
411 {"cd", required_argument
, 0, 11},
412 {"tty", required_argument
, 0, 't'},
413 {"baud", required_argument
, 0, 'b'},
414 {"b", required_argument
, 0, 'b'},
415 /* Allow machine descriptions to add more options... */
416 #ifdef ADDITIONAL_OPTIONS
419 {0, no_argument
, 0, 0},
426 c
= getopt_long_only (argc
, argv
, "",
427 long_options
, &option_index
);
431 /* Long option that takes an argument. */
432 if (c
== 0 && long_options
[option_index
].flag
== 0)
433 c
= long_options
[option_index
].val
;
438 /* Long option that just sets a flag. */
457 cmdarg
[ncmd
++] = optarg
;
461 cmdarg
= (char **) xrealloc ((char *)cmdarg
,
462 cmdsize
* sizeof (*cmdarg
));
466 dirarg
[ndir
++] = optarg
;
470 dirarg
= (char **) xrealloc ((char *)dirarg
,
471 dirsize
* sizeof (*dirarg
));
483 #ifdef ADDITIONAL_OPTION_CASES
484 ADDITIONAL_OPTION_CASES
488 "Use `%s +help' for a complete list of options.\n",
497 This is GDB, the GNU debugger. Use the command\n\
498 gdb [options] [executable [core-file]]\n\
499 to enter the debugger.\n\
501 Options available are:\n\
502 -help Print this message.\n\
503 -quiet Do not print version number on startup.\n\
504 -fullname Output information used by emacs-GDB interface.\n\
505 -epoch Output information used by epoch emacs-GDB interface.\n\
506 -batch Exit after processing options.\n\
507 -nx Do not read .gdbinit file.\n\
508 -tty=TTY Use TTY for input/output by the program being debugged.\n\
509 -cd=DIR Change current directory to DIR.\n\
510 -directory=DIR Search for source files in DIR.\n\
511 -command=FILE Execute GDB commands from FILE.\n\
512 -symbols=SYMFILE Read symbols from SYMFILE.\n\
513 -exec=EXECFILE Use EXECFILE as the executable.\n\
514 -se=FILE Use FILE as symbol file and executable file.\n\
515 -core=COREFILE Analyze the core dump COREFILE.\n\
516 -b BAUDRATE Set serial port baud rate used for remote debugging\n\
518 #ifdef ADDITIONAL_OPTION_HELP
519 fputs (ADDITIONAL_OPTION_HELP
, stderr
);
522 For more information, type \"help\" from within GDB, or consult the\n\
523 GDB manual (available as on-line info or a printed manual).\n", stderr
);
524 /* Exiting after printing this message seems like
525 the most useful thing to do. */
529 /* OK, that's all the options. The other arguments are filenames. */
531 for (; optind
< argc
; optind
++)
535 symarg
= argv
[optind
];
536 execarg
= argv
[optind
];
539 corearg
= argv
[optind
];
543 "Excess command line arguments ignored. (%s%s)\n",
544 argv
[optind
], (optind
== argc
- 1) ? "" : " ...");
551 /* Run the init function of each source file */
553 initialize_cmd_lists (); /* This needs to be done first */
554 initialize_all_files ();
555 initialize_main (); /* But that omits this file! Do it now */
560 /* Print all the junk at the top, with trailing "..." if we are about
561 to read a symbol file (possibly slowly). */
562 print_gnu_advertisement ();
563 print_gdb_version ();
565 printf_filtered ("..");
567 fflush (stdout
); /* Force to screen during slow operations */
570 error_pre_print
= "\n\n";
572 /* Now perform all the actions indicated by the arguments. */
575 if (!setjmp (to_top_level
))
577 cd_command (cdarg
, 0);
581 do_cleanups (ALL_CLEANUPS
);
583 for (i
= 0; i
< ndir
; i
++)
584 if (!setjmp (to_top_level
))
585 directory_command (dirarg
[i
], 0);
587 do_cleanups (ALL_CLEANUPS
);
591 && strcmp (execarg
, symarg
) == 0)
593 /* The exec file and the symbol-file are the same. If we can't open
594 it, better only print one error message. */
595 if (!setjmp (to_top_level
))
597 exec_file_command (execarg
, !batch
);
598 symbol_file_command (symarg
, 0);
604 if (!setjmp (to_top_level
))
605 exec_file_command (execarg
, !batch
);
607 if (!setjmp (to_top_level
))
608 symbol_file_command (symarg
, 0);
610 do_cleanups (ALL_CLEANUPS
);
612 /* After the symbol file has been read, print a newline to get us
613 beyond the copyright line... But errors should still set off
614 the error message with a (single) blank line. */
616 printf_filtered ("\n");
617 error_pre_print
= "\n";
619 /* Set the initial language. */
621 extern enum language
deduce_language_from_filename ();
622 extern struct partial_symtab
*find_main_psymtab ();
623 struct partial_symtab
*pst
= find_main_psymtab ();
624 enum language lang
= language_unknown
;
627 /* A better solution would set the language when reading the psymtab.
628 This would win for symbol file formats that encode the langauge,
629 such as dwarf. But, we don't do that yet. FIXME */
630 else if (pst
->language
!= language_unknown
)
631 lang
= pst
->language
;
633 else if (pst
->filename
!= NULL
)
634 lang
= deduce_language_from_filename (pst
->filename
);
635 if (lang
== language_unknown
) /* Make C the default language */
641 if (!setjmp (to_top_level
))
642 core_file_command (corearg
, !batch
);
643 else if (isdigit (corearg
[0]) && !setjmp (to_top_level
))
644 attach_command (corearg
, !batch
);
645 do_cleanups (ALL_CLEANUPS
);
648 if (!setjmp (to_top_level
))
649 tty_command (ttyarg
, !batch
);
650 do_cleanups (ALL_CLEANUPS
);
652 #ifdef ADDITIONAL_OPTION_HANDLER
653 ADDITIONAL_OPTION_HANDLER
;
656 /* Error messages should no longer be distinguished with extra output. */
660 struct stat homebuf
, cwdbuf
;
661 char *homedir
, *homeinit
;
663 /* Read init file, if it exists in home directory */
664 homedir
= getenv ("HOME");
667 homeinit
= (char *) alloca (strlen (getenv ("HOME")) +
668 strlen (gdbinit
) + 10);
669 strcpy (homeinit
, getenv ("HOME"));
670 strcat (homeinit
, "/");
671 strcat (homeinit
, gdbinit
);
672 if (!inhibit_gdbinit
&& access (homeinit
, R_OK
) == 0)
673 if (!setjmp (to_top_level
))
674 source_command (homeinit
, 0);
675 do_cleanups (ALL_CLEANUPS
);
677 /* Do stats; no need to do them elsewhere since we'll only
678 need them if homedir is set. Make sure that they are
679 zero in case one of them fails (this guarantees that they
680 won't match if either exists). */
682 bzero (&homebuf
, sizeof (struct stat
));
683 bzero (&cwdbuf
, sizeof (struct stat
));
685 stat (homeinit
, &homebuf
);
686 stat (gdbinit
, &cwdbuf
); /* We'll only need this if
690 /* Read the input file in the current directory, *if* it isn't
691 the same file (it should exist, also). */
694 || bcmp ((char *) &homebuf
,
696 sizeof (struct stat
)))
697 if (!inhibit_gdbinit
&& access (gdbinit
, R_OK
) == 0)
698 if (!setjmp (to_top_level
))
699 source_command (gdbinit
, 0);
700 do_cleanups (ALL_CLEANUPS
);
703 for (i
= 0; i
< ncmd
; i
++)
704 if (!setjmp (to_top_level
))
706 if (cmdarg
[i
][0] == '-' && cmdarg
[i
][1] == '\0')
707 read_command_file (stdin
);
709 source_command (cmdarg
[i
], !batch
);
710 do_cleanups (ALL_CLEANUPS
);
714 /* Read in the old history after all the command files have been read. */
715 initialize_history();
719 /* We have hit the end of the batch file. */
723 /* Do any host- or target-specific hacks. This is used for i960 targets
724 to force the user to set a nindy target and spec its parameters. */
726 #ifdef BEFORE_MAIN_LOOP_HOOK
727 BEFORE_MAIN_LOOP_HOOK
;
730 /* The command loop. */
734 if (!setjmp (to_top_level
))
736 do_cleanups (ALL_CLEANUPS
); /* Do complete cleanup */
738 quit_command ((char *)0, instream
== stdin
);
741 /* No exit -- exit is through quit_command. */
744 /* Execute the line P as a command.
745 Pass FROM_TTY as second argument to the defining function. */
748 execute_command (p
, from_tty
)
752 register struct cmd_list_element
*c
;
753 register struct command_line
*cmdlines
;
754 register enum language flang
;
755 static const struct language_defn
*saved_language
= 0;
756 static int warned
= 0;
760 /* This can happen when command_line_input hits end of file. */
764 while (*p
== ' ' || *p
== '\t') p
++;
769 c
= lookup_cmd (&p
, cmdlist
, "", 0, 1);
770 /* Pass null arg rather than an empty one. */
772 if (c
->class == class_user
)
774 struct cleanup
*old_chain
;
777 error ("User-defined commands cannot take arguments.");
778 cmdlines
= c
->user_commands
;
783 /* Set the instream to 0, indicating execution of a
784 user-defined function. */
785 old_chain
= make_cleanup (source_cleanup
, instream
);
786 instream
= (FILE *) 0;
789 execute_command (cmdlines
->line
, 0);
790 cmdlines
= cmdlines
->next
;
792 do_cleanups (old_chain
);
794 else if (c
->type
== set_cmd
|| c
->type
== show_cmd
)
795 do_setshow_command (arg
, from_tty
& caution
, c
);
796 else if (c
->function
== NO_FUNCTION
)
797 error ("That is not a command, just a help topic.");
799 (*c
->function
) (arg
, from_tty
& caution
);
802 /* Tell the user if the language has changed (except first time). */
803 if (current_language
!= saved_language
)
805 if (language_mode
== language_mode_auto
) {
807 language_info (1); /* Print what changed. */
809 saved_language
= current_language
;
813 /* Warn the user if the working language does not match the
814 language of the current frame. Only warn the user if we are
815 actually running the program, i.e. there is a stack. */
816 /* FIXME: This should be cacheing the frame and only running when
817 the frame changes. */
818 if (target_has_stack
)
820 flang
= get_frame_language ();
822 && flang
!= language_unknown
823 && flang
!= current_language
->la_language
)
825 printf_filtered ("%s\n", lang_frame_mismatch_warn
);
833 command_loop_marker (foo
)
838 /* Read commands from `instream' and execute them
839 until end of file or error reading instream. */
843 struct cleanup
*old_chain
;
845 int stdin_is_tty
= ISATTY (stdin
);
847 while (!feof (instream
))
849 if (window_hook
&& instream
== stdin
)
850 (*window_hook
) (instream
, prompt
);
853 if (instream
== stdin
&& stdin_is_tty
)
854 reinitialize_more_filter ();
855 old_chain
= make_cleanup (command_loop_marker
, 0);
856 command
= command_line_input (instream
== stdin
? prompt
: 0,
860 execute_command (command
, instream
== stdin
);
861 /* Do any commands attached to breakpoint we stopped at. */
862 bpstat_do_actions (&stop_bpstat
);
863 do_cleanups (old_chain
);
867 /* Commands call this if they do not want to be repeated by null lines. */
872 /* If we aren't reading from standard input, we are saving the last
873 thing read from stdin in line and don't want to delete it. Null lines
874 won't repeat here in any case. */
875 if (instream
== stdin
)
879 /* Read a line from the stream "instream" without command line editing.
881 It prints PRROMPT once at the start.
882 Action is compatible with "readline", e.g. space for the result is
883 malloc'd and should be freed by the caller.
885 A NULL return means end of file. */
887 gdb_readline (prrompt
)
893 int result_size
= 80;
901 result
= (char *) xmalloc (result_size
);
905 /* Read from stdin if we are executing a user defined command.
906 This is the right thing for prompt_for_continue, at least. */
907 c
= fgetc (instream
? instream
: stdin
);
918 result
[input_index
++] = c
;
919 while (input_index
>= result_size
)
922 result
= (char *) xrealloc (result
, result_size
);
926 result
[input_index
++] = '\0';
930 /* Declaration for fancy readline with command line editing. */
933 /* Variables which control command line editing and history
934 substitution. These variables are given default values at the end
936 static int command_editing_p
;
937 static int history_expansion_p
;
938 static int write_history_p
;
939 static int history_size
;
940 static char *history_filename
;
942 /* Variables which are necessary for fancy command line editing. */
943 char *gdb_completer_word_break_characters
=
944 " \t\n!@#$%^&*()-+=|~`}{[]\"';:?/>.<,";
946 /* Functions that are used as part of the fancy command line editing. */
948 /* This can be used for functions which don't want to complete on symbols
949 but don't want to complete on anything else either. */
952 noop_completer (text
)
958 /* Generate symbol names one by one for the completer. If STATE is
959 zero, then we need to initialize, otherwise the initialization has
960 already taken place. TEXT is what we expect the symbol to start
961 with. RL_LINE_BUFFER is available to be looked at; it contains the
962 entire text of the line. RL_POINT is the offset in that line of
963 the cursor. You should pretend that the line ends at RL_POINT.
964 The result is NULL if there are no more completions, else a char
965 string which is a possible completion. */
967 symbol_completion_function (text
, state
)
971 static char **list
= (char **)NULL
;
974 extern char *rl_line_buffer
;
976 char *tmp_command
, *p
;
977 struct cmd_list_element
*c
, *result_list
;
981 /* Free the storage used by LIST, but not by the strings inside. This is
982 because rl_complete_internal () frees the strings. */
988 /* Decide whether to complete on a list of gdb commands or on
990 tmp_command
= (char *) alloca (rl_point
+ 1);
993 strncpy (tmp_command
, rl_line_buffer
, rl_point
);
994 tmp_command
[rl_point
] = '\0';
998 /* An empty line we want to consider ambiguous; that is,
999 it could be any command. */
1000 c
= (struct cmd_list_element
*) -1;
1004 c
= lookup_cmd_1 (&p
, cmdlist
, &result_list
, 1);
1006 /* Move p up to the next interesting thing. */
1007 while (*p
== ' ' || *p
== '\t')
1011 /* He's typed something unrecognizable. Sigh. */
1013 else if (c
== (struct cmd_list_element
*) -1)
1015 /* If we didn't recognize everything up to the thing that
1016 needs completing, and we don't know what command it is
1017 yet, we are in trouble. Part of the trouble might be
1018 that the list of delimiters used by readline includes
1019 '-', which we use in commands. Check for this. */
1020 if (p
+ strlen(text
) != tmp_command
+ rl_point
) {
1021 if (tmp_command
[rl_point
- strlen(text
) - 1] == '-')
1024 /* This really should not produce an error. Better would
1025 be to pretend to hit RETURN here; this would produce a
1026 response like "Ambiguous command: foo, foobar, etc",
1027 and leave the line available for re-entry with ^P. Instead,
1028 this error blows away the user's typed input without
1029 any way to get it back. */
1030 error (" Unrecognized command.");
1034 /* He's typed something ambiguous. This is easier. */
1036 list
= complete_on_cmdlist (*result_list
->prefixlist
, text
);
1038 list
= complete_on_cmdlist (cmdlist
, text
);
1042 /* If we've gotten this far, gdb has recognized a full
1043 command. There are several possibilities:
1045 1) We need to complete on the command.
1046 2) We need to complete on the possibilities coming after
1048 2) We need to complete the text of what comes after the
1052 /* Always (might be longer versions of thie command). */
1053 list
= complete_on_cmdlist (result_list
, text
);
1054 else if (!*p
&& !*text
)
1057 list
= complete_on_cmdlist (*c
->prefixlist
, "");
1059 list
= (*c
->completer
) ("");
1063 if (c
->prefixlist
&& !c
->allow_unknown
)
1066 /* Something like "info adsfkdj". But error() is not
1067 the proper response; just return no completions
1070 error ("\"%s\" command requires a subcommand.",
1077 list
= (*c
->completer
) (text
);
1082 /* If the debugged program wasn't compiled with symbols, or if we're
1083 clearly completing on a command and no command matches, return
1086 return ((char *)NULL
);
1088 output
= list
[index
];
1099 #if STOP_SIGNAL == SIGTSTP
1100 signal (SIGTSTP
, SIG_DFL
);
1102 kill (getpid (), SIGTSTP
);
1103 signal (SIGTSTP
, stop_sig
);
1105 signal (STOP_SIGNAL
, stop_sig
);
1107 printf ("%s", prompt
);
1110 /* Forget about any previous command -- null line now will do nothing. */
1113 #endif /* STOP_SIGNAL */
1115 /* Initialize signal handlers. */
1124 extern void request_quit ();
1126 signal (SIGINT
, request_quit
);
1128 /* If we initialize SIGQUIT to SIG_IGN, then the SIG_IGN will get
1129 passed to the inferior, which we don't want. It would be
1130 possible to do a "signal (SIGQUIT, SIG_DFL)" after we fork, but
1131 on BSD4.3 systems using vfork, that can affect the
1132 GDB process as well as the inferior (the signal handling tables
1133 might be in memory, shared between the two). Since we establish
1134 a handler for SIGQUIT, when we call exec it will set the signal
1135 to SIG_DFL for us. */
1136 signal (SIGQUIT
, do_nothing
);
1137 if (signal (SIGHUP
, do_nothing
) != SIG_IGN
)
1138 signal (SIGHUP
, disconnect
);
1139 signal (SIGFPE
, float_handler
);
1142 /* Read one line from the command input stream `instream'
1143 into the local static buffer `linebuffer' (whose current length
1145 The buffer is made bigger as necessary.
1146 Returns the address of the start of the line.
1148 NULL is returned for end of file.
1150 *If* the instream == stdin & stdin is a terminal, the line read
1151 is copied into the file line saver (global var char *line,
1152 length linesize) so that it can be duplicated.
1154 This routine either uses fancy command line editing or
1155 simple input as the user has requested. */
1158 command_line_input (prrompt
, repeat
)
1162 static char *linebuffer
= 0;
1163 static int linelength
= 0;
1167 char *local_prompt
= prrompt
;
1172 if (linebuffer
== 0)
1175 linebuffer
= (char *) xmalloc (linelength
);
1180 /* Control-C quits instantly if typed while in this loop
1181 since it should not wait until the user types a newline. */
1184 signal (STOP_SIGNAL
, stop_sig
);
1189 /* Reports are that some Sys V's don't flush stdout/err on reads
1190 from stdin, when stdin/out are sockets rather than ttys. So we
1191 have to do it ourselves, to make emacs-gdb and xxgdb work.
1192 On other machines, doing this once per input should be a cheap nop. */
1196 /* Don't use fancy stuff if not talking to stdin. */
1197 if (command_editing_p
&& instream
== stdin
1198 && ISATTY (instream
))
1199 rl
= readline (local_prompt
);
1201 rl
= gdb_readline (local_prompt
);
1203 if (!rl
|| rl
== (char *) EOF
)
1208 if (strlen(rl
) + 1 + (p
- linebuffer
) > linelength
)
1210 linelength
= strlen(rl
) + 1 + (p
- linebuffer
);
1211 nline
= (char *) xrealloc (linebuffer
, linelength
);
1212 p
+= nline
- linebuffer
;
1216 /* Copy line. Don't copy null at end. (Leaves line alone
1217 if this was just a newline) */
1221 free (rl
); /* Allocated in readline. */
1223 if (p
== linebuffer
|| *(p
- 1) != '\\')
1226 p
--; /* Put on top of '\'. */
1227 local_prompt
= (char *) 0;
1231 signal (SIGTSTP
, SIG_DFL
);
1238 /* Do history expansion if that is wished. */
1239 if (history_expansion_p
&& instream
== stdin
1240 && ISATTY (instream
))
1242 char *history_value
;
1245 *p
= '\0'; /* Insert null now. */
1246 expanded
= history_expand (linebuffer
, &history_value
);
1249 /* Print the changes. */
1250 printf ("%s\n", history_value
);
1252 /* If there was an error, call this function again. */
1255 free (history_value
);
1256 return command_line_input (prrompt
, repeat
);
1258 if (strlen (history_value
) > linelength
)
1260 linelength
= strlen (history_value
) + 1;
1261 linebuffer
= (char *) xrealloc (linebuffer
, linelength
);
1263 strcpy (linebuffer
, history_value
);
1264 p
= linebuffer
+ strlen(linebuffer
);
1265 free (history_value
);
1269 /* If we just got an empty line, and that is supposed
1270 to repeat the previous command, return the value in the
1274 if (p
== linebuffer
)
1277 while (*p1
== ' ' || *p1
== '\t')
1285 /* Add line to history if appropriate. */
1286 if (instream
== stdin
1287 && ISATTY (stdin
) && *linebuffer
)
1288 add_history (linebuffer
);
1290 /* Note: lines consisting soley of comments are added to the command
1291 history. This is useful when you type a command, and then
1292 realize you don't want to execute it quite yet. You can comment
1293 out the command and then later fetch it from the value history
1294 and remove the '#'. The kill ring is probably better, but some
1295 people are in the habit of commenting things out. */
1297 while ((c
= *p1
++) != '\0')
1300 while ((c
= *p1
++) != '"')
1302 /* Make sure an escaped '"' doesn't make us think the string
1310 while ((c
= *p1
++) != '\'')
1312 /* Make sure an escaped '\'' doesn't make us think the string
1321 /* Found a comment. */
1327 /* Save into global buffer if appropriate. */
1330 if (linelength
> linesize
)
1332 line
= xrealloc (line
, linelength
);
1333 linesize
= linelength
;
1335 strcpy (line
, linebuffer
);
1342 /* Read lines from the input stream
1343 and accumulate them in a chain of struct command_line's
1344 which is then returned. */
1346 struct command_line
*
1347 read_command_lines ()
1349 struct command_line
*first
= 0;
1350 register struct command_line
*next
, *tail
= 0;
1351 register char *p
, *p1
;
1352 struct cleanup
*old_chain
= 0;
1357 p
= command_line_input (0, instream
== stdin
);
1359 /* Treat end of file like "end". */
1362 /* Remove leading and trailing blanks. */
1363 while (*p
== ' ' || *p
== '\t') p
++;
1364 p1
= p
+ strlen (p
);
1365 while (p1
!= p
&& (p1
[-1] == ' ' || p1
[-1] == '\t')) p1
--;
1367 /* Is this "end"? */
1368 if (p1
- p
== 3 && !strncmp (p
, "end", 3))
1371 /* No => add this line to the chain of command lines. */
1372 next
= (struct command_line
*) xmalloc (sizeof (struct command_line
));
1373 next
->line
= savestring (p
, p1
- p
);
1381 /* We just read the first line.
1382 From now on, arrange to throw away the lines we have
1383 if we quit or get an error while inside this function. */
1385 old_chain
= make_cleanup (free_command_lines
, &first
);
1392 /* Now we are about to return the chain to our caller,
1393 so freeing it becomes his responsibility. */
1395 discard_cleanups (old_chain
);
1399 /* Free a chain of struct command_line's. */
1402 free_command_lines (lptr
)
1403 struct command_line
**lptr
;
1405 register struct command_line
*l
= *lptr
;
1406 register struct command_line
*next
;
1417 /* Add an element to the list of info subcommands. */
1420 add_info (name
, fun
, doc
)
1425 add_cmd (name
, no_class
, fun
, doc
, &infolist
);
1428 /* Add an alias to the list of info subcommands. */
1431 add_info_alias (name
, oldname
, abbrev_flag
)
1436 add_alias_cmd (name
, oldname
, 0, abbrev_flag
, &infolist
);
1439 /* The "info" command is defined as a prefix, with allow_unknown = 0.
1440 Therefore, its own definition is called only for "info" with no args. */
1444 info_command (arg
, from_tty
)
1448 printf ("\"info\" must be followed by the name of an info command.\n");
1449 help_list (infolist
, "info ", -1, stdout
);
1452 /* The "show" command with no arguments shows all the settings. */
1456 show_command (arg
, from_tty
)
1460 cmd_show_list (showlist
, from_tty
, "");
1463 /* Add an element to the list of commands. */
1466 add_com (name
, class, fun
, doc
)
1468 enum command_class
class;
1472 add_cmd (name
, class, fun
, doc
, &cmdlist
);
1475 /* Add an alias or abbreviation command to the list of commands. */
1478 add_com_alias (name
, oldname
, class, abbrev_flag
)
1481 enum command_class
class;
1484 add_alias_cmd (name
, oldname
, class, abbrev_flag
, &cmdlist
);
1491 error ("Argument required (%s).", why
);
1496 help_command (command
, from_tty
)
1498 int from_tty
; /* Ignored */
1500 help_cmd (command
, stdout
);
1504 validate_comname (comname
)
1510 error_no_arg ("name of command to define");
1515 if (!(*p
>= 'A' && *p
<= 'Z')
1516 && !(*p
>= 'a' && *p
<= 'z')
1517 && !(*p
>= '0' && *p
<= '9')
1519 error ("Junk in argument list: \"%s\"", p
);
1525 define_command (comname
, from_tty
)
1529 register struct command_line
*cmds
;
1530 register struct cmd_list_element
*c
, *newc
;
1531 char *tem
= comname
;
1532 extern void not_just_help_class_command ();
1534 validate_comname (comname
);
1536 /* Look it up, and verify that we got an exact match. */
1537 c
= lookup_cmd (&tem
, cmdlist
, "", -1, 1);
1538 if (c
&& 0 != strcmp (comname
, c
->name
))
1543 if (c
->class == class_user
|| c
->class == class_alias
)
1544 tem
= "Redefine command \"%s\"? ";
1546 tem
= "Really redefine built-in command \"%s\"? ";
1547 if (!query (tem
, comname
))
1548 error ("Command \"%s\" not redefined.", comname
);
1553 printf ("Type commands for definition of \"%s\".\n\
1554 End with a line saying just \"end\".\n", comname
);
1557 comname
= savestring (comname
, strlen (comname
));
1559 cmds
= read_command_lines ();
1561 if (c
&& c
->class == class_user
)
1562 free_command_lines (&c
->user_commands
);
1564 newc
= add_cmd (comname
, class_user
, not_just_help_class_command
,
1565 (c
&& c
->class == class_user
)
1566 ? c
->doc
: savestring ("User-defined.", 13), &cmdlist
);
1567 newc
->user_commands
= cmds
;
1571 document_command (comname
, from_tty
)
1575 struct command_line
*doclines
;
1576 register struct cmd_list_element
*c
;
1577 char *tem
= comname
;
1579 validate_comname (comname
);
1581 c
= lookup_cmd (&tem
, cmdlist
, "", 0, 1);
1583 if (c
->class != class_user
)
1584 error ("Command \"%s\" is built-in.", comname
);
1587 printf ("Type documentation for \"%s\".\n\
1588 End with a line saying just \"end\".\n", comname
);
1590 doclines
= read_command_lines ();
1592 if (c
->doc
) free (c
->doc
);
1595 register struct command_line
*cl1
;
1596 register int len
= 0;
1598 for (cl1
= doclines
; cl1
; cl1
= cl1
->next
)
1599 len
+= strlen (cl1
->line
) + 1;
1601 c
->doc
= (char *) xmalloc (len
+ 1);
1604 for (cl1
= doclines
; cl1
; cl1
= cl1
->next
)
1606 strcat (c
->doc
, cl1
->line
);
1608 strcat (c
->doc
, "\n");
1612 free_command_lines (&doclines
);
1616 print_gnu_advertisement()
1619 GDB is free software and you are welcome to distribute copies of it\n\
1620 under certain conditions; type \"show copying\" to see the conditions.\n\
1621 There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\
1626 print_gdb_version ()
1629 GDB %s, Copyright 1992 Free Software Foundation, Inc.",
1635 show_version (args
, from_tty
)
1640 print_gnu_advertisement ();
1641 print_gdb_version ();
1642 printf_filtered ("\n");
1646 /* xgdb calls this to reprint the usual GDB prompt. */
1651 printf ("%s", prompt
);
1656 quit_command (args
, from_tty
)
1660 if (inferior_pid
!= 0 && target_has_execution
)
1662 if (query ("The program is running. Quit anyway? "))
1667 error ("Not confirmed.");
1669 /* Save the history information if it is appropriate to do so. */
1670 if (write_history_p
&& history_filename
)
1671 write_history (history_filename
);
1675 /* Returns whether GDB is running on a terminal and whether the user
1676 desires that questions be asked of them on that terminal. */
1679 input_from_terminal_p ()
1681 return gdb_has_a_terminal
&& (instream
== stdin
) & caution
;
1686 pwd_command (args
, from_tty
)
1690 if (args
) error ("The \"pwd\" command does not take an argument: %s", args
);
1691 getcwd (dirbuf
, sizeof (dirbuf
));
1693 if (strcmp (dirbuf
, current_directory
))
1694 printf ("Working directory %s\n (canonically %s).\n",
1695 current_directory
, dirbuf
);
1697 printf ("Working directory %s.\n", current_directory
);
1701 cd_command (dir
, from_tty
)
1708 /* If the new directory is absolute, repeat is a no-op; if relative,
1709 repeat might be useful but is more likely to be a mistake. */
1713 error_no_arg ("new working directory");
1715 dir
= tilde_expand (dir
);
1716 make_cleanup (free
, dir
);
1718 if (chdir (dir
) < 0)
1719 perror_with_name (dir
);
1722 dir
= savestring (dir
, len
- (len
> 1 && dir
[len
-1] == '/'));
1724 current_directory
= dir
;
1727 current_directory
= concat (current_directory
, "/", dir
, NULL
);
1731 /* Now simplify any occurrences of `.' and `..' in the pathname. */
1739 for (p
= current_directory
; *p
;)
1741 if (!strncmp (p
, "/./", 2)
1742 && (p
[2] == 0 || p
[2] == '/'))
1744 else if (!strncmp (p
, "/..", 3)
1745 && (p
[3] == 0 || p
[3] == '/')
1746 && p
!= current_directory
)
1749 while (q
!= current_directory
&& q
[-1] != '/') q
--;
1750 if (q
!= current_directory
)
1760 forget_cached_source_info ();
1763 pwd_command ((char *) 0, 1);
1768 source_command (args
, from_tty
)
1773 struct cleanup
*cleanups
;
1777 /* Let source without arguments read .gdbinit. */
1780 file
= tilde_expand (file
);
1781 make_cleanup (free
, file
);
1783 stream
= fopen (file
, "r");
1785 perror_with_name (file
);
1787 cleanups
= make_cleanup (fclose
, stream
);
1789 read_command_file (stream
);
1791 do_cleanups (cleanups
);
1796 echo_command (text
, from_tty
)
1808 /* \ at end of argument is used after spaces
1809 so they won't be lost. */
1813 c
= parse_escape (&p
);
1815 printf_filtered ("%c", c
);
1818 printf_filtered ("%c", c
);
1821 /* Force this output to appear now. */
1828 dump_me_command (args
, from_tty
)
1832 if (query ("Should GDB dump core? "))
1834 signal (SIGQUIT
, SIG_DFL
);
1835 kill (getpid (), SIGQUIT
);
1839 /* Functions to manipulate command line editing control variables. */
1841 /* Number of commands to print in each call to show_commands. */
1842 #define Hist_print 10
1844 show_commands (args
, from_tty
)
1848 /* Index for history commands. Relative to history_base. */
1851 /* Number of the history entry which we are planning to display next.
1852 Relative to history_base. */
1855 /* The first command in the history which doesn't exist (i.e. one more
1856 than the number of the last command). Relative to history_base. */
1859 struct _hist_entry
*history_get();
1860 extern int history_base
;
1862 /* Print out some of the commands from the command history. */
1863 /* First determine the length of the history list. */
1864 hist_len
= history_size
;
1865 for (offset
= 0; offset
< history_size
; offset
++)
1867 if (!history_get (history_base
+ offset
))
1876 if (args
[0] == '+' && args
[1] == '\0')
1877 /* "info editing +" should print from the stored position. */
1880 /* "info editing <exp>" should print around command number <exp>. */
1881 num
= (parse_and_eval_address (args
) - history_base
) - Hist_print
/ 2;
1883 /* "show commands" means print the last Hist_print commands. */
1886 num
= hist_len
- Hist_print
;
1892 /* If there are at least Hist_print commands, we want to display the last
1893 Hist_print rather than, say, the last 6. */
1894 if (hist_len
- num
< Hist_print
)
1896 num
= hist_len
- Hist_print
;
1901 for (offset
= num
; offset
< num
+ Hist_print
&& offset
< hist_len
; offset
++)
1903 printf_filtered ("%5d %s\n", history_base
+ offset
,
1904 (history_get (history_base
+ offset
))->line
);
1907 /* The next command we want to display is the next one that we haven't
1911 /* If the user repeats this command with return, it should do what
1912 "show commands +" does. This is unnecessary if arg is null,
1913 because "show commands +" is not useful after "show commands". */
1914 if (from_tty
&& args
)
1921 /* Called by do_setshow_command. */
1924 set_history_size_command (args
, from_tty
, c
)
1927 struct cmd_list_element
*c
;
1929 if (history_size
== UINT_MAX
)
1930 unstifle_history ();
1932 stifle_history (history_size
);
1937 set_history (args
, from_tty
)
1941 printf ("\"set history\" must be followed by the name of a history subcommand.\n");
1942 help_list (sethistlist
, "set history ", -1, stdout
);
1947 show_history (args
, from_tty
)
1951 cmd_show_list (showhistlist
, from_tty
, "");
1954 int info_verbose
= 0; /* Default verbose msgs off */
1956 /* Called by do_setshow_command. An elaborate joke. */
1959 set_verbose (args
, from_tty
, c
)
1962 struct cmd_list_element
*c
;
1964 char *cmdname
= "verbose";
1965 struct cmd_list_element
*showcmd
;
1967 showcmd
= lookup_cmd_1 (&cmdname
, showlist
, NULL
, 1);
1971 c
->doc
= "Set verbose printing of informational messages.";
1972 showcmd
->doc
= "Show verbose printing of informational messages.";
1976 c
->doc
= "Set verbosity.";
1977 showcmd
->doc
= "Show verbosity.";
1984 /* This message is based on ANSI C, section 4.7. Note that integer
1985 divide by zero causes this, so "float" is a misnomer. */
1986 error ("Erroneous arithmetic operation.");
1989 /* Return whether we are running a batch file or from terminal. */
1993 return !(instream
== stdin
&& ISATTY (stdin
));
1998 initialize_cmd_lists ()
2000 cmdlist
= (struct cmd_list_element
*) 0;
2001 infolist
= (struct cmd_list_element
*) 0;
2002 enablelist
= (struct cmd_list_element
*) 0;
2003 disablelist
= (struct cmd_list_element
*) 0;
2004 deletelist
= (struct cmd_list_element
*) 0;
2005 enablebreaklist
= (struct cmd_list_element
*) 0;
2006 setlist
= (struct cmd_list_element
*) 0;
2008 sethistlist
= (struct cmd_list_element
*) 0;
2009 showhistlist
= NULL
;
2010 unsethistlist
= (struct cmd_list_element
*) 0;
2013 /* Init the history buffer. Note that we are called after the init file(s)
2014 * have been read so that the user can change the history file via his
2015 * .gdbinit file (for instance). The GDBHISTFILE environment variable
2016 * overrides all of this.
2020 initialize_history()
2024 if (tmpenv
= getenv ("HISTSIZE"))
2025 history_size
= atoi (tmpenv
);
2026 else if (!history_size
)
2029 stifle_history (history_size
);
2031 if (tmpenv
= getenv ("GDBHISTFILE"))
2032 history_filename
= savestring (tmpenv
, strlen(tmpenv
));
2033 else if (!history_filename
) {
2034 /* We include the current directory so that if the user changes
2035 directories the file written will be the same as the one
2037 history_filename
= concat (current_directory
, "/.gdb_history", NULL
);
2039 read_history (history_filename
);
2045 struct cmd_list_element
*c
;
2047 #ifdef DEFAULT_PROMPT
2048 prompt
= savestring (DEFAULT_PROMPT
, strlen(DEFAULT_PROMPT
));
2050 prompt
= savestring ("(gdb) ", 6);
2053 /* Set the important stuff up for command editing. */
2054 command_editing_p
= 1;
2055 history_expansion_p
= 0;
2056 write_history_p
= 0;
2058 /* Setup important stuff for command line editing. */
2059 rl_completion_entry_function
= (int (*)()) symbol_completion_function
;
2060 rl_completer_word_break_characters
= gdb_completer_word_break_characters
;
2061 rl_readline_name
= "gdb";
2063 /* Define the classes of commands.
2064 They will appear in the help list in the reverse of this order. */
2066 add_cmd ("obscure", class_obscure
, NO_FUNCTION
, "Obscure features.", &cmdlist
);
2067 add_cmd ("aliases", class_alias
, NO_FUNCTION
, "Aliases of other commands.", &cmdlist
);
2068 add_cmd ("user-defined", class_user
, NO_FUNCTION
, "User-defined commands.\n\
2069 The commands in this class are those defined by the user.\n\
2070 Use the \"define\" command to define a command.", &cmdlist
);
2071 add_cmd ("support", class_support
, NO_FUNCTION
, "Support facilities.", &cmdlist
);
2072 add_cmd ("status", class_info
, NO_FUNCTION
, "Status inquiries.", &cmdlist
);
2073 add_cmd ("files", class_files
, NO_FUNCTION
, "Specifying and examining files.", &cmdlist
);
2074 add_cmd ("breakpoints", class_breakpoint
, NO_FUNCTION
, "Making program stop at certain points.", &cmdlist
);
2075 add_cmd ("data", class_vars
, NO_FUNCTION
, "Examining data.", &cmdlist
);
2076 add_cmd ("stack", class_stack
, NO_FUNCTION
, "Examining the stack.\n\
2077 The stack is made up of stack frames. Gdb assigns numbers to stack frames\n\
2078 counting from zero for the innermost (currently executing) frame.\n\n\
2079 At any time gdb identifies one frame as the \"selected\" frame.\n\
2080 Variable lookups are done with respect to the selected frame.\n\
2081 When the program being debugged stops, gdb selects the innermost frame.\n\
2082 The commands below can be used to select other frames by number or address.",
2084 add_cmd ("running", class_run
, NO_FUNCTION
, "Running the program.", &cmdlist
);
2086 add_com ("pwd", class_files
, pwd_command
,
2087 "Print working directory. This is used for your program as well.");
2088 add_com ("cd", class_files
, cd_command
,
2089 "Set working directory to DIR for debugger and program being debugged.\n\
2090 The change does not take effect for the program being debugged\n\
2091 until the next time it is started.");
2094 (add_set_cmd ("prompt", class_support
, var_string
, (char *)&prompt
,
2099 add_com ("echo", class_support
, echo_command
,
2100 "Print a constant string. Give string as argument.\n\
2101 C escape sequences may be used in the argument.\n\
2102 No newline is added at the end of the argument;\n\
2103 use \"\\n\" if you want a newline to be printed.\n\
2104 Since leading and trailing whitespace are ignored in command arguments,\n\
2105 if you want to print some you must use \"\\\" before leading whitespace\n\
2106 to be printed or after trailing whitespace.");
2107 add_com ("document", class_support
, document_command
,
2108 "Document a user-defined command.\n\
2109 Give command name as argument. Give documentation on following lines.\n\
2110 End with a line of just \"end\".");
2111 add_com ("define", class_support
, define_command
,
2112 "Define a new command name. Command name is argument.\n\
2113 Definition appears on following lines, one command per line.\n\
2114 End with a line of just \"end\".\n\
2115 Use the \"document\" command to give documentation for the new command.\n\
2116 Commands defined in this way do not take arguments.");
2119 add_com ("source", class_support
, source_command
,
2120 "Read commands from a file named FILE.\n\
2121 Note that the file \"" GDBINIT_FILENAME
"\" is read automatically in this way\n\
2122 when gdb is started.");
2124 /* Punt file name, we can't help it easily. */
2125 add_com ("source", class_support
, source_command
,
2126 "Read commands from a file named FILE.\n\
2127 Note that the file \".gdbinit\" is read automatically in this way\n\
2128 when gdb is started.");
2131 add_com ("quit", class_support
, quit_command
, "Exit gdb.");
2132 add_com ("help", class_support
, help_command
, "Print list of commands.");
2133 add_com_alias ("q", "quit", class_support
, 1);
2134 add_com_alias ("h", "help", class_support
, 1);
2137 c
= add_set_cmd ("verbose", class_support
, var_boolean
, (char *)&info_verbose
,
2140 add_show_from_set (c
, &showlist
);
2141 c
->function
= set_verbose
;
2142 set_verbose (NULL
, 0, c
);
2144 add_com ("dump-me", class_obscure
, dump_me_command
,
2145 "Get fatal error; make debugger dump its core.");
2148 (add_set_cmd ("editing", class_support
, var_boolean
, (char *)&command_editing_p
,
2149 "Set editing of command lines as they are typed.\n\
2150 Use \"on\" to enable to enable the editing, and \"off\" to disable it.\n\
2151 Without an argument, command line editing is enabled. To edit, use\n\
2152 EMACS-like or VI-like commands like control-P or ESC.", &setlist
),
2155 add_prefix_cmd ("history", class_support
, set_history
,
2156 "Generic command for setting command history parameters.",
2157 &sethistlist
, "set history ", 0, &setlist
);
2158 add_prefix_cmd ("history", class_support
, show_history
,
2159 "Generic command for showing command history parameters.",
2160 &showhistlist
, "show history ", 0, &showlist
);
2163 (add_set_cmd ("expansion", no_class
, var_boolean
, (char *)&history_expansion_p
,
2164 "Set history expansion on command input.\n\
2165 Without an argument, history expansion is enabled.", &sethistlist
),
2169 (add_set_cmd ("save", no_class
, var_boolean
, (char *)&write_history_p
,
2170 "Set saving of the history record on exit.\n\
2171 Use \"on\" to enable to enable the saving, and \"off\" to disable it.\n\
2172 Without an argument, saving is enabled.", &sethistlist
),
2175 c
= add_set_cmd ("size", no_class
, var_uinteger
, (char *)&history_size
,
2176 "Set the size of the command history, \n\
2177 ie. the number of previous commands to keep a record of.", &sethistlist
);
2178 add_show_from_set (c
, &showhistlist
);
2179 c
->function
= set_history_size_command
;
2182 (add_set_cmd ("filename", no_class
, var_filename
, (char *)&history_filename
,
2183 "Set the filename in which to record the command history\n\
2184 (the list of previous commands of which a record is kept).", &sethistlist
),
2188 (add_set_cmd ("confirm", class_support
, var_boolean
,
2190 "Set whether to confirm potentially dangerous operations.",
2194 add_prefix_cmd ("info", class_info
, info_command
,
2195 "Generic command for showing things about the program being debugged.",
2196 &infolist
, "info ", 0, &cmdlist
);
2197 add_com_alias ("i", "info", class_info
, 1);
2199 add_prefix_cmd ("show", class_info
, show_command
,
2200 "Generic command for showing things about the debugger.",
2201 &showlist
, "show ", 0, &cmdlist
);
2202 /* Another way to get at the same thing. */
2203 add_info ("set", show_command
, "Show all GDB settings.");
2205 add_cmd ("commands", no_class
, show_commands
,
2206 "Show the the history of commands you typed.\n\
2207 You can supply a command number to start with, or a `+' to start after\n\
2208 the previous command number shown.",
2211 add_cmd ("version", no_class
, show_version
,
2212 "Show what version of GDB this is.", &showlist
);