1 /* Top level `main' program for GDB, the GNU debugger.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991 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>
48 #include <sys/param.h>
52 #ifdef SET_STACK_LIMIT_HUGE
54 #include <sys/resource.h>
56 int original_stack_limit
;
60 /* If this definition isn't overridden by the header files, assume
61 that isatty and fileno exist on this system. */
63 #define ISATTY(FP) (isatty (fileno (FP)))
66 /* Initialization file name for gdb. This is overridden in some configs. */
68 #ifndef GDBINIT_FILENAME
69 #define GDBINIT_FILENAME ".gdbinit"
71 char gdbinit
[] = GDBINIT_FILENAME
;
73 #define ALL_CLEANUPS ((struct cleanup *)0)
75 /* Version number of GDB, as a string. */
79 /* Message to be printed before the error message, when an error occurs. */
81 extern char *error_pre_print
;
83 extern char lang_frame_mismatch_warn
[]; /* language.c */
85 /* Flag for whether we want all the "from_tty" gubbish printed. */
87 int caution
= 1; /* Default is yes, sigh. */
90 * Define all cmd_list_element's
93 /* Chain containing all defined commands. */
95 struct cmd_list_element
*cmdlist
;
97 /* Chain containing all defined info subcommands. */
99 struct cmd_list_element
*infolist
;
101 /* Chain containing all defined enable subcommands. */
103 struct cmd_list_element
*enablelist
;
105 /* Chain containing all defined disable subcommands. */
107 struct cmd_list_element
*disablelist
;
109 /* Chain containing all defined delete subcommands. */
111 struct cmd_list_element
*deletelist
;
113 /* Chain containing all defined "enable breakpoint" subcommands. */
115 struct cmd_list_element
*enablebreaklist
;
117 /* Chain containing all defined set subcommands */
119 struct cmd_list_element
*setlist
;
121 /* Chain containing all defined show subcommands. */
122 struct cmd_list_element
*showlist
;
124 /* Chain containing all defined \"set history\". */
126 struct cmd_list_element
*sethistlist
;
128 /* Chain containing all defined \"show history\". */
129 struct cmd_list_element
*showhistlist
;
131 /* Chain containing all defined \"unset history\". */
133 struct cmd_list_element
*unsethistlist
;
135 /* stdio stream that command input is being read from. */
139 /* Current working directory. */
141 char *current_directory
;
143 /* The directory name is actually stored here (usually). */
144 static char dirbuf
[1024];
146 /* Function to call before reading a command, if nonzero.
147 The function receives two args: an input stream,
148 and a prompt string. */
150 void (*window_hook
) ();
152 extern int frame_file_full_name
;
156 /* The external commands we call... */
157 extern void init_source_path ();
158 extern void directory_command ();
159 extern void exec_file_command ();
160 extern void symbol_file_command ();
161 extern void core_file_command ();
162 extern void tty_command ();
164 extern void help_list ();
165 extern void initialize_all_files ();
166 extern void init_malloc ();
168 /* Forward declarations for this file */
169 void free_command_lines ();
170 char *gdb_readline ();
171 char *command_line_input ();
172 static void initialize_history ();
173 static void initialize_main ();
174 static void initialize_cmd_lists ();
175 static void init_signals ();
176 static void quit_command ();
177 void command_loop ();
178 static void source_command ();
179 static void print_gdb_version ();
180 static void print_gnu_advertisement ();
181 static void float_handler ();
182 static void cd_command ();
183 static void read_command_file ();
187 /* gdb prints this when reading a command interactively */
190 /* Buffer used for reading command lines, and the size
191 allocated for it so far. */
196 /* Baud rate specified for talking to serial target systems. Default
197 is left as a zero pointer, so targets can choose their own defaults. */
201 /* Signal to catch ^Z typed while reading a command: SIGTSTP or SIGCONT. */
205 #define STOP_SIGNAL SIGTSTP
209 /* Some System V have job control but not sigsetmask(). */
210 #if !defined (HAVE_SIGSETMASK)
211 #define HAVE_SIGSETMASK !defined (USG)
214 #if 0 == (HAVE_SIGSETMASK)
215 #define sigsetmask(n)
218 /* This is how `error' returns to command level. */
220 jmp_buf to_top_level
;
223 return_to_top_level ()
227 bpstat_clear_actions(stop_bpstat
); /* Clear queued breakpoint commands */
228 clear_momentary_breakpoints ();
229 disable_current_display ();
230 do_cleanups (ALL_CLEANUPS
);
231 longjmp (to_top_level
, 1);
234 /* Call FUNC with arg ARGS, catching any errors.
235 If there is no error, return the value returned by FUNC.
236 If there is an error, print ERRSTRING, print the specific error message,
240 catch_errors (func
, args
, errstring
)
247 struct cleanup
*saved_cleanup_chain
;
248 char *saved_error_pre_print
;
250 saved_cleanup_chain
= save_cleanups ();
251 saved_error_pre_print
= error_pre_print
;
253 bcopy (to_top_level
, saved
, sizeof (jmp_buf));
254 error_pre_print
= errstring
;
256 if (setjmp (to_top_level
) == 0)
257 val
= (*func
) (args
);
261 restore_cleanups (saved_cleanup_chain
);
263 error_pre_print
= saved_error_pre_print
;
264 bcopy (saved
, to_top_level
, sizeof (jmp_buf));
268 /* Handler for SIGHUP. */
273 kill_inferior_fast ();
274 signal (SIGHUP
, SIG_DFL
);
275 kill (getpid (), SIGHUP
);
278 /* Clean up on error during a "source" command (or execution of a
279 user-defined command). */
282 source_cleanup (stream
)
285 /* Restore the previous input stream. */
289 /* Read commands from STREAM. */
291 read_command_file (stream
)
294 struct cleanup
*cleanups
;
296 cleanups
= make_cleanup (source_cleanup
, instream
);
299 do_cleanups (cleanups
);
308 static int inhibit_gdbinit
= 0;
309 static int quiet
= 0;
310 static int batch
= 0;
312 /* Pointers to various arguments from command line. */
314 char *execarg
= NULL
;
315 char *corearg
= NULL
;
319 /* Pointers to all arguments of +command option. */
321 /* Allocated size of cmdarg. */
323 /* Number of elements of cmdarg used. */
326 /* Indices of all arguments of +directory option. */
328 /* Allocated size. */
330 /* Number of elements used. */
335 /* This needs to happen before the first use of malloc. */
338 #if defined (ALIGN_STACK_ON_STARTUP)
339 i
= (int) &count
& 0x3;
344 /* If error() is called from initialization code, just exit */
345 if (setjmp (to_top_level
)) {
350 cmdarg
= (char **) xmalloc (cmdsize
* sizeof (*cmdarg
));
353 dirarg
= (char **) xmalloc (dirsize
* sizeof (*dirarg
));
357 line
= (char *) xmalloc (linesize
);
358 line
[0] = '\0'; /* Terminate saved (now empty) cmd line */
361 getcwd (dirbuf
, sizeof (dirbuf
));
362 current_directory
= dirbuf
;
364 #ifdef SET_STACK_LIMIT_HUGE
368 /* Set the stack limit huge so that alloca (particularly stringtab
369 * in dbxread.c) does not fail. */
370 getrlimit (RLIMIT_STACK
, &rlim
);
371 original_stack_limit
= rlim
.rlim_cur
;
372 rlim
.rlim_cur
= rlim
.rlim_max
;
373 setrlimit (RLIMIT_STACK
, &rlim
);
375 #endif /* SET_STACK_LIMIT_HUGE */
377 /* Parse arguments and options. */
380 static int print_help
;
381 /* When var field is 0, use flag field to record the equivalent
382 short option (or arbitrary numbers starting at 10 for those
383 with no equivalent). */
384 static struct option long_options
[] =
386 {"quiet", 0, &quiet
, 1},
387 {"nx", 0, &inhibit_gdbinit
, 1},
388 {"batch", 0, &batch
, 1},
389 {"epoch", 0, &epoch_interface
, 1},
390 {"fullname", 0, &frame_file_full_name
, 1},
391 {"help", 0, &print_help
, 1},
393 {"symbols", 1, 0, 's'},
398 {"command", 1, 0, 'x'},
400 {"directory", 1, 0, 'd'},
404 /* Allow machine descriptions to add more options... */
405 #ifdef ADDITIONAL_OPTIONS
413 c
= getopt_long_only (argc
, argv
, "",
414 long_options
, &option_index
);
418 /* Long option that takes an argument. */
419 if (c
== 0 && long_options
[option_index
].flag
== 0)
420 c
= long_options
[option_index
].val
;
425 /* Long option that just sets a flag. */
444 cmdarg
[ncmd
++] = optarg
;
448 cmdarg
= (char **) xrealloc ((char *)cmdarg
,
449 cmdsize
* sizeof (*cmdarg
));
453 dirarg
[ndir
++] = optarg
;
457 dirarg
= (char **) xrealloc ((char *)dirarg
,
458 dirsize
* sizeof (*dirarg
));
470 #ifdef ADDITIONAL_OPTION_CASES
471 ADDITIONAL_OPTION_CASES
475 "Use `%s +help' for a complete list of options.\n",
484 This is GDB, the GNU debugger. Use the command\n\
485 gdb [options] [executable [core-file]]\n\
486 to enter the debugger.\n\
488 Options available are:\n\
489 -help Print this message.\n\
490 -quiet Do not print version number on startup.\n\
491 -fullname Output information used by emacs-GDB interface.\n\
492 -epoch Output information used by epoch emacs-GDB interface.\n\
493 -batch Exit after processing options.\n\
494 -nx Do not read .gdbinit file.\n\
495 -tty=TTY Use TTY for input/output by the program being debugged.\n\
496 -cd=DIR Change current directory to DIR.\n\
497 -directory=DIR Search for source files in DIR.\n\
498 -command=FILE Execute GDB commands from FILE.\n\
499 -symbols=SYMFILE Read symbols from SYMFILE.\n\
500 -exec=EXECFILE Use EXECFILE as the executable.\n\
501 -se=FILE Use FILE as symbol file and executable file.\n\
502 -core=COREFILE Analyze the core dump COREFILE.\n\
503 -b BAUDRATE Set serial port baud rate used for remote debugging\n\
505 #ifdef ADDITIONAL_OPTION_HELP
506 fputs (ADDITIONAL_OPTION_HELP
, stderr
);
509 For more information, type \"help\" from within GDB, or consult the\n\
510 GDB manual (available as on-line info or a printed manual).\n", stderr
);
511 /* Exiting after printing this message seems like
512 the most useful thing to do. */
516 /* OK, that's all the options. The other arguments are filenames. */
518 for (; optind
< argc
; optind
++)
522 symarg
= argv
[optind
];
523 execarg
= argv
[optind
];
526 corearg
= argv
[optind
];
530 "Excess command line arguments ignored. (%s%s)\n",
531 argv
[optind
], (optind
== argc
- 1) ? "" : " ...");
538 /* Run the init function of each source file */
540 initialize_cmd_lists (); /* This needs to be done first */
541 initialize_all_files ();
542 initialize_main (); /* But that omits this file! Do it now */
547 /* Print all the junk at the top, with trailing "..." if we are about
548 to read a symbol file (possibly slowly). */
549 print_gnu_advertisement ();
550 print_gdb_version ();
552 printf_filtered ("..");
554 fflush (stdout
); /* Force to screen during slow operations */
557 error_pre_print
= "\n\n";
559 /* Now perform all the actions indicated by the arguments. */
562 if (!setjmp (to_top_level
))
564 cd_command (cdarg
, 0);
568 do_cleanups (ALL_CLEANUPS
);
570 for (i
= 0; i
< ndir
; i
++)
571 if (!setjmp (to_top_level
))
572 directory_command (dirarg
[i
], 0);
574 do_cleanups (ALL_CLEANUPS
);
578 && strcmp (execarg
, symarg
) == 0)
580 /* The exec file and the symbol-file are the same. If we can't open
581 it, better only print one error message. */
582 if (!setjmp (to_top_level
))
584 exec_file_command (execarg
, !batch
);
585 symbol_file_command (symarg
, 0);
591 if (!setjmp (to_top_level
))
592 exec_file_command (execarg
, !batch
);
594 if (!setjmp (to_top_level
))
595 symbol_file_command (symarg
, 0);
597 do_cleanups (ALL_CLEANUPS
);
599 /* After the symbol file has been read, print a newline to get us
600 beyond the copyright line... But errors should still set off
601 the error message with a (single) blank line. */
603 printf_filtered ("\n");
604 error_pre_print
= "\n";
606 /* Set the initial language. */
608 extern enum language
deduce_language_from_filename ();
609 extern struct partial_symtab
*find_main_psymtab ();
610 struct partial_symtab
*pst
= find_main_psymtab ();
611 enum language lang
= language_unknown
;
614 /* A better solution would set the language when reading the psymtab.
615 This would win for symbol file formats that encode the langauge,
616 such as dwarf. But, we don't do that yet. FIXME */
617 else if (pst
->language
!= language_unknown
)
618 lang
= pst
->language
;
620 else if (pst
->filename
!= NULL
)
621 lang
= deduce_language_from_filename (pst
->filename
);
622 if (lang
== language_unknown
) /* Make C the default language */
628 if (!setjmp (to_top_level
))
629 core_file_command (corearg
, !batch
);
630 else if (isdigit (corearg
[0]) && !setjmp (to_top_level
))
631 attach_command (corearg
, !batch
);
632 do_cleanups (ALL_CLEANUPS
);
635 if (!setjmp (to_top_level
))
636 tty_command (ttyarg
, !batch
);
637 do_cleanups (ALL_CLEANUPS
);
639 #ifdef ADDITIONAL_OPTION_HANDLER
640 ADDITIONAL_OPTION_HANDLER
;
643 /* Error messages should no longer be distinguished with extra output. */
647 struct stat homebuf
, cwdbuf
;
648 char *homedir
, *homeinit
;
650 /* Read init file, if it exists in home directory */
651 homedir
= getenv ("HOME");
654 homeinit
= (char *) alloca (strlen (getenv ("HOME")) +
655 strlen (gdbinit
) + 10);
656 strcpy (homeinit
, getenv ("HOME"));
657 strcat (homeinit
, "/");
658 strcat (homeinit
, gdbinit
);
659 if (!inhibit_gdbinit
&& access (homeinit
, R_OK
) == 0)
660 if (!setjmp (to_top_level
))
661 source_command (homeinit
, 0);
662 do_cleanups (ALL_CLEANUPS
);
664 /* Do stats; no need to do them elsewhere since we'll only
665 need them if homedir is set. Make sure that they are
666 zero in case one of them fails (this guarantees that they
667 won't match if either exists). */
669 bzero (&homebuf
, sizeof (struct stat
));
670 bzero (&cwdbuf
, sizeof (struct stat
));
672 stat (homeinit
, &homebuf
);
673 stat (gdbinit
, &cwdbuf
); /* We'll only need this if
677 /* Read the input file in the current directory, *if* it isn't
678 the same file (it should exist, also). */
681 || bcmp ((char *) &homebuf
,
683 sizeof (struct stat
)))
684 if (!inhibit_gdbinit
&& access (gdbinit
, R_OK
) == 0)
685 if (!setjmp (to_top_level
))
686 source_command (gdbinit
, 0);
687 do_cleanups (ALL_CLEANUPS
);
690 for (i
= 0; i
< ncmd
; i
++)
691 if (!setjmp (to_top_level
))
693 if (cmdarg
[i
][0] == '-' && cmdarg
[i
][1] == '\0')
694 read_command_file (stdin
);
696 source_command (cmdarg
[i
], !batch
);
697 do_cleanups (ALL_CLEANUPS
);
701 /* Read in the old history after all the command files have been read. */
702 initialize_history();
706 /* We have hit the end of the batch file. */
710 /* Do any host- or target-specific hacks. This is used for i960 targets
711 to force the user to set a nindy target and spec its parameters. */
713 #ifdef BEFORE_MAIN_LOOP_HOOK
714 BEFORE_MAIN_LOOP_HOOK
;
717 /* The command loop. */
721 if (!setjmp (to_top_level
))
723 do_cleanups (ALL_CLEANUPS
); /* Do complete cleanup */
725 quit_command ((char *)0, instream
== stdin
);
728 /* No exit -- exit is through quit_command. */
731 /* Execute the line P as a command.
732 Pass FROM_TTY as second argument to the defining function. */
735 execute_command (p
, from_tty
)
739 register struct cmd_list_element
*c
;
740 register struct command_line
*cmdlines
;
741 register enum language flang
;
742 static struct language_defn
*saved_language
= 0;
743 static int warned
= 0;
747 /* This can happen when command_line_input hits end of file. */
751 while (*p
== ' ' || *p
== '\t') p
++;
756 c
= lookup_cmd (&p
, cmdlist
, "", 0, 1);
757 /* Pass null arg rather than an empty one. */
759 if (c
->class == class_user
)
761 struct cleanup
*old_chain
;
764 error ("User-defined commands cannot take arguments.");
765 cmdlines
= c
->user_commands
;
770 /* Set the instream to 0, indicating execution of a
771 user-defined function. */
772 old_chain
= make_cleanup (source_cleanup
, instream
);
773 instream
= (FILE *) 0;
776 execute_command (cmdlines
->line
, 0);
777 cmdlines
= cmdlines
->next
;
779 do_cleanups (old_chain
);
781 else if (c
->type
== set_cmd
|| c
->type
== show_cmd
)
782 do_setshow_command (arg
, from_tty
& caution
, c
);
783 else if (c
->function
== NO_FUNCTION
)
784 error ("That is not a command, just a help topic.");
786 (*c
->function
) (arg
, from_tty
& caution
);
789 /* Tell the user if the language has changed (except first time). */
790 if (current_language
!= saved_language
)
792 if (language_mode
== language_mode_auto
) {
796 saved_language
= current_language
;
800 /* Warn the user if the working language does not match the
801 language of the current frame. Only warn the user if we are
802 actually running the program, i.e. there is a stack. */
803 /* FIXME: This should be cacheing the frame and only running when
804 the frame changes. */
805 if (target_has_stack
)
807 flang
= get_frame_language ();
809 && flang
!= language_unknown
810 && flang
!= current_language
->la_language
)
812 printf_filtered ("%s\n", lang_frame_mismatch_warn
);
820 command_loop_marker (foo
)
825 /* Read commands from `instream' and execute them
826 until end of file or error reading instream. */
830 struct cleanup
*old_chain
;
832 int stdin_is_tty
= ISATTY (stdin
);
834 while (!feof (instream
))
836 if (window_hook
&& instream
== stdin
)
837 (*window_hook
) (instream
, prompt
);
840 if (instream
== stdin
&& stdin_is_tty
)
841 reinitialize_more_filter ();
842 old_chain
= make_cleanup (command_loop_marker
, 0);
843 command
= command_line_input (instream
== stdin
? prompt
: 0,
847 execute_command (command
, instream
== stdin
);
848 /* Do any commands attached to breakpoint we stopped at. */
849 bpstat_do_actions (&stop_bpstat
);
850 do_cleanups (old_chain
);
854 /* Commands call this if they do not want to be repeated by null lines. */
859 /* If we aren't reading from standard input, we are saving the last
860 thing read from stdin in line and don't want to delete it. Null lines
861 won't repeat here in any case. */
862 if (instream
== stdin
)
866 /* Read a line from the stream "instream" without command line editing.
868 It prints PRROMPT once at the start.
869 Action is compatible with "readline", e.g. space for the result is
870 malloc'd and should be freed by the caller.
872 A NULL return means end of file. */
874 gdb_readline (prrompt
)
880 int result_size
= 80;
888 result
= (char *) xmalloc (result_size
);
892 /* Read from stdin if we are executing a user defined command.
893 This is the right thing for prompt_for_continue, at least. */
894 c
= fgetc (instream
? instream
: stdin
);
905 result
[input_index
++] = c
;
906 while (input_index
>= result_size
)
909 result
= (char *) xrealloc (result
, result_size
);
913 result
[input_index
++] = '\0';
917 /* Declaration for fancy readline with command line editing. */
920 /* Variables which control command line editing and history
921 substitution. These variables are given default values at the end
923 static int command_editing_p
;
924 static int history_expansion_p
;
925 static int write_history_p
;
926 static int history_size
;
927 static char *history_filename
;
929 /* Variables which are necessary for fancy command line editing. */
930 char *gdb_completer_word_break_characters
=
931 " \t\n!@#$%^&*()-+=|~`}{[]\"';:?/>.<,";
933 /* Functions that are used as part of the fancy command line editing. */
935 /* This can be used for functions which don't want to complete on symbols
936 but don't want to complete on anything else either. */
939 noop_completer (text
)
945 /* Generate symbol names one by one for the completer. If STATE is
946 zero, then we need to initialize, otherwise the initialization has
947 already taken place. TEXT is what we expect the symbol to start
948 with. RL_LINE_BUFFER is available to be looked at; it contains the
949 entire text of the line. RL_POINT is the offset in that line of
950 the cursor. You should pretend that the line ends at RL_POINT.
951 The result is NULL if there are no more completions, else a char
952 string which is a possible completion. */
954 symbol_completion_function (text
, state
)
958 static char **list
= (char **)NULL
;
961 extern char *rl_line_buffer
;
963 char *tmp_command
, *p
;
964 struct cmd_list_element
*c
, *result_list
;
968 /* Free the storage used by LIST, but not by the strings inside. This is
969 because rl_complete_internal () frees the strings. */
975 /* Decide whether to complete on a list of gdb commands or on
977 tmp_command
= (char *) alloca (rl_point
+ 1);
980 strncpy (tmp_command
, rl_line_buffer
, rl_point
);
981 tmp_command
[rl_point
] = '\0';
985 /* An empty line we want to consider ambiguous; that is,
986 it could be any command. */
987 c
= (struct cmd_list_element
*) -1;
991 c
= lookup_cmd_1 (&p
, cmdlist
, &result_list
, 1);
993 /* Move p up to the next interesting thing. */
994 while (*p
== ' ' || *p
== '\t')
998 /* He's typed something unrecognizable. Sigh. */
1000 else if (c
== (struct cmd_list_element
*) -1)
1002 /* If we didn't recognize everything up to the thing that
1003 needs completing, and we don't know what command it is
1004 yet, we are in trouble. Part of the trouble might be
1005 that the list of delimiters used by readline includes
1006 '-', which we use in commands. Check for this. */
1007 if (p
+ strlen(text
) != tmp_command
+ rl_point
) {
1008 if (tmp_command
[rl_point
- strlen(text
) - 1] == '-')
1011 /* This really should not produce an error. Better would
1012 be to pretend to hit RETURN here; this would produce a
1013 response like "Ambiguous command: foo, foobar, etc",
1014 and leave the line available for re-entry with ^P. Instead,
1015 this error blows away the user's typed input without
1016 any way to get it back. */
1017 error (" Unrecognized command.");
1021 /* He's typed something ambiguous. This is easier. */
1023 list
= complete_on_cmdlist (*result_list
->prefixlist
, text
);
1025 list
= complete_on_cmdlist (cmdlist
, text
);
1029 /* If we've gotten this far, gdb has recognized a full
1030 command. There are several possibilities:
1032 1) We need to complete on the command.
1033 2) We need to complete on the possibilities coming after
1035 2) We need to complete the text of what comes after the
1039 /* Always (might be longer versions of thie command). */
1040 list
= complete_on_cmdlist (result_list
, text
);
1041 else if (!*p
&& !*text
)
1044 list
= complete_on_cmdlist (*c
->prefixlist
, "");
1046 list
= (*c
->completer
) ("");
1050 if (c
->prefixlist
&& !c
->allow_unknown
)
1053 /* Something like "info adsfkdj". But error() is not
1054 the proper response; just return no completions
1057 error ("\"%s\" command requires a subcommand.",
1064 list
= (*c
->completer
) (text
);
1069 /* If the debugged program wasn't compiled with symbols, or if we're
1070 clearly completing on a command and no command matches, return
1073 return ((char *)NULL
);
1075 output
= list
[index
];
1086 #if STOP_SIGNAL == SIGTSTP
1087 signal (SIGTSTP
, SIG_DFL
);
1089 kill (getpid (), SIGTSTP
);
1090 signal (SIGTSTP
, stop_sig
);
1092 signal (STOP_SIGNAL
, stop_sig
);
1094 printf ("%s", prompt
);
1097 /* Forget about any previous command -- null line now will do nothing. */
1100 #endif /* STOP_SIGNAL */
1102 /* Initialize signal handlers. */
1111 extern void request_quit ();
1113 signal (SIGINT
, request_quit
);
1115 /* If we initialize SIGQUIT to SIG_IGN, then the SIG_IGN will get
1116 passed to the inferior, which we don't want. It would be
1117 possible to do a "signal (SIGQUIT, SIG_DFL)" after we fork, but
1118 on BSD4.3 systems using vfork, that can affect the
1119 GDB process as well as the inferior (the signal handling tables
1120 might be in memory, shared between the two). Since we establish
1121 a handler for SIGQUIT, when we call exec it will set the signal
1122 to SIG_DFL for us. */
1123 signal (SIGQUIT
, do_nothing
);
1124 if (signal (SIGHUP
, do_nothing
) != SIG_IGN
)
1125 signal (SIGHUP
, disconnect
);
1126 signal (SIGFPE
, float_handler
);
1129 /* Read one line from the command input stream `instream'
1130 into the local static buffer `linebuffer' (whose current length
1132 The buffer is made bigger as necessary.
1133 Returns the address of the start of the line.
1135 NULL is returned for end of file.
1137 *If* the instream == stdin & stdin is a terminal, the line read
1138 is copied into the file line saver (global var char *line,
1139 length linesize) so that it can be duplicated.
1141 This routine either uses fancy command line editing or
1142 simple input as the user has requested. */
1145 command_line_input (prrompt
, repeat
)
1149 static char *linebuffer
= 0;
1150 static int linelength
= 0;
1154 char *local_prompt
= prrompt
;
1159 if (linebuffer
== 0)
1162 linebuffer
= (char *) xmalloc (linelength
);
1167 /* Control-C quits instantly if typed while in this loop
1168 since it should not wait until the user types a newline. */
1171 signal (STOP_SIGNAL
, stop_sig
);
1176 /* Reports are that some Sys V's don't flush stdout/err on reads
1177 from stdin, when stdin/out are sockets rather than ttys. So we
1178 have to do it ourselves, to make emacs-gdb and xxgdb work.
1179 On other machines, doing this once per input should be a cheap nop. */
1183 /* Don't use fancy stuff if not talking to stdin. */
1184 if (command_editing_p
&& instream
== stdin
1185 && ISATTY (instream
))
1186 rl
= readline (local_prompt
);
1188 rl
= gdb_readline (local_prompt
);
1190 if (!rl
|| rl
== (char *) EOF
)
1195 if (strlen(rl
) + 1 + (p
- linebuffer
) > linelength
)
1197 linelength
= strlen(rl
) + 1 + (p
- linebuffer
);
1198 nline
= (char *) xrealloc (linebuffer
, linelength
);
1199 p
+= nline
- linebuffer
;
1203 /* Copy line. Don't copy null at end. (Leaves line alone
1204 if this was just a newline) */
1208 free (rl
); /* Allocated in readline. */
1210 if (p
== linebuffer
|| *(p
- 1) != '\\')
1213 p
--; /* Put on top of '\'. */
1214 local_prompt
= (char *) 0;
1218 signal (SIGTSTP
, SIG_DFL
);
1225 /* Do history expansion if that is wished. */
1226 if (history_expansion_p
&& instream
== stdin
1227 && ISATTY (instream
))
1229 char *history_value
;
1232 *p
= '\0'; /* Insert null now. */
1233 expanded
= history_expand (linebuffer
, &history_value
);
1236 /* Print the changes. */
1237 printf ("%s\n", history_value
);
1239 /* If there was an error, call this function again. */
1242 free (history_value
);
1243 return command_line_input (prrompt
, repeat
);
1245 if (strlen (history_value
) > linelength
)
1247 linelength
= strlen (history_value
) + 1;
1248 linebuffer
= (char *) xrealloc (linebuffer
, linelength
);
1250 strcpy (linebuffer
, history_value
);
1251 p
= linebuffer
+ strlen(linebuffer
);
1252 free (history_value
);
1256 /* If we just got an empty line, and that is supposed
1257 to repeat the previous command, return the value in the
1261 if (p
== linebuffer
)
1264 while (*p1
== ' ' || *p1
== '\t')
1272 /* Add line to history if appropriate. */
1273 if (instream
== stdin
1274 && ISATTY (stdin
) && *linebuffer
)
1275 add_history (linebuffer
);
1277 /* Note: lines consisting soley of comments are added to the command
1278 history. This is useful when you type a command, and then
1279 realize you don't want to execute it quite yet. You can comment
1280 out the command and then later fetch it from the value history
1281 and remove the '#'. The kill ring is probably better, but some
1282 people are in the habit of commenting things out. */
1284 while ((c
= *p1
++) != '\0')
1287 while ((c
= *p1
++) != '"')
1289 /* Make sure an escaped '"' doesn't make us think the string
1297 while ((c
= *p1
++) != '\'')
1299 /* Make sure an escaped '\'' doesn't make us think the string
1308 /* Found a comment. */
1314 /* Save into global buffer if appropriate. */
1317 if (linelength
> linesize
)
1319 line
= xrealloc (line
, linelength
);
1320 linesize
= linelength
;
1322 strcpy (line
, linebuffer
);
1329 /* Read lines from the input stream
1330 and accumulate them in a chain of struct command_line's
1331 which is then returned. */
1333 struct command_line
*
1334 read_command_lines ()
1336 struct command_line
*first
= 0;
1337 register struct command_line
*next
, *tail
= 0;
1338 register char *p
, *p1
;
1339 struct cleanup
*old_chain
= 0;
1344 p
= command_line_input (0, instream
== stdin
);
1346 /* Treat end of file like "end". */
1349 /* Remove leading and trailing blanks. */
1350 while (*p
== ' ' || *p
== '\t') p
++;
1351 p1
= p
+ strlen (p
);
1352 while (p1
!= p
&& (p1
[-1] == ' ' || p1
[-1] == '\t')) p1
--;
1354 /* Is this "end"? */
1355 if (p1
- p
== 3 && !strncmp (p
, "end", 3))
1358 /* No => add this line to the chain of command lines. */
1359 next
= (struct command_line
*) xmalloc (sizeof (struct command_line
));
1360 next
->line
= savestring (p
, p1
- p
);
1368 /* We just read the first line.
1369 From now on, arrange to throw away the lines we have
1370 if we quit or get an error while inside this function. */
1372 old_chain
= make_cleanup (free_command_lines
, &first
);
1379 /* Now we are about to return the chain to our caller,
1380 so freeing it becomes his responsibility. */
1382 discard_cleanups (old_chain
);
1386 /* Free a chain of struct command_line's. */
1389 free_command_lines (lptr
)
1390 struct command_line
**lptr
;
1392 register struct command_line
*l
= *lptr
;
1393 register struct command_line
*next
;
1404 /* Add an element to the list of info subcommands. */
1407 add_info (name
, fun
, doc
)
1412 add_cmd (name
, no_class
, fun
, doc
, &infolist
);
1415 /* Add an alias to the list of info subcommands. */
1418 add_info_alias (name
, oldname
, abbrev_flag
)
1423 add_alias_cmd (name
, oldname
, 0, abbrev_flag
, &infolist
);
1426 /* The "info" command is defined as a prefix, with allow_unknown = 0.
1427 Therefore, its own definition is called only for "info" with no args. */
1431 info_command (arg
, from_tty
)
1435 printf ("\"info\" must be followed by the name of an info command.\n");
1436 help_list (infolist
, "info ", -1, stdout
);
1439 /* The "show" command with no arguments shows all the settings. */
1443 show_command (arg
, from_tty
)
1447 cmd_show_list (showlist
, from_tty
, "");
1450 /* Add an element to the list of commands. */
1453 add_com (name
, class, fun
, doc
)
1455 enum command_class
class;
1459 add_cmd (name
, class, fun
, doc
, &cmdlist
);
1462 /* Add an alias or abbreviation command to the list of commands. */
1465 add_com_alias (name
, oldname
, class, abbrev_flag
)
1468 enum command_class
class;
1471 add_alias_cmd (name
, oldname
, class, abbrev_flag
, &cmdlist
);
1478 error ("Argument required (%s).", why
);
1483 help_command (command
, from_tty
)
1485 int from_tty
; /* Ignored */
1487 help_cmd (command
, stdout
);
1491 validate_comname (comname
)
1497 error_no_arg ("name of command to define");
1502 if (!(*p
>= 'A' && *p
<= 'Z')
1503 && !(*p
>= 'a' && *p
<= 'z')
1504 && !(*p
>= '0' && *p
<= '9')
1506 error ("Junk in argument list: \"%s\"", p
);
1512 define_command (comname
, from_tty
)
1516 register struct command_line
*cmds
;
1517 register struct cmd_list_element
*c
, *newc
;
1518 char *tem
= comname
;
1519 extern void not_just_help_class_command ();
1521 validate_comname (comname
);
1523 /* Look it up, and verify that we got an exact match. */
1524 c
= lookup_cmd (&tem
, cmdlist
, "", -1, 1);
1525 if (c
&& 0 != strcmp (comname
, c
->name
))
1530 if (c
->class == class_user
|| c
->class == class_alias
)
1531 tem
= "Redefine command \"%s\"? ";
1533 tem
= "Really redefine built-in command \"%s\"? ";
1534 if (!query (tem
, comname
))
1535 error ("Command \"%s\" not redefined.", comname
);
1540 printf ("Type commands for definition of \"%s\".\n\
1541 End with a line saying just \"end\".\n", comname
);
1544 comname
= savestring (comname
, strlen (comname
));
1546 cmds
= read_command_lines ();
1548 if (c
&& c
->class == class_user
)
1549 free_command_lines (&c
->user_commands
);
1551 newc
= add_cmd (comname
, class_user
, not_just_help_class_command
,
1552 (c
&& c
->class == class_user
)
1553 ? c
->doc
: savestring ("User-defined.", 13), &cmdlist
);
1554 newc
->user_commands
= cmds
;
1558 document_command (comname
, from_tty
)
1562 struct command_line
*doclines
;
1563 register struct cmd_list_element
*c
;
1564 char *tem
= comname
;
1566 validate_comname (comname
);
1568 c
= lookup_cmd (&tem
, cmdlist
, "", 0, 1);
1570 if (c
->class != class_user
)
1571 error ("Command \"%s\" is built-in.", comname
);
1574 printf ("Type documentation for \"%s\".\n\
1575 End with a line saying just \"end\".\n", comname
);
1577 doclines
= read_command_lines ();
1579 if (c
->doc
) free (c
->doc
);
1582 register struct command_line
*cl1
;
1583 register int len
= 0;
1585 for (cl1
= doclines
; cl1
; cl1
= cl1
->next
)
1586 len
+= strlen (cl1
->line
) + 1;
1588 c
->doc
= (char *) xmalloc (len
+ 1);
1591 for (cl1
= doclines
; cl1
; cl1
= cl1
->next
)
1593 strcat (c
->doc
, cl1
->line
);
1595 strcat (c
->doc
, "\n");
1599 free_command_lines (&doclines
);
1603 print_gnu_advertisement()
1606 GDB is free software and you are welcome to distribute copies of it\n\
1607 under certain conditions; type \"show copying\" to see the conditions.\n\
1608 There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\
1613 print_gdb_version ()
1616 GDB %s, Copyright 1991 Free Software Foundation, Inc.",
1622 show_version (args
, from_tty
)
1627 print_gnu_advertisement ();
1628 print_gdb_version ();
1629 printf_filtered ("\n");
1633 /* xgdb calls this to reprint the usual GDB prompt. */
1638 printf ("%s", prompt
);
1643 quit_command (args
, from_tty
)
1647 if (inferior_pid
!= 0 && target_has_execution
)
1649 if (query ("The program is running. Quit anyway? "))
1651 target_kill (args
, from_tty
);
1654 error ("Not confirmed.");
1656 /* Save the history information if it is appropriate to do so. */
1657 if (write_history_p
&& history_filename
)
1658 write_history (history_filename
);
1663 input_from_terminal_p ()
1665 return (instream
== stdin
) & caution
;
1670 pwd_command (args
, from_tty
)
1674 if (args
) error ("The \"pwd\" command does not take an argument: %s", args
);
1675 getcwd (dirbuf
, sizeof (dirbuf
));
1677 if (strcmp (dirbuf
, current_directory
))
1678 printf ("Working directory %s\n (canonically %s).\n",
1679 current_directory
, dirbuf
);
1681 printf ("Working directory %s.\n", current_directory
);
1685 cd_command (dir
, from_tty
)
1692 /* If the new directory is absolute, repeat is a no-op; if relative,
1693 repeat might be useful but is more likely to be a mistake. */
1697 error_no_arg ("new working directory");
1699 dir
= tilde_expand (dir
);
1700 make_cleanup (free
, dir
);
1703 dir
= savestring (dir
, len
- (len
> 1 && dir
[len
-1] == '/'));
1705 current_directory
= dir
;
1708 current_directory
= concat (current_directory
, "/", dir
, NULL
);
1712 /* Now simplify any occurrences of `.' and `..' in the pathname. */
1720 for (p
= current_directory
; *p
;)
1722 if (!strncmp (p
, "/./", 2)
1723 && (p
[2] == 0 || p
[2] == '/'))
1725 else if (!strncmp (p
, "/..", 3)
1726 && (p
[3] == 0 || p
[3] == '/')
1727 && p
!= current_directory
)
1730 while (q
!= current_directory
&& q
[-1] != '/') q
--;
1731 if (q
!= current_directory
)
1741 if (chdir (dir
) < 0)
1742 perror_with_name (dir
);
1744 forget_cached_source_info ();
1747 pwd_command ((char *) 0, 1);
1752 source_command (args
, from_tty
)
1757 struct cleanup
*cleanups
;
1761 /* Let source without arguments read .gdbinit. */
1764 file
= tilde_expand (file
);
1765 make_cleanup (free
, file
);
1767 stream
= fopen (file
, "r");
1769 perror_with_name (file
);
1771 cleanups
= make_cleanup (fclose
, stream
);
1773 read_command_file (stream
);
1775 do_cleanups (cleanups
);
1780 echo_command (text
, from_tty
)
1792 /* \ at end of argument is used after spaces
1793 so they won't be lost. */
1797 c
= parse_escape (&p
);
1799 printf_filtered ("%c", c
);
1802 printf_filtered ("%c", c
);
1805 /* Force this output to appear now. */
1812 dump_me_command (args
, from_tty
)
1816 if (query ("Should GDB dump core? "))
1818 signal (SIGQUIT
, SIG_DFL
);
1819 kill (getpid (), SIGQUIT
);
1823 /* Functions to manipulate command line editing control variables. */
1825 /* Number of commands to print in each call to show_commands. */
1826 #define Hist_print 10
1828 show_commands (args
, from_tty
)
1832 /* Index for history commands. Relative to history_base. */
1835 /* Number of the history entry which we are planning to display next.
1836 Relative to history_base. */
1839 /* The first command in the history which doesn't exist (i.e. one more
1840 than the number of the last command). Relative to history_base. */
1843 struct _hist_entry
*history_get();
1844 extern int history_base
;
1847 /* This is all reported by individual "show" commands. */
1848 printf_filtered ("Interactive command editing is %s.\n",
1849 command_editing_p
? "on" : "off");
1851 printf_filtered ("History expansion of command input is %s.\n",
1852 history_expansion_p
? "on" : "off");
1853 printf_filtered ("Writing of a history record upon exit is %s.\n",
1854 write_history_p
? "enabled" : "disabled");
1855 printf_filtered ("The size of the history list (number of stored commands) is %d.\n",
1857 printf_filtered ("The name of the history record is \"%s\".\n\n",
1858 history_filename
? history_filename
: "");
1861 /* Print out some of the commands from the command history. */
1862 /* First determine the length of the history list. */
1863 hist_len
= history_size
;
1864 for (offset
= 0; offset
< history_size
; offset
++)
1866 if (!history_get (history_base
+ offset
))
1875 if (args
[0] == '+' && args
[1] == '\0')
1876 /* "info editing +" should print from the stored position. */
1879 /* "info editing <exp>" should print around command number <exp>. */
1880 num
= (parse_and_eval_address (args
) - history_base
) - Hist_print
/ 2;
1882 /* "info editing" means print the last Hist_print commands. */
1885 num
= hist_len
- Hist_print
;
1891 /* If there are at least Hist_print commands, we want to display the last
1892 Hist_print rather than, say, the last 6. */
1893 if (hist_len
- num
< Hist_print
)
1895 num
= hist_len
- Hist_print
;
1901 /* No need for a header now that "info editing" only prints one thing. */
1902 if (num
== hist_len
- Hist_print
)
1903 printf_filtered ("The list of the last %d commands is:\n\n", Hist_print
);
1905 printf_filtered ("Some of the stored commands are:\n\n");
1908 for (offset
= num
; offset
< num
+ Hist_print
&& offset
< hist_len
; offset
++)
1910 printf_filtered ("%5d %s\n", history_base
+ offset
,
1911 (history_get (history_base
+ offset
))->line
);
1914 /* The next command we want to display is the next one that we haven't
1918 /* If the user repeats this command with return, it should do what
1919 "info editing +" does. This is unnecessary if arg is null,
1920 because "info editing +" is not useful after "info editing". */
1921 if (from_tty
&& args
)
1928 /* Called by do_setshow_command. */
1931 set_history_size_command (args
, from_tty
, c
)
1934 struct cmd_list_element
*c
;
1936 if (history_size
== UINT_MAX
)
1937 unstifle_history ();
1939 stifle_history (history_size
);
1944 set_history (args
, from_tty
)
1948 printf ("\"set history\" must be followed by the name of a history subcommand.\n");
1949 help_list (sethistlist
, "set history ", -1, stdout
);
1954 show_history (args
, from_tty
)
1958 cmd_show_list (showhistlist
, from_tty
, "");
1961 int info_verbose
= 0; /* Default verbose msgs off */
1963 /* Called by do_setshow_command. An elaborate joke. */
1966 set_verbose (args
, from_tty
, c
)
1969 struct cmd_list_element
*c
;
1971 char *cmdname
= "verbose";
1972 struct cmd_list_element
*showcmd
;
1974 showcmd
= lookup_cmd_1 (&cmdname
, showlist
, NULL
, 1);
1978 c
->doc
= "Set verbose printing of informational messages.";
1979 showcmd
->doc
= "Show verbose printing of informational messages.";
1983 c
->doc
= "Set verbosity.";
1984 showcmd
->doc
= "Show verbosity.";
1991 /* This message is based on ANSI C, section 4.7. Note that integer
1992 divide by zero causes this, so "float" is a misnomer. */
1993 error ("Erroneous arithmetic operation.");
1996 /* Return whether we are running a batch file or from terminal. */
2000 return !(instream
== stdin
&& ISATTY (stdin
));
2005 initialize_cmd_lists ()
2007 cmdlist
= (struct cmd_list_element
*) 0;
2008 infolist
= (struct cmd_list_element
*) 0;
2009 enablelist
= (struct cmd_list_element
*) 0;
2010 disablelist
= (struct cmd_list_element
*) 0;
2011 deletelist
= (struct cmd_list_element
*) 0;
2012 enablebreaklist
= (struct cmd_list_element
*) 0;
2013 setlist
= (struct cmd_list_element
*) 0;
2015 sethistlist
= (struct cmd_list_element
*) 0;
2016 showhistlist
= NULL
;
2017 unsethistlist
= (struct cmd_list_element
*) 0;
2020 /* Init the history buffer. Note that we are called after the init file(s)
2021 * have been read so that the user can change the history file via his
2022 * .gdbinit file (for instance). The GDBHISTFILE environment variable
2023 * overrides all of this.
2027 initialize_history()
2031 if (tmpenv
= getenv ("HISTSIZE"))
2032 history_size
= atoi (tmpenv
);
2033 else if (!history_size
)
2036 stifle_history (history_size
);
2038 if (tmpenv
= getenv ("GDBHISTFILE"))
2039 history_filename
= savestring (tmpenv
, strlen(tmpenv
));
2040 else if (!history_filename
) {
2041 /* We include the current directory so that if the user changes
2042 directories the file written will be the same as the one
2044 history_filename
= concat (current_directory
, "/.gdb_history", NULL
);
2046 read_history (history_filename
);
2052 struct cmd_list_element
*c
;
2054 #ifdef DEFAULT_PROMPT
2055 prompt
= savestring (DEFAULT_PROMPT
, strlen(DEFAULT_PROMPT
));
2057 prompt
= savestring ("(gdb) ", 6);
2060 /* Set the important stuff up for command editing. */
2061 command_editing_p
= 1;
2062 history_expansion_p
= 0;
2063 write_history_p
= 0;
2065 /* Setup important stuff for command line editing. */
2066 rl_completion_entry_function
= (int (*)()) symbol_completion_function
;
2067 rl_completer_word_break_characters
= gdb_completer_word_break_characters
;
2068 rl_readline_name
= "gdb";
2070 /* Define the classes of commands.
2071 They will appear in the help list in the reverse of this order. */
2073 add_cmd ("obscure", class_obscure
, NO_FUNCTION
, "Obscure features.", &cmdlist
);
2074 add_cmd ("aliases", class_alias
, NO_FUNCTION
, "Aliases of other commands.", &cmdlist
);
2075 add_cmd ("user-defined", class_user
, NO_FUNCTION
, "User-defined commands.\n\
2076 The commands in this class are those defined by the user.\n\
2077 Use the \"define\" command to define a command.", &cmdlist
);
2078 add_cmd ("support", class_support
, NO_FUNCTION
, "Support facilities.", &cmdlist
);
2079 add_cmd ("status", class_info
, NO_FUNCTION
, "Status inquiries.", &cmdlist
);
2080 add_cmd ("files", class_files
, NO_FUNCTION
, "Specifying and examining files.", &cmdlist
);
2081 add_cmd ("breakpoints", class_breakpoint
, NO_FUNCTION
, "Making program stop at certain points.", &cmdlist
);
2082 add_cmd ("data", class_vars
, NO_FUNCTION
, "Examining data.", &cmdlist
);
2083 add_cmd ("stack", class_stack
, NO_FUNCTION
, "Examining the stack.\n\
2084 The stack is made up of stack frames. Gdb assigns numbers to stack frames\n\
2085 counting from zero for the innermost (currently executing) frame.\n\n\
2086 At any time gdb identifies one frame as the \"selected\" frame.\n\
2087 Variable lookups are done with respect to the selected frame.\n\
2088 When the program being debugged stops, gdb selects the innermost frame.\n\
2089 The commands below can be used to select other frames by number or address.",
2091 add_cmd ("running", class_run
, NO_FUNCTION
, "Running the program.", &cmdlist
);
2093 add_com ("pwd", class_files
, pwd_command
,
2094 "Print working directory. This is used for your program as well.");
2095 add_com ("cd", class_files
, cd_command
,
2096 "Set working directory to DIR for debugger and program being debugged.\n\
2097 The change does not take effect for the program being debugged\n\
2098 until the next time it is started.");
2101 (add_set_cmd ("prompt", class_support
, var_string
, (char *)&prompt
,
2106 add_com ("echo", class_support
, echo_command
,
2107 "Print a constant string. Give string as argument.\n\
2108 C escape sequences may be used in the argument.\n\
2109 No newline is added at the end of the argument;\n\
2110 use \"\\n\" if you want a newline to be printed.\n\
2111 Since leading and trailing whitespace are ignored in command arguments,\n\
2112 if you want to print some you must use \"\\\" before leading whitespace\n\
2113 to be printed or after trailing whitespace.");
2114 add_com ("document", class_support
, document_command
,
2115 "Document a user-defined command.\n\
2116 Give command name as argument. Give documentation on following lines.\n\
2117 End with a line of just \"end\".");
2118 add_com ("define", class_support
, define_command
,
2119 "Define a new command name. Command name is argument.\n\
2120 Definition appears on following lines, one command per line.\n\
2121 End with a line of just \"end\".\n\
2122 Use the \"document\" command to give documentation for the new command.\n\
2123 Commands defined in this way do not take arguments.");
2126 add_com ("source", class_support
, source_command
,
2127 "Read commands from a file named FILE.\n\
2128 Note that the file \"" GDBINIT_FILENAME
"\" is read automatically in this way\n\
2129 when gdb is started.");
2131 /* Punt file name, we can't help it easily. */
2132 add_com ("source", class_support
, source_command
,
2133 "Read commands from a file named FILE.\n\
2134 Note that the file \".gdbinit\" is read automatically in this way\n\
2135 when gdb is started.");
2138 add_com ("quit", class_support
, quit_command
, "Exit gdb.");
2139 add_com ("help", class_support
, help_command
, "Print list of commands.");
2140 add_com_alias ("q", "quit", class_support
, 1);
2141 add_com_alias ("h", "help", class_support
, 1);
2144 c
= add_set_cmd ("verbose", class_support
, var_boolean
, (char *)&info_verbose
,
2147 add_show_from_set (c
, &showlist
);
2148 c
->function
= set_verbose
;
2149 set_verbose (NULL
, 0, c
);
2151 add_com ("dump-me", class_obscure
, dump_me_command
,
2152 "Get fatal error; make debugger dump its core.");
2155 (add_set_cmd ("editing", class_support
, var_boolean
, (char *)&command_editing_p
,
2156 "Set command line editing.\n\
2157 Use \"on\" to enable to enable the editing, and \"off\" to disable it.\n\
2158 Without an argument, command line editing is enabled.", &setlist
),
2161 add_prefix_cmd ("history", class_support
, set_history
,
2162 "Generic command for setting command history parameters.",
2163 &sethistlist
, "set history ", 0, &setlist
);
2164 add_prefix_cmd ("history", class_support
, show_history
,
2165 "Generic command for showing command history parameters.",
2166 &showhistlist
, "show history ", 0, &showlist
);
2169 (add_set_cmd ("expansion", no_class
, var_boolean
, (char *)&history_expansion_p
,
2170 "Set history expansion on command input.\n\
2171 Without an argument, history expansion is enabled.", &sethistlist
),
2175 (add_set_cmd ("save", no_class
, var_boolean
, (char *)&write_history_p
,
2176 "Set saving of the history record on exit.\n\
2177 Use \"on\" to enable to enable the saving, and \"off\" to disable it.\n\
2178 Without an argument, saving is enabled.", &sethistlist
),
2181 c
= add_set_cmd ("size", no_class
, var_uinteger
, (char *)&history_size
,
2182 "Set the size of the command history, \n\
2183 ie. the number of previous commands to keep a record of.", &sethistlist
);
2184 add_show_from_set (c
, &showhistlist
);
2185 c
->function
= set_history_size_command
;
2188 (add_set_cmd ("filename", no_class
, var_filename
, (char *)&history_filename
,
2189 "Set the filename in which to record the command history\n\
2190 (the list of previous commands of which a record is kept).", &sethistlist
),
2194 (add_set_cmd ("confirm", class_support
, var_boolean
,
2196 "Set whether to confirm potentially dangerous operations.",
2200 add_prefix_cmd ("info", class_info
, info_command
,
2201 "Generic command for printing status.",
2202 &infolist
, "info ", 0, &cmdlist
);
2203 add_com_alias ("i", "info", class_info
, 1);
2205 add_prefix_cmd ("show", class_info
, show_command
,
2206 "Generic command for showing things set with \"set\".",
2207 &showlist
, "show ", 0, &cmdlist
);
2208 /* Another way to get at the same thing. */
2209 add_info ("set", show_command
, "Show all GDB settings.");
2211 add_cmd ("commands", no_class
, show_commands
, "Status of command editor.",
2214 add_cmd ("version", no_class
, show_version
,
2215 "Report what version of GDB this is.", &showlist
);