1 /* Top level for GDB, the GNU debugger.
2 Copyright (C) 1986, 1987, 1988, 1989, 1990 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. */
29 #include "breakpoint.h"
34 /* readline include files */
38 /* readline defines this. */
42 #include <sys/types.h>
49 #include <sys/param.h>
53 #ifdef SET_STACK_LIMIT_HUGE
55 #include <sys/resource.h>
57 int original_stack_limit
;
61 /* If this definition isn't overridden by the header files, assume
62 that isatty and fileno exist on this system. */
64 #define ISATTY(FP) (isatty (fileno (FP)))
67 /* Initialization file name for gdb. This is overridden in some configs. */
69 #ifndef GDBINIT_FILENAME
70 #define GDBINIT_FILENAME ".gdbinit"
72 char gdbinit
[] = GDBINIT_FILENAME
;
74 #define ALL_CLEANUPS ((struct cleanup *)0)
76 /* Version number of GDB, as a string. */
80 /* Message to be printed before the error message, when an error occurs. */
82 extern char *error_pre_print
;
84 extern char lang_frame_mismatch_warn
[]; /* language.c */
86 /* Flag for whether we want all the "from_tty" gubbish printed. */
88 int caution
= 1; /* Default is yes, sigh. */
91 * Define all cmd_list_element's
94 /* Chain containing all defined commands. */
96 struct cmd_list_element
*cmdlist
;
98 /* Chain containing all defined info subcommands. */
100 struct cmd_list_element
*infolist
;
102 /* Chain containing all defined enable subcommands. */
104 struct cmd_list_element
*enablelist
;
106 /* Chain containing all defined disable subcommands. */
108 struct cmd_list_element
*disablelist
;
110 /* Chain containing all defined delete subcommands. */
112 struct cmd_list_element
*deletelist
;
114 /* Chain containing all defined "enable breakpoint" subcommands. */
116 struct cmd_list_element
*enablebreaklist
;
118 /* Chain containing all defined set subcommands */
120 struct cmd_list_element
*setlist
;
122 /* Chain containing all defined show subcommands. */
123 struct cmd_list_element
*showlist
;
125 /* Chain containing all defined \"set history\". */
127 struct cmd_list_element
*sethistlist
;
129 /* Chain containing all defined \"show history\". */
130 struct cmd_list_element
*showhistlist
;
132 /* Chain containing all defined \"unset history\". */
134 struct cmd_list_element
*unsethistlist
;
136 /* stdio stream that command input is being read from. */
140 /* Current working directory. */
142 char *current_directory
;
144 /* The directory name is actually stored here (usually). */
145 static char dirbuf
[MAXPATHLEN
];
147 /* Function to call before reading a command, if nonzero.
148 The function receives two args: an input stream,
149 and a prompt string. */
151 void (*window_hook
) ();
153 extern int frame_file_full_name
;
157 /* The external commands we call... */
158 extern void init_source_path ();
159 extern void directory_command ();
160 extern void exec_file_command ();
161 extern void symbol_file_command ();
162 extern void core_file_command ();
163 extern void tty_command ();
165 extern void help_list ();
166 extern void initialize_all_files ();
167 extern void init_malloc ();
169 /* Forward declarations for this file */
170 void free_command_lines ();
171 char *gdb_readline ();
172 char *command_line_input ();
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)
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 */
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";
607 if (!setjmp (to_top_level
))
608 core_file_command (corearg
, !batch
);
609 else if (isdigit (corearg
[0]) && !setjmp (to_top_level
))
610 attach_command (corearg
, !batch
);
611 do_cleanups (ALL_CLEANUPS
);
614 if (!setjmp (to_top_level
))
615 tty_command (ttyarg
, !batch
);
616 do_cleanups (ALL_CLEANUPS
);
618 #ifdef ADDITIONAL_OPTION_HANDLER
619 ADDITIONAL_OPTION_HANDLER
;
622 /* Error messages should no longer be distinguished with extra output. */
626 struct stat homebuf
, cwdbuf
;
627 char *homedir
, *homeinit
;
629 /* Read init file, if it exists in home directory */
630 homedir
= getenv ("HOME");
633 homeinit
= (char *) alloca (strlen (getenv ("HOME")) +
634 strlen (gdbinit
) + 10);
635 strcpy (homeinit
, getenv ("HOME"));
636 strcat (homeinit
, "/");
637 strcat (homeinit
, gdbinit
);
638 if (!inhibit_gdbinit
&& access (homeinit
, R_OK
) == 0)
639 if (!setjmp (to_top_level
))
640 source_command (homeinit
, 0);
641 do_cleanups (ALL_CLEANUPS
);
643 /* Do stats; no need to do them elsewhere since we'll only
644 need them if homedir is set. Make sure that they are
645 zero in case one of them fails (this guarantees that they
646 won't match if either exists). */
648 bzero (&homebuf
, sizeof (struct stat
));
649 bzero (&cwdbuf
, sizeof (struct stat
));
651 stat (homeinit
, &homebuf
);
652 stat (gdbinit
, &cwdbuf
); /* We'll only need this if
656 /* Read the input file in the current directory, *if* it isn't
657 the same file (it should exist, also). */
660 || bcmp ((char *) &homebuf
,
662 sizeof (struct stat
)))
663 if (!inhibit_gdbinit
&& access (gdbinit
, R_OK
) == 0)
664 if (!setjmp (to_top_level
))
665 source_command (gdbinit
, 0);
666 do_cleanups (ALL_CLEANUPS
);
669 for (i
= 0; i
< ncmd
; i
++)
670 if (!setjmp (to_top_level
))
672 if (cmdarg
[i
][0] == '-' && cmdarg
[i
][1] == '\0')
673 read_command_file (stdin
);
675 source_command (cmdarg
[i
], !batch
);
676 do_cleanups (ALL_CLEANUPS
);
682 /* We have hit the end of the batch file. */
686 /* Do any host- or target-specific hacks. This is used for i960 targets
687 to force the user to set a nindy target and spec its parameters. */
689 #ifdef BEFORE_MAIN_LOOP_HOOK
690 BEFORE_MAIN_LOOP_HOOK
;
693 /* The command loop. */
697 if (!setjmp (to_top_level
))
699 do_cleanups (ALL_CLEANUPS
); /* Do complete cleanup */
701 quit_command ((char *)0, instream
== stdin
);
704 /* No exit -- exit is through quit_command. */
707 /* Execute the line P as a command.
708 Pass FROM_TTY as second argument to the defining function. */
711 execute_command (p
, from_tty
)
715 register struct cmd_list_element
*c
;
716 register struct command_line
*cmdlines
;
717 register enum language flang
;
718 static struct language_defn
*saved_language
= 0;
719 static int warned
= 0;
723 /* This can happen when command_line_input hits end of file. */
727 while (*p
== ' ' || *p
== '\t') p
++;
732 c
= lookup_cmd (&p
, cmdlist
, "", 0, 1);
733 /* Pass null arg rather than an empty one. */
735 if (c
->class == class_user
)
737 struct cleanup
*old_chain
;
740 error ("User-defined commands cannot take arguments.");
741 cmdlines
= c
->user_commands
;
746 /* Set the instream to 0, indicating execution of a
747 user-defined function. */
748 old_chain
= make_cleanup (source_cleanup
, instream
);
749 instream
= (FILE *) 0;
752 execute_command (cmdlines
->line
, 0);
753 cmdlines
= cmdlines
->next
;
755 do_cleanups (old_chain
);
757 else if (c
->type
== set_cmd
|| c
->type
== show_cmd
)
758 do_setshow_command (arg
, from_tty
& caution
, c
);
759 else if (c
->function
== NO_FUNCTION
)
760 error ("That is not a command, just a help topic.");
762 (*c
->function
) (arg
, from_tty
& caution
);
765 /* Tell the user if the language has changed (except first time). */
766 if (current_language
!= saved_language
)
768 if (language_mode
== language_mode_auto
) {
772 saved_language
= current_language
;
776 /* Warn the user if the working language does not match the
777 language of the current frame. Only warn the user if we are
778 actually running the program, i.e. there is a stack. */
779 /* FIXME: This should be cacheing the frame and only running when
780 the frame changes. */
781 if (target_has_stack
)
783 flang
= get_frame_language ();
785 && flang
!= language_unknown
786 && flang
!= current_language
->la_language
)
788 printf_filtered ("%s\n", lang_frame_mismatch_warn
);
796 command_loop_marker (foo
)
801 /* Read commands from `instream' and execute them
802 until end of file or error reading instream. */
806 struct cleanup
*old_chain
;
808 int stdin_is_tty
= ISATTY (stdin
);
810 while (!feof (instream
))
812 if (window_hook
&& instream
== stdin
)
813 (*window_hook
) (instream
, prompt
);
816 if (instream
== stdin
&& stdin_is_tty
)
817 reinitialize_more_filter ();
818 old_chain
= make_cleanup (command_loop_marker
, 0);
819 command
= command_line_input (instream
== stdin
? prompt
: 0,
823 execute_command (command
, instream
== stdin
);
824 /* Do any commands attached to breakpoint we stopped at. */
825 bpstat_do_actions (&stop_bpstat
);
826 do_cleanups (old_chain
);
830 /* Commands call this if they do not want to be repeated by null lines. */
835 /* If we aren't reading from standard input, we are saving the last
836 thing read from stdin in line and don't want to delete it. Null lines
837 won't repeat here in any case. */
838 if (instream
== stdin
)
842 /* Read a line from the stream "instream" without command line editing.
844 It prints PRROMPT once at the start.
845 Action is compatible with "readline", e.g. space for the result is
846 malloc'd and should be freed by the caller.
848 A NULL return means end of file. */
850 gdb_readline (prrompt
)
856 int result_size
= 80;
864 result
= (char *) xmalloc (result_size
);
868 /* Read from stdin if we are executing a user defined command.
869 This is the right thing for prompt_for_continue, at least. */
870 c
= fgetc (instream
? instream
: stdin
);
881 result
[input_index
++] = c
;
882 while (input_index
>= result_size
)
885 result
= (char *) xrealloc (result
, result_size
);
889 result
[input_index
++] = '\0';
893 /* Declaration for fancy readline with command line editing. */
896 /* Variables which control command line editing and history
897 substitution. These variables are given default values at the end
899 static int command_editing_p
;
900 static int history_expansion_p
;
901 static int write_history_p
;
902 static int history_size
;
903 static char *history_filename
;
905 /* Variables which are necessary for fancy command line editing. */
906 char *gdb_completer_word_break_characters
=
907 " \t\n!@#$%^&*()-+=|~`}{[]\"';:?/>.<,";
909 /* Functions that are used as part of the fancy command line editing. */
911 /* This can be used for functions which don't want to complete on symbols
912 but don't want to complete on anything else either. */
915 noop_completer (text
)
921 /* Generate symbol names one by one for the completer. If STATE is
922 zero, then we need to initialize, otherwise the initialization has
923 already taken place. TEXT is what we expect the symbol to start
924 with. RL_LINE_BUFFER is available to be looked at; it contains the
925 entire text of the line. RL_POINT is the offset in that line of
926 the cursor. You should pretend that the line ends at RL_POINT.
927 The result is NULL if there are no more completions, else a char
928 string which is a possible completion. */
930 symbol_completion_function (text
, state
)
934 static char **list
= (char **)NULL
;
937 extern char *rl_line_buffer
;
939 char *tmp_command
, *p
;
940 struct cmd_list_element
*c
, *result_list
;
944 /* Free the storage used by LIST, but not by the strings inside. This is
945 because rl_complete_internal () frees the strings. */
951 /* Decide whether to complete on a list of gdb commands or on
953 tmp_command
= (char *) alloca (rl_point
+ 1);
956 strncpy (tmp_command
, rl_line_buffer
, rl_point
);
957 tmp_command
[rl_point
] = '\0';
961 /* An empty line we want to consider ambiguous; that is,
962 it could be any command. */
963 c
= (struct cmd_list_element
*) -1;
967 c
= lookup_cmd_1 (&p
, cmdlist
, &result_list
, 1);
969 /* Move p up to the next interesting thing. */
970 while (*p
== ' ' || *p
== '\t')
974 /* He's typed something unrecognizable. Sigh. */
976 else if (c
== (struct cmd_list_element
*) -1)
978 /* If we didn't recognize everything up to the thing that
979 needs completing, and we don't know what command it is
980 yet, we are in trouble. Part of the trouble might be
981 that the list of delimiters used by readline includes
982 '-', which we use in commands. Check for this. */
983 if (p
+ strlen(text
) != tmp_command
+ rl_point
) {
984 if (tmp_command
[rl_point
- strlen(text
) - 1] == '-')
987 /* This really should not produce an error. Better would
988 be to pretend to hit RETURN here; this would produce a
989 response like "Ambiguous command: foo, foobar, etc",
990 and leave the line available for re-entry with ^P. Instead,
991 this error blows away the user's typed input without
992 any way to get it back. */
993 error (" Unrecognized command.");
997 /* He's typed something ambiguous. This is easier. */
999 list
= complete_on_cmdlist (*result_list
->prefixlist
, text
);
1001 list
= complete_on_cmdlist (cmdlist
, text
);
1005 /* If we've gotten this far, gdb has recognized a full
1006 command. There are several possibilities:
1008 1) We need to complete on the command.
1009 2) We need to complete on the possibilities coming after
1011 2) We need to complete the text of what comes after the
1015 /* Always (might be longer versions of thie command). */
1016 list
= complete_on_cmdlist (result_list
, text
);
1017 else if (!*p
&& !*text
)
1020 list
= complete_on_cmdlist (*c
->prefixlist
, "");
1022 list
= (*c
->completer
) ("");
1026 if (c
->prefixlist
&& !c
->allow_unknown
)
1029 /* Something like "info adsfkdj". But error() is not
1030 the proper response; just return no completions
1033 error ("\"%s\" command requires a subcommand.",
1040 list
= (*c
->completer
) (text
);
1045 /* If the debugged program wasn't compiled with symbols, or if we're
1046 clearly completing on a command and no command matches, return
1049 return ((char *)NULL
);
1051 output
= list
[index
];
1062 #if STOP_SIGNAL == SIGTSTP
1063 signal (SIGTSTP
, SIG_DFL
);
1065 kill (getpid (), SIGTSTP
);
1066 signal (SIGTSTP
, stop_sig
);
1068 signal (STOP_SIGNAL
, stop_sig
);
1070 printf ("%s", prompt
);
1073 /* Forget about any previous command -- null line now will do nothing. */
1076 #endif /* STOP_SIGNAL */
1078 /* Initialize signal handlers. */
1087 extern void request_quit ();
1089 signal (SIGINT
, request_quit
);
1091 /* If we initialize SIGQUIT to SIG_IGN, then the SIG_IGN will get
1092 passed to the inferior, which we don't want. It would be
1093 possible to do a "signal (SIGQUIT, SIG_DFL)" after we fork, but
1094 on BSD4.3 systems using vfork, that can affect the
1095 GDB process as well as the inferior (the signal handling tables
1096 might be in memory, shared between the two). Since we establish
1097 a handler for SIGQUIT, when we call exec it will set the signal
1098 to SIG_DFL for us. */
1099 signal (SIGQUIT
, do_nothing
);
1100 if (signal (SIGHUP
, do_nothing
) != SIG_IGN
)
1101 signal (SIGHUP
, disconnect
);
1102 signal (SIGFPE
, float_handler
);
1105 /* Read one line from the command input stream `instream'
1106 into the local static buffer `linebuffer' (whose current length
1108 The buffer is made bigger as necessary.
1109 Returns the address of the start of the line.
1111 NULL is returned for end of file.
1113 *If* the instream == stdin & stdin is a terminal, the line read
1114 is copied into the file line saver (global var char *line,
1115 length linesize) so that it can be duplicated.
1117 This routine either uses fancy command line editing or
1118 simple input as the user has requested. */
1121 command_line_input (prrompt
, repeat
)
1125 static char *linebuffer
= 0;
1126 static int linelength
= 0;
1130 char *local_prompt
= prrompt
;
1135 if (linebuffer
== 0)
1138 linebuffer
= (char *) xmalloc (linelength
);
1143 /* Control-C quits instantly if typed while in this loop
1144 since it should not wait until the user types a newline. */
1147 signal (STOP_SIGNAL
, stop_sig
);
1152 /* Reports are that some Sys V's don't flush stdout/err on reads
1153 from stdin, when stdin/out are sockets rather than ttys. So we
1154 have to do it ourselves, to make emacs-gdb and xxgdb work.
1155 On other machines, doing this once per input should be a cheap nop. */
1159 /* Don't use fancy stuff if not talking to stdin. */
1160 if (command_editing_p
&& instream
== stdin
1161 && ISATTY (instream
))
1162 rl
= readline (local_prompt
);
1164 rl
= gdb_readline (local_prompt
);
1166 if (!rl
|| rl
== (char *) EOF
)
1171 if (strlen(rl
) + 1 + (p
- linebuffer
) > linelength
)
1173 linelength
= strlen(rl
) + 1 + (p
- linebuffer
);
1174 nline
= (char *) xrealloc (linebuffer
, linelength
);
1175 p
+= nline
- linebuffer
;
1179 /* Copy line. Don't copy null at end. (Leaves line alone
1180 if this was just a newline) */
1184 free (rl
); /* Allocated in readline. */
1186 if (p
== linebuffer
|| *(p
- 1) != '\\')
1189 p
--; /* Put on top of '\'. */
1190 local_prompt
= (char *) 0;
1194 signal (SIGTSTP
, SIG_DFL
);
1201 /* Do history expansion if that is wished. */
1202 if (history_expansion_p
&& instream
== stdin
1203 && ISATTY (instream
))
1205 char *history_value
;
1208 *p
= '\0'; /* Insert null now. */
1209 expanded
= history_expand (linebuffer
, &history_value
);
1212 /* Print the changes. */
1213 printf ("%s\n", history_value
);
1215 /* If there was an error, call this function again. */
1218 free (history_value
);
1219 return command_line_input (prrompt
, repeat
);
1221 if (strlen (history_value
) > linelength
)
1223 linelength
= strlen (history_value
) + 1;
1224 linebuffer
= (char *) xrealloc (linebuffer
, linelength
);
1226 strcpy (linebuffer
, history_value
);
1227 p
= linebuffer
+ strlen(linebuffer
);
1228 free (history_value
);
1232 /* If we just got an empty line, and that is supposed
1233 to repeat the previous command, return the value in the
1237 if (p
== linebuffer
)
1240 while (*p1
== ' ' || *p1
== '\t')
1248 /* Add line to history if appropriate. */
1249 if (instream
== stdin
1250 && ISATTY (stdin
) && *linebuffer
)
1251 add_history (linebuffer
);
1253 /* Note: lines consisting soley of comments are added to the command
1254 history. This is useful when you type a command, and then
1255 realize you don't want to execute it quite yet. You can comment
1256 out the command and then later fetch it from the value history
1257 and remove the '#'. The kill ring is probably better, but some
1258 people are in the habit of commenting things out. */
1260 while ((c
= *p1
++) != '\0')
1263 while ((c
= *p1
++) != '"')
1265 /* Make sure an escaped '"' doesn't make us think the string
1273 while ((c
= *p1
++) != '\'')
1275 /* Make sure an escaped '\'' doesn't make us think the string
1284 /* Found a comment. */
1290 /* Save into global buffer if appropriate. */
1293 if (linelength
> linesize
)
1295 line
= xrealloc (line
, linelength
);
1296 linesize
= linelength
;
1298 strcpy (line
, linebuffer
);
1305 /* Read lines from the input stream
1306 and accumulate them in a chain of struct command_line's
1307 which is then returned. */
1309 struct command_line
*
1310 read_command_lines ()
1312 struct command_line
*first
= 0;
1313 register struct command_line
*next
, *tail
= 0;
1314 register char *p
, *p1
;
1315 struct cleanup
*old_chain
= 0;
1320 p
= command_line_input (0, instream
== stdin
);
1322 /* Treat end of file like "end". */
1325 /* Remove leading and trailing blanks. */
1326 while (*p
== ' ' || *p
== '\t') p
++;
1327 p1
= p
+ strlen (p
);
1328 while (p1
!= p
&& (p1
[-1] == ' ' || p1
[-1] == '\t')) p1
--;
1330 /* Is this "end"? */
1331 if (p1
- p
== 3 && !strncmp (p
, "end", 3))
1334 /* No => add this line to the chain of command lines. */
1335 next
= (struct command_line
*) xmalloc (sizeof (struct command_line
));
1336 next
->line
= savestring (p
, p1
- p
);
1344 /* We just read the first line.
1345 From now on, arrange to throw away the lines we have
1346 if we quit or get an error while inside this function. */
1348 old_chain
= make_cleanup (free_command_lines
, &first
);
1355 /* Now we are about to return the chain to our caller,
1356 so freeing it becomes his responsibility. */
1358 discard_cleanups (old_chain
);
1362 /* Free a chain of struct command_line's. */
1365 free_command_lines (lptr
)
1366 struct command_line
**lptr
;
1368 register struct command_line
*l
= *lptr
;
1369 register struct command_line
*next
;
1380 /* Add an element to the list of info subcommands. */
1383 add_info (name
, fun
, doc
)
1388 add_cmd (name
, no_class
, fun
, doc
, &infolist
);
1391 /* Add an alias to the list of info subcommands. */
1394 add_info_alias (name
, oldname
, abbrev_flag
)
1399 add_alias_cmd (name
, oldname
, 0, abbrev_flag
, &infolist
);
1402 /* The "info" command is defined as a prefix, with allow_unknown = 0.
1403 Therefore, its own definition is called only for "info" with no args. */
1407 info_command (arg
, from_tty
)
1411 printf ("\"info\" must be followed by the name of an info command.\n");
1412 help_list (infolist
, "info ", -1, stdout
);
1415 /* The "show" command with no arguments shows all the settings. */
1419 show_command (arg
, from_tty
)
1423 cmd_show_list (showlist
, from_tty
, "");
1426 /* Add an element to the list of commands. */
1429 add_com (name
, class, fun
, doc
)
1431 enum command_class
class;
1435 add_cmd (name
, class, fun
, doc
, &cmdlist
);
1438 /* Add an alias or abbreviation command to the list of commands. */
1441 add_com_alias (name
, oldname
, class, abbrev_flag
)
1444 enum command_class
class;
1447 add_alias_cmd (name
, oldname
, class, abbrev_flag
, &cmdlist
);
1454 error ("Argument required (%s).", why
);
1459 help_command (command
, from_tty
)
1461 int from_tty
; /* Ignored */
1463 help_cmd (command
, stdout
);
1467 validate_comname (comname
)
1473 error_no_arg ("name of command to define");
1478 if (!(*p
>= 'A' && *p
<= 'Z')
1479 && !(*p
>= 'a' && *p
<= 'z')
1480 && !(*p
>= '0' && *p
<= '9')
1482 error ("Junk in argument list: \"%s\"", p
);
1488 define_command (comname
, from_tty
)
1492 register struct command_line
*cmds
;
1493 register struct cmd_list_element
*c
, *newc
;
1494 char *tem
= comname
;
1495 extern void not_just_help_class_command ();
1497 validate_comname (comname
);
1499 /* Look it up, and verify that we got an exact match. */
1500 c
= lookup_cmd (&tem
, cmdlist
, "", -1, 1);
1501 if (c
&& 0 != strcmp (comname
, c
->name
))
1506 if (c
->class == class_user
|| c
->class == class_alias
)
1507 tem
= "Redefine command \"%s\"? ";
1509 tem
= "Really redefine built-in command \"%s\"? ";
1510 if (!query (tem
, comname
))
1511 error ("Command \"%s\" not redefined.", comname
);
1516 printf ("Type commands for definition of \"%s\".\n\
1517 End with a line saying just \"end\".\n", comname
);
1520 comname
= savestring (comname
, strlen (comname
));
1522 cmds
= read_command_lines ();
1524 if (c
&& c
->class == class_user
)
1525 free_command_lines (&c
->user_commands
);
1527 newc
= add_cmd (comname
, class_user
, not_just_help_class_command
,
1528 (c
&& c
->class == class_user
)
1529 ? c
->doc
: savestring ("User-defined.", 13), &cmdlist
);
1530 newc
->user_commands
= cmds
;
1534 document_command (comname
, from_tty
)
1538 struct command_line
*doclines
;
1539 register struct cmd_list_element
*c
;
1540 char *tem
= comname
;
1542 validate_comname (comname
);
1544 c
= lookup_cmd (&tem
, cmdlist
, "", 0, 1);
1546 if (c
->class != class_user
)
1547 error ("Command \"%s\" is built-in.", comname
);
1550 printf ("Type documentation for \"%s\".\n\
1551 End with a line saying just \"end\".\n", comname
);
1553 doclines
= read_command_lines ();
1555 if (c
->doc
) free (c
->doc
);
1558 register struct command_line
*cl1
;
1559 register int len
= 0;
1561 for (cl1
= doclines
; cl1
; cl1
= cl1
->next
)
1562 len
+= strlen (cl1
->line
) + 1;
1564 c
->doc
= (char *) xmalloc (len
+ 1);
1567 for (cl1
= doclines
; cl1
; cl1
= cl1
->next
)
1569 strcat (c
->doc
, cl1
->line
);
1571 strcat (c
->doc
, "\n");
1575 free_command_lines (&doclines
);
1579 print_gnu_advertisement()
1582 GDB is free software and you are welcome to distribute copies of it\n\
1583 under certain conditions; type \"show copying\" to see the conditions.\n\
1584 There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\
1589 print_gdb_version ()
1592 GDB %s, Copyright 1991 Free Software Foundation, Inc.",
1598 show_version (args
, from_tty
)
1603 print_gnu_advertisement ();
1604 print_gdb_version ();
1605 printf_filtered ("\n");
1609 /* xgdb calls this to reprint the usual GDB prompt. */
1614 printf ("%s", prompt
);
1619 quit_command (args
, from_tty
)
1623 if (inferior_pid
!= 0 && target_has_execution
)
1625 if (query ("The program is running. Quit anyway? "))
1627 target_kill (args
, from_tty
);
1630 error ("Not confirmed.");
1632 /* Save the history information if it is appropriate to do so. */
1633 if (write_history_p
&& history_filename
)
1634 write_history (history_filename
);
1639 input_from_terminal_p ()
1641 return (instream
== stdin
) & caution
;
1646 pwd_command (args
, from_tty
)
1650 if (args
) error ("The \"pwd\" command does not take an argument: %s", args
);
1653 if (strcmp (dirbuf
, current_directory
))
1654 printf ("Working directory %s\n (canonically %s).\n",
1655 current_directory
, dirbuf
);
1657 printf ("Working directory %s.\n", current_directory
);
1661 cd_command (dir
, from_tty
)
1668 /* If the new directory is absolute, repeat is a no-op; if relative,
1669 repeat might be useful but is more likely to be a mistake. */
1673 error_no_arg ("new working directory");
1675 dir
= tilde_expand (dir
);
1676 make_cleanup (free
, dir
);
1679 dir
= savestring (dir
, len
- (len
> 1 && dir
[len
-1] == '/'));
1681 current_directory
= dir
;
1684 current_directory
= concat (current_directory
, "/", dir
);
1688 /* Now simplify any occurrences of `.' and `..' in the pathname. */
1696 for (p
= current_directory
; *p
;)
1698 if (!strncmp (p
, "/./", 2)
1699 && (p
[2] == 0 || p
[2] == '/'))
1701 else if (!strncmp (p
, "/..", 3)
1702 && (p
[3] == 0 || p
[3] == '/')
1703 && p
!= current_directory
)
1706 while (q
!= current_directory
&& q
[-1] != '/') q
--;
1707 if (q
!= current_directory
)
1717 if (chdir (dir
) < 0)
1718 perror_with_name (dir
);
1720 forget_cached_source_info ();
1723 pwd_command ((char *) 0, 1);
1728 source_command (args
, from_tty
)
1733 struct cleanup
*cleanups
;
1737 /* Let source without arguments read .gdbinit. */
1740 file
= tilde_expand (file
);
1741 make_cleanup (free
, file
);
1743 stream
= fopen (file
, "r");
1745 perror_with_name (file
);
1747 cleanups
= make_cleanup (fclose
, stream
);
1749 read_command_file (stream
);
1751 do_cleanups (cleanups
);
1756 echo_command (text
, from_tty
)
1768 /* \ at end of argument is used after spaces
1769 so they won't be lost. */
1773 c
= parse_escape (&p
);
1775 printf_filtered ("%c", c
);
1778 printf_filtered ("%c", c
);
1781 /* Force this output to appear now. */
1788 dump_me_command (args
, from_tty
)
1792 if (query ("Should GDB dump core? "))
1794 signal (SIGQUIT
, SIG_DFL
);
1795 kill (getpid (), SIGQUIT
);
1799 /* Functions to manipulate command line editing control variables. */
1801 /* Number of commands to print in each call to show_commands. */
1802 #define Hist_print 10
1804 show_commands (args
, from_tty
)
1808 /* Index for history commands. Relative to history_base. */
1811 /* Number of the history entry which we are planning to display next.
1812 Relative to history_base. */
1815 /* The first command in the history which doesn't exist (i.e. one more
1816 than the number of the last command). Relative to history_base. */
1819 struct _hist_entry
*history_get();
1820 extern int history_base
;
1823 /* This is all reported by individual "show" commands. */
1824 printf_filtered ("Interactive command editing is %s.\n",
1825 command_editing_p
? "on" : "off");
1827 printf_filtered ("History expansion of command input is %s.\n",
1828 history_expansion_p
? "on" : "off");
1829 printf_filtered ("Writing of a history record upon exit is %s.\n",
1830 write_history_p
? "enabled" : "disabled");
1831 printf_filtered ("The size of the history list (number of stored commands) is %d.\n",
1833 printf_filtered ("The name of the history record is \"%s\".\n\n",
1834 history_filename
? history_filename
: "");
1837 /* Print out some of the commands from the command history. */
1838 /* First determine the length of the history list. */
1839 hist_len
= history_size
;
1840 for (offset
= 0; offset
< history_size
; offset
++)
1842 if (!history_get (history_base
+ offset
))
1851 if (args
[0] == '+' && args
[1] == '\0')
1852 /* "info editing +" should print from the stored position. */
1855 /* "info editing <exp>" should print around command number <exp>. */
1856 num
= (parse_and_eval_address (args
) - history_base
) - Hist_print
/ 2;
1858 /* "info editing" means print the last Hist_print commands. */
1861 num
= hist_len
- Hist_print
;
1867 /* If there are at least Hist_print commands, we want to display the last
1868 Hist_print rather than, say, the last 6. */
1869 if (hist_len
- num
< Hist_print
)
1871 num
= hist_len
- Hist_print
;
1877 /* No need for a header now that "info editing" only prints one thing. */
1878 if (num
== hist_len
- Hist_print
)
1879 printf_filtered ("The list of the last %d commands is:\n\n", Hist_print
);
1881 printf_filtered ("Some of the stored commands are:\n\n");
1884 for (offset
= num
; offset
< num
+ Hist_print
&& offset
< hist_len
; offset
++)
1886 printf_filtered ("%5d %s\n", history_base
+ offset
,
1887 (history_get (history_base
+ offset
))->line
);
1890 /* The next command we want to display is the next one that we haven't
1894 /* If the user repeats this command with return, it should do what
1895 "info editing +" does. This is unnecessary if arg is null,
1896 because "info editing +" is not useful after "info editing". */
1897 if (from_tty
&& args
)
1904 /* Called by do_setshow_command. */
1907 set_history_size_command (args
, from_tty
, c
)
1910 struct cmd_list_element
*c
;
1912 if (history_size
== UINT_MAX
)
1913 unstifle_history ();
1915 stifle_history (history_size
);
1920 set_history (args
, from_tty
)
1924 printf ("\"set history\" must be followed by the name of a history subcommand.\n");
1925 help_list (sethistlist
, "set history ", -1, stdout
);
1930 show_history (args
, from_tty
)
1934 cmd_show_list (showhistlist
, from_tty
, "");
1937 int info_verbose
= 0; /* Default verbose msgs off */
1939 /* Called by do_setshow_command. An elaborate joke. */
1942 set_verbose (args
, from_tty
, c
)
1945 struct cmd_list_element
*c
;
1947 char *cmdname
= "verbose";
1948 struct cmd_list_element
*showcmd
;
1950 showcmd
= lookup_cmd_1 (&cmdname
, showlist
, NULL
, 1);
1954 c
->doc
= "Set verbose printing of informational messages.";
1955 showcmd
->doc
= "Show verbose printing of informational messages.";
1959 c
->doc
= "Set verbosity.";
1960 showcmd
->doc
= "Show verbosity.";
1967 /* This message is based on ANSI C, section 4.7. Note that integer
1968 divide by zero causes this, so "float" is a misnomer. */
1969 error ("Erroneous arithmetic operation.");
1972 /* Return whether we are running a batch file or from terminal. */
1976 return !(instream
== stdin
&& ISATTY (stdin
));
1981 initialize_cmd_lists ()
1983 cmdlist
= (struct cmd_list_element
*) 0;
1984 infolist
= (struct cmd_list_element
*) 0;
1985 enablelist
= (struct cmd_list_element
*) 0;
1986 disablelist
= (struct cmd_list_element
*) 0;
1987 deletelist
= (struct cmd_list_element
*) 0;
1988 enablebreaklist
= (struct cmd_list_element
*) 0;
1989 setlist
= (struct cmd_list_element
*) 0;
1991 sethistlist
= (struct cmd_list_element
*) 0;
1992 showhistlist
= NULL
;
1993 unsethistlist
= (struct cmd_list_element
*) 0;
1999 struct cmd_list_element
*c
;
2003 #ifdef DEFAULT_PROMPT
2004 prompt
= savestring (DEFAULT_PROMPT
, strlen(DEFAULT_PROMPT
));
2006 prompt
= savestring ("(gdb) ", 6);
2009 /* Set the important stuff up for command editing. */
2010 command_editing_p
= 1;
2011 history_expansion_p
= 0;
2012 write_history_p
= 0;
2014 if (tmpenv
= getenv ("HISTSIZE"))
2015 history_size
= atoi (tmpenv
);
2019 stifle_history (history_size
);
2021 if (tmpenv
= getenv ("GDBHISTFILE"))
2022 history_filename
= savestring (tmpenv
, strlen(tmpenv
));
2024 /* We include the current directory so that if the user changes
2025 directories the file written will be the same as the one
2027 history_filename
= concat (current_directory
, "/.gdb_history", "");
2029 read_history (history_filename
);
2031 /* Setup important stuff for command line editing. */
2032 rl_completion_entry_function
= (int (*)()) symbol_completion_function
;
2033 rl_completer_word_break_characters
= gdb_completer_word_break_characters
;
2034 rl_readline_name
= "gdb";
2036 /* Define the classes of commands.
2037 They will appear in the help list in the reverse of this order. */
2039 add_cmd ("obscure", class_obscure
, NO_FUNCTION
, "Obscure features.", &cmdlist
);
2040 add_cmd ("aliases", class_alias
, NO_FUNCTION
, "Aliases of other commands.", &cmdlist
);
2041 add_cmd ("user-defined", class_user
, NO_FUNCTION
, "User-defined commands.\n\
2042 The commands in this class are those defined by the user.\n\
2043 Use the \"define\" command to define a command.", &cmdlist
);
2044 add_cmd ("support", class_support
, NO_FUNCTION
, "Support facilities.", &cmdlist
);
2045 add_cmd ("status", class_info
, NO_FUNCTION
, "Status inquiries.", &cmdlist
);
2046 add_cmd ("files", class_files
, NO_FUNCTION
, "Specifying and examining files.", &cmdlist
);
2047 add_cmd ("breakpoints", class_breakpoint
, NO_FUNCTION
, "Making program stop at certain points.", &cmdlist
);
2048 add_cmd ("data", class_vars
, NO_FUNCTION
, "Examining data.", &cmdlist
);
2049 add_cmd ("stack", class_stack
, NO_FUNCTION
, "Examining the stack.\n\
2050 The stack is made up of stack frames. Gdb assigns numbers to stack frames\n\
2051 counting from zero for the innermost (currently executing) frame.\n\n\
2052 At any time gdb identifies one frame as the \"selected\" frame.\n\
2053 Variable lookups are done with respect to the selected frame.\n\
2054 When the program being debugged stops, gdb selects the innermost frame.\n\
2055 The commands below can be used to select other frames by number or address.",
2057 add_cmd ("running", class_run
, NO_FUNCTION
, "Running the program.", &cmdlist
);
2059 add_com ("pwd", class_files
, pwd_command
,
2060 "Print working directory. This is used for your program as well.");
2061 add_com ("cd", class_files
, cd_command
,
2062 "Set working directory to DIR for debugger and program being debugged.\n\
2063 The change does not take effect for the program being debugged\n\
2064 until the next time it is started.");
2067 (add_set_cmd ("prompt", class_support
, var_string
, (char *)&prompt
,
2072 add_com ("echo", class_support
, echo_command
,
2073 "Print a constant string. Give string as argument.\n\
2074 C escape sequences may be used in the argument.\n\
2075 No newline is added at the end of the argument;\n\
2076 use \"\\n\" if you want a newline to be printed.\n\
2077 Since leading and trailing whitespace are ignored in command arguments,\n\
2078 if you want to print some you must use \"\\\" before leading whitespace\n\
2079 to be printed or after trailing whitespace.");
2080 add_com ("document", class_support
, document_command
,
2081 "Document a user-defined command.\n\
2082 Give command name as argument. Give documentation on following lines.\n\
2083 End with a line of just \"end\".");
2084 add_com ("define", class_support
, define_command
,
2085 "Define a new command name. Command name is argument.\n\
2086 Definition appears on following lines, one command per line.\n\
2087 End with a line of just \"end\".\n\
2088 Use the \"document\" command to give documentation for the new command.\n\
2089 Commands defined in this way do not take arguments.");
2092 add_com ("source", class_support
, source_command
,
2093 "Read commands from a file named FILE.\n\
2094 Note that the file \"" GDBINIT_FILENAME
"\" is read automatically in this way\n\
2095 when gdb is started.");
2097 /* Punt file name, we can't help it easily. */
2098 add_com ("source", class_support
, source_command
,
2099 "Read commands from a file named FILE.\n\
2100 Note that the file \".gdbinit\" is read automatically in this way\n\
2101 when gdb is started.");
2104 add_com ("quit", class_support
, quit_command
, "Exit gdb.");
2105 add_com ("help", class_support
, help_command
, "Print list of commands.");
2106 add_com_alias ("q", "quit", class_support
, 1);
2107 add_com_alias ("h", "help", class_support
, 1);
2110 c
= add_set_cmd ("verbose", class_support
, var_boolean
, (char *)&info_verbose
,
2113 add_show_from_set (c
, &showlist
);
2114 c
->function
= set_verbose
;
2115 set_verbose (NULL
, 0, c
);
2117 add_com ("dump-me", class_obscure
, dump_me_command
,
2118 "Get fatal error; make debugger dump its core.");
2121 (add_set_cmd ("editing", class_support
, var_boolean
, (char *)&command_editing_p
,
2122 "Set command line editing.\n\
2123 Use \"on\" to enable to enable the editing, and \"off\" to disable it.\n\
2124 Without an argument, command line editing is enabled.", &setlist
),
2127 add_prefix_cmd ("history", class_support
, set_history
,
2128 "Generic command for setting command history parameters.",
2129 &sethistlist
, "set history ", 0, &setlist
);
2130 add_prefix_cmd ("history", class_support
, show_history
,
2131 "Generic command for showing command history parameters.",
2132 &showhistlist
, "show history ", 0, &showlist
);
2135 (add_set_cmd ("expansion", no_class
, var_boolean
, (char *)&history_expansion_p
,
2136 "Set history expansion on command input.\n\
2137 Without an argument, history expansion is enabled.", &sethistlist
),
2141 (add_set_cmd ("save", no_class
, var_boolean
, (char *)&write_history_p
,
2142 "Set saving of the history record on exit.\n\
2143 Use \"on\" to enable to enable the saving, and \"off\" to disable it.\n\
2144 Without an argument, saving is enabled.", &sethistlist
),
2147 c
= add_set_cmd ("size", no_class
, var_uinteger
, (char *)&history_size
,
2148 "Set the size of the command history, \n\
2149 ie. the number of previous commands to keep a record of.", &sethistlist
);
2150 add_show_from_set (c
, &showhistlist
);
2151 c
->function
= set_history_size_command
;
2154 (add_set_cmd ("filename", no_class
, var_filename
, (char *)&history_filename
,
2155 "Set the filename in which to record the command history\n\
2156 (the list of previous commands of which a record is kept).", &sethistlist
),
2160 (add_set_cmd ("confirm", class_support
, var_boolean
,
2162 "Set whether to confirm potentially dangerous operations.",
2166 add_prefix_cmd ("info", class_info
, info_command
,
2167 "Generic command for printing status.",
2168 &infolist
, "info ", 0, &cmdlist
);
2169 add_com_alias ("i", "info", class_info
, 1);
2171 add_prefix_cmd ("show", class_info
, show_command
,
2172 "Generic command for showing things set with \"set\".",
2173 &showlist
, "show ", 0, &cmdlist
);
2174 /* Another way to get at the same thing. */
2175 add_info ("set", show_command
, "Show all GDB settings.");
2177 add_cmd ("commands", no_class
, show_commands
, "Status of command editor.",
2180 add_cmd ("version", no_class
, show_version
,
2181 "Report what version of GDB this is.", &showlist
);