1 /* Top level stuff for GDB, the GNU debugger.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
23 #include "call-cmds.h"
28 #include "breakpoint.h"
30 #include "expression.h"
33 #include "terminal.h" /* For job_control. */
38 /* readline include files */
42 /* readline defines this. */
45 #include <sys/types.h>
47 /* What is this for? X_OK? */
55 #include <sys/param.h>
59 /* Prototypes for local functions */
61 static char * symbol_completion_function
PARAMS ((char *, int));
63 static void command_loop_marker
PARAMS ((int));
65 static void while_command
PARAMS ((char *, int));
67 static void if_command
PARAMS ((char *, int));
69 static enum command_control_type
70 execute_control_command
PARAMS ((struct command_line
*));
72 static struct command_line
*
73 build_command_line
PARAMS ((enum command_control_type
, char *));
75 static struct command_line
*
76 get_command_line
PARAMS ((enum command_control_type
, char *));
78 static void realloc_body_list
PARAMS ((struct command_line
*, int));
80 static enum misc_command_type read_next_line
PARAMS ((struct command_line
**));
82 static enum command_control_type
83 recurse_read_control_structure
PARAMS ((struct command_line
*));
85 static void init_main
PARAMS ((void));
87 static void init_cmd_lists
PARAMS ((void));
89 static void float_handler
PARAMS ((int));
91 static void init_signals
PARAMS ((void));
93 static void set_verbose
PARAMS ((char *, int, struct cmd_list_element
*));
95 static void show_history
PARAMS ((char *, int));
97 static void set_history
PARAMS ((char *, int));
99 static void set_history_size_command
PARAMS ((char *, int,
100 struct cmd_list_element
*));
102 static void show_commands
PARAMS ((char *, int));
104 static void echo_command
PARAMS ((char *, int));
106 static void pwd_command
PARAMS ((char *, int));
108 static void show_version
PARAMS ((char *, int));
110 static void document_command
PARAMS ((char *, int));
112 static void define_command
PARAMS ((char *, int));
114 static void validate_comname
PARAMS ((char *));
116 static void help_command
PARAMS ((char *, int));
118 static void show_command
PARAMS ((char *, int));
120 static void info_command
PARAMS ((char *, int));
122 static void complete_command
PARAMS ((char *, int));
124 static void do_nothing
PARAMS ((int));
126 static int quit_cover
PARAMS ((char *));
128 static void disconnect
PARAMS ((int));
130 static void source_cleanup
PARAMS ((FILE *));
132 /* If this definition isn't overridden by the header files, assume
133 that isatty and fileno exist on this system. */
135 #define ISATTY(FP) (isatty (fileno (FP)))
138 /* Initialization file name for gdb. This is overridden in some configs. */
140 #ifndef GDBINIT_FILENAME
141 #define GDBINIT_FILENAME ".gdbinit"
143 char gdbinit
[] = GDBINIT_FILENAME
;
144 int inhibit_gdbinit
= 0;
146 /* Disable windows if non-zero */
150 /* Version number of GDB, as a string. */
152 extern char *version
;
154 /* Canonical host name as a string. */
156 extern char *host_name
;
158 /* Canonical target name as a string. */
160 extern char *target_name
;
162 extern char lang_frame_mismatch_warn
[]; /* language.c */
164 /* Flag for whether we want all the "from_tty" gubbish printed. */
166 int caution
= 1; /* Default is yes, sigh. */
169 * Define all cmd_list_element's
172 /* Chain containing all defined commands. */
174 struct cmd_list_element
*cmdlist
;
176 /* Chain containing all defined info subcommands. */
178 struct cmd_list_element
*infolist
;
180 /* Chain containing all defined enable subcommands. */
182 struct cmd_list_element
*enablelist
;
184 /* Chain containing all defined disable subcommands. */
186 struct cmd_list_element
*disablelist
;
188 /* Chain containing all defined delete subcommands. */
190 struct cmd_list_element
*deletelist
;
192 /* Chain containing all defined "enable breakpoint" subcommands. */
194 struct cmd_list_element
*enablebreaklist
;
196 /* Chain containing all defined set subcommands */
198 struct cmd_list_element
*setlist
;
200 /* Chain containing all defined unset subcommands */
202 struct cmd_list_element
*unsetlist
;
204 /* Chain containing all defined show subcommands. */
206 struct cmd_list_element
*showlist
;
208 /* Chain containing all defined \"set history\". */
210 struct cmd_list_element
*sethistlist
;
212 /* Chain containing all defined \"show history\". */
214 struct cmd_list_element
*showhistlist
;
216 /* Chain containing all defined \"unset history\". */
218 struct cmd_list_element
*unsethistlist
;
220 /* Chain containing all defined maintenance subcommands. */
223 struct cmd_list_element
*maintenancelist
;
226 /* Chain containing all defined "maintenance info" subcommands. */
229 struct cmd_list_element
*maintenanceinfolist
;
232 /* Chain containing all defined "maintenance print" subcommands. */
235 struct cmd_list_element
*maintenanceprintlist
;
238 struct cmd_list_element
*setprintlist
;
240 struct cmd_list_element
*showprintlist
;
242 struct cmd_list_element
*setchecklist
;
244 struct cmd_list_element
*showchecklist
;
246 /* stdio stream that command input is being read from. Set to stdin normally.
247 Set by source_command to the file we are sourcing. Set to NULL if we are
248 executing a user-defined command. */
252 /* Current working directory. */
254 char *current_directory
;
256 /* The directory name is actually stored here (usually). */
257 char gdb_dirbuf
[1024];
259 /* Function to call before reading a command, if nonzero.
260 The function receives two args: an input stream,
261 and a prompt string. */
263 void (*window_hook
) PARAMS ((FILE *, char *));
268 /* gdb prints this when reading a command interactively */
271 /* Buffer used for reading command lines, and the size
272 allocated for it so far. */
277 /* Nonzero if the current command is modified by "server ". This
278 affects things like recording into the command history, comamnds
279 repeating on RETURN, etc. This is so a user interface (emacs, GUI,
280 whatever) can issue its own commands and also send along commands
281 from the user, and have the user not notice that the user interface
282 is issuing commands too. */
285 /* Baud rate specified for talking to serial target systems. Default
286 is left as -1, so targets can choose their own defaults. */
287 /* FIXME: This means that "show remotebaud" and gr_files_info can print -1
288 or (unsigned int)-1. This is a Bad User Interface. */
292 /* Non-zero tells remote* modules to output debugging info. */
294 int remote_debug
= 0;
296 /* Level of control structure. */
297 static int control_level
;
299 /* Signal to catch ^Z typed while reading a command: SIGTSTP or SIGCONT. */
303 #define STOP_SIGNAL SIGTSTP
304 static void stop_sig
PARAMS ((int));
308 /* Some System V have job control but not sigsetmask(). */
309 #if !defined (HAVE_SIGSETMASK)
311 #define HAVE_SIGSETMASK 1
313 #define HAVE_SIGSETMASK 0
317 #if 0 == (HAVE_SIGSETMASK)
318 #define sigsetmask(n)
321 /* Hooks for alternate command interfaces. */
323 /* Called after most modules have been initialized, but before taking users
326 void (*init_ui_hook
) PARAMS ((void));
328 /* Called instead of command_loop at top level. Can be invoked via
329 return_to_top_level. */
331 void (*command_loop_hook
) PARAMS ((void));
333 /* Called instead of fputs for all output. */
335 void (*fputs_unfiltered_hook
) PARAMS ((const char *linebuffer
));
337 /* Called from print_frame_info to list the line we stopped in. */
339 void (*print_frame_info_listing_hook
) PARAMS ((struct symtab
*s
, int line
,
340 int stopline
, int noerror
));
341 /* Replaces most of query. */
343 int (*query_hook
) PARAMS (());
345 /* Called from gdb_flush to flush output. */
347 void (*flush_hook
) PARAMS ((FILE *stream
));
349 /* Called as appropriate to notify the interface of the specified breakpoint
352 void (*create_breakpoint_hook
) PARAMS ((struct breakpoint
*bpt
));
353 void (*delete_breakpoint_hook
) PARAMS ((struct breakpoint
*bpt
));
354 void (*enable_breakpoint_hook
) PARAMS ((struct breakpoint
*bpt
));
355 void (*disable_breakpoint_hook
) PARAMS ((struct breakpoint
*bpt
));
357 /* Called during long calculations to allow GUI to repair window damage, and to
358 check for stop buttons, etc... */
360 void (*interactive_hook
) PARAMS ((void));
363 /* Where to go for return_to_top_level (RETURN_ERROR). */
364 jmp_buf error_return
;
365 /* Where to go for return_to_top_level (RETURN_QUIT). */
368 /* Return for reason REASON. This generally gets back to the command
369 loop, but can be caught via catch_errors. */
372 return_to_top_level (reason
)
373 enum return_reason reason
;
378 /* Perhaps it would be cleaner to do this via the cleanup chain (not sure
379 I can think of a reason why that is vital, though). */
380 bpstat_clear_actions(stop_bpstat
); /* Clear queued breakpoint commands */
382 disable_current_display ();
383 do_cleanups (ALL_CLEANUPS
);
385 if (annotation_level
> 1)
396 (NORETURN
void) longjmp
397 (reason
== RETURN_ERROR
? error_return
: quit_return
, 1);
400 /* Call FUNC with arg ARGS, catching any errors. If there is no
401 error, return the value returned by FUNC. If there is an error,
402 print ERRSTRING, print the specific error message, then return
405 Must not be called with immediate_quit in effect (bad things might
406 happen, say we got a signal in the middle of a memcpy to quit_return).
407 This is an OK restriction; with very few exceptions immediate_quit can
408 be replaced by judicious use of QUIT.
410 MASK specifies what to catch; it is normally set to
411 RETURN_MASK_ALL, if for no other reason than that the code which
412 calls catch_errors might not be set up to deal with a quit which
413 isn't caught. But if the code can deal with it, it generally
414 should be RETURN_MASK_ERROR, unless for some reason it is more
415 useful to abort only the portion of the operation inside the
416 catch_errors. Note that quit should return to the command line
417 fairly quickly, even if some further processing is being done. */
420 catch_errors (func
, args
, errstring
, mask
)
421 int (*func
) PARAMS ((char *));
430 struct cleanup
*saved_cleanup_chain
;
431 char *saved_error_pre_print
;
433 saved_cleanup_chain
= save_cleanups ();
434 saved_error_pre_print
= error_pre_print
;
436 if (mask
& RETURN_MASK_ERROR
)
437 memcpy ((char *)saved_error
, (char *)error_return
, sizeof (jmp_buf));
438 if (mask
& RETURN_MASK_QUIT
)
439 memcpy (saved_quit
, quit_return
, sizeof (jmp_buf));
440 error_pre_print
= errstring
;
442 if (setjmp (tmp_jmp
) == 0)
444 if (mask
& RETURN_MASK_ERROR
)
445 memcpy (error_return
, tmp_jmp
, sizeof (jmp_buf));
446 if (mask
& RETURN_MASK_QUIT
)
447 memcpy (quit_return
, tmp_jmp
, sizeof (jmp_buf));
448 val
= (*func
) (args
);
453 restore_cleanups (saved_cleanup_chain
);
455 error_pre_print
= saved_error_pre_print
;
456 if (mask
& RETURN_MASK_ERROR
)
457 memcpy (error_return
, saved_error
, sizeof (jmp_buf));
458 if (mask
& RETURN_MASK_QUIT
)
459 memcpy (quit_return
, saved_quit
, sizeof (jmp_buf));
463 /* Handler for SIGHUP. */
469 catch_errors (quit_cover
, NULL
,
470 "Could not kill the program being debugged", RETURN_MASK_ALL
);
471 signal (SIGHUP
, SIG_DFL
);
472 kill (getpid (), SIGHUP
);
475 /* Just a little helper function for disconnect(). */
481 caution
= 0; /* Throw caution to the wind -- we're exiting.
482 This prevents asking the user dumb questions. */
483 quit_command((char *)0, 0);
487 /* Line number we are currently in in a file which is being sourced. */
488 static int source_line_number
;
490 /* Name of the file we are sourcing. */
491 static char *source_file_name
;
493 /* Buffer containing the error_pre_print used by the source stuff.
495 static char *source_error
;
496 static int source_error_allocated
;
498 /* Something to glom on to the start of error_pre_print if source_file_name
500 static char *source_pre_error
;
502 /* Clean up on error during a "source" command (or execution of a
503 user-defined command). */
506 source_cleanup (stream
)
509 /* Restore the previous input stream. */
513 /* Read commands from STREAM. */
515 read_command_file (stream
)
518 struct cleanup
*cleanups
;
520 cleanups
= make_cleanup (source_cleanup
, instream
);
523 do_cleanups (cleanups
);
526 extern void init_proc ();
531 /* Run the init function of each source file */
533 getcwd (gdb_dirbuf
, sizeof (gdb_dirbuf
));
534 current_directory
= gdb_dirbuf
;
536 init_cmd_lists (); /* This needs to be done first */
537 initialize_targets (); /* Setup target_terminal macros for utils.c */
538 initialize_utils (); /* Make errors and warnings possible */
539 initialize_all_files ();
540 init_main (); /* But that omits this file! Do it now */
545 /* We need a default language for parsing expressions, so simple things like
546 "set width 0" won't fail if no language is explicitly set in a config file
547 or implicitly set by reading an executable during startup. */
548 set_language (language_c
);
549 expected_language
= current_language
; /* don't warn about the change. */
555 /* Allocate, initialize a new command line structure for one of the
556 control commands (if/while). */
558 static struct command_line
*
559 build_command_line (type
, args
)
560 enum command_control_type type
;
563 struct command_line
*cmd
;
565 cmd
= (struct command_line
*)xmalloc (sizeof (struct command_line
));
567 cmd
->control_type
= type
;
571 = (struct command_line
**)xmalloc (sizeof (struct command_line
*)
573 memset (cmd
->body_list
, 0, sizeof (struct command_line
*) * cmd
->body_count
);
574 cmd
->line
= savestring (args
, strlen (args
));
578 /* Build and return a new command structure for the control commands
579 such as "if" and "while". */
581 static struct command_line
*
582 get_command_line (type
, arg
)
583 enum command_control_type type
;
586 struct command_line
*cmd
;
587 struct cleanup
*old_chain
= NULL
;
589 /* Allocate and build a new command line structure. */
590 cmd
= build_command_line (type
, arg
);
592 old_chain
= make_cleanup (free_command_lines
, &cmd
);
594 /* Read in the body of this command. */
595 if (recurse_read_control_structure (cmd
) == invalid_control
)
597 warning ("error reading in control structure\n");
598 do_cleanups (old_chain
);
602 discard_cleanups (old_chain
);
606 /* Execute the command in CMD. */
608 static enum command_control_type
609 execute_control_command (cmd
)
610 struct command_line
*cmd
;
612 struct expression
*expr
;
613 struct command_line
*current
;
614 struct cleanup
*old_chain
= 0;
615 struct cleanup
*tmp_chain
;
618 enum command_control_type ret
;
620 switch (cmd
->control_type
)
623 /* A simple command, execute it and return. */
624 execute_command (cmd
->line
, 0);
625 return cmd
->control_type
;
627 case continue_control
:
629 /* Return for "continue", and "break" so we can either
630 continue the loop at the top, or break out. */
631 return cmd
->control_type
;
635 /* Parse the loop control expression for the while statement. */
636 expr
= parse_expression (cmd
->line
);
637 tmp_chain
= make_cleanup (free_current_contents
, &expr
);
639 old_chain
= tmp_chain
;
641 ret
= simple_control
;
644 /* Keep iterating so long as the expression is true. */
647 /* Evaluate the expression. */
648 val
= evaluate_expression (expr
);
650 /* If the value is false, then break out of the loop. */
651 if (!value_true (val
))
654 /* Execute the body of the while statement. */
655 current
= *cmd
->body_list
;
658 ret
= execute_control_command (current
);
660 /* If we got an error, or a "break" command, then stop
662 if (ret
== invalid_control
|| ret
== break_control
)
668 /* If we got a "continue" command, then restart the loop
670 if (ret
== continue_control
)
673 /* Get the next statement. */
674 current
= current
->next
;
678 /* Reset RET so that we don't recurse the break all the way down. */
679 if (ret
== break_control
)
680 ret
= simple_control
;
687 /* Parse the conditional for the if statement. */
688 expr
= parse_expression (cmd
->line
);
689 old_chain
= make_cleanup (free_current_contents
, &expr
);
692 ret
= simple_control
;
694 /* Evaluate the conditional. */
695 val
= evaluate_expression (expr
);
697 /* Choose which arm to take commands from based on the value of the
698 conditional expression. */
699 if (value_true (val
))
700 current
= *cmd
->body_list
;
701 else if (cmd
->body_count
== 2)
702 current
= *(cmd
->body_list
+ 1);
704 /* Execute commands in the given arm. */
707 ret
= execute_control_command (current
);
709 /* If we got an error, get out. */
710 if (ret
!= simple_control
)
713 /* Get the next statement in the body. */
714 current
= current
->next
;
720 warning ("Invalid control type in command structure.");
721 return invalid_control
;
725 do_cleanups (old_chain
);
730 /* "while" command support. Executes a body of statements while the
731 loop condition is nonzero. */
734 while_command (arg
, from_tty
)
738 struct command_line
*command
= NULL
;
741 command
= get_command_line (while_control
, arg
);
746 execute_control_command (command
);
747 free_command_lines (&command
);
750 /* "if" command support. Execute either the true or false arm depending
751 on the value of the if conditional. */
754 if_command (arg
, from_tty
)
758 struct command_line
*command
= NULL
;
761 command
= get_command_line (if_control
, arg
);
766 execute_control_command (command
);
767 free_command_lines (&command
);
771 execute_user_command (c
, args
)
772 struct cmd_list_element
*c
;
775 register struct command_line
*cmdlines
;
776 struct cleanup
*old_chain
;
777 enum command_control_type ret
;
780 error ("User-defined commands cannot take arguments.");
782 cmdlines
= c
->user_commands
;
787 /* Set the instream to 0, indicating execution of a
788 user-defined function. */
789 old_chain
= make_cleanup (source_cleanup
, instream
);
790 instream
= (FILE *) 0;
793 ret
= execute_control_command (cmdlines
);
794 if (ret
!= simple_control
&& ret
!= break_control
)
796 warning ("Error in control structure.\n");
799 cmdlines
= cmdlines
->next
;
801 do_cleanups (old_chain
);
804 /* Execute the line P as a command.
805 Pass FROM_TTY as second argument to the defining function. */
808 execute_command (p
, from_tty
)
812 register struct cmd_list_element
*c
;
813 register enum language flang
;
814 static int warned
= 0;
818 /* This can happen when command_line_input hits end of file. */
822 while (*p
== ' ' || *p
== '\t') p
++;
827 c
= lookup_cmd (&p
, cmdlist
, "", 0, 1);
828 /* Pass null arg rather than an empty one. */
831 /* If this command has been hooked, run the hook first. */
833 execute_user_command (c
->hook
, (char *)0);
835 if (c
->class == class_user
)
836 execute_user_command (c
, arg
);
837 else if (c
->type
== set_cmd
|| c
->type
== show_cmd
)
838 do_setshow_command (arg
, from_tty
& caution
, c
);
839 else if (c
->function
.cfunc
== NO_FUNCTION
)
840 error ("That is not a command, just a help topic.");
842 (*c
->function
.cfunc
) (arg
, from_tty
& caution
);
845 /* Tell the user if the language has changed (except first time). */
846 if (current_language
!= expected_language
)
848 if (language_mode
== language_mode_auto
) {
849 language_info (1); /* Print what changed. */
854 /* Warn the user if the working language does not match the
855 language of the current frame. Only warn the user if we are
856 actually running the program, i.e. there is a stack. */
857 /* FIXME: This should be cacheing the frame and only running when
858 the frame changes. */
859 if (target_has_stack
)
861 flang
= get_frame_language ();
863 && flang
!= language_unknown
864 && flang
!= current_language
->la_language
)
866 printf_filtered ("%s\n", lang_frame_mismatch_warn
);
874 command_loop_marker (foo
)
879 /* Read commands from `instream' and execute them
880 until end of file or error reading instream. */
884 struct cleanup
*old_chain
;
886 int stdin_is_tty
= ISATTY (stdin
);
888 while (!feof (instream
))
890 if (window_hook
&& instream
== stdin
)
891 (*window_hook
) (instream
, prompt
);
894 if (instream
== stdin
&& stdin_is_tty
)
895 reinitialize_more_filter ();
896 old_chain
= make_cleanup (command_loop_marker
, 0);
897 command
= command_line_input (instream
== stdin
? prompt
: (char *) NULL
,
898 instream
== stdin
, "prompt");
901 execute_command (command
, instream
== stdin
);
902 /* Do any commands attached to breakpoint we stopped at. */
903 bpstat_do_actions (&stop_bpstat
);
904 do_cleanups (old_chain
);
908 /* Commands call this if they do not want to be repeated by null lines. */
916 /* If we aren't reading from standard input, we are saving the last
917 thing read from stdin in line and don't want to delete it. Null lines
918 won't repeat here in any case. */
919 if (instream
== stdin
)
923 /* Read a line from the stream "instream" without command line editing.
925 It prints PRROMPT once at the start.
926 Action is compatible with "readline", e.g. space for the result is
927 malloc'd and should be freed by the caller.
929 A NULL return means end of file. */
931 gdb_readline (prrompt
)
937 int result_size
= 80;
941 /* Don't use a _filtered function here. It causes the assumed
942 character position to be off, since the newline we read from
943 the user is not accounted for. */
944 fputs_unfiltered (prrompt
, gdb_stdout
);
945 /* start-sanitize-mpw */
947 /* Move to a new line so the entered line doesn't have a prompt
948 on the front of it. */
949 fputs_unfiltered ("\n", gdb_stdout
);
951 /* end-sanitize-mpw */
952 gdb_flush (gdb_stdout
);
955 result
= (char *) xmalloc (result_size
);
959 /* Read from stdin if we are executing a user defined command.
960 This is the right thing for prompt_for_continue, at least. */
961 c
= fgetc (instream
? instream
: stdin
);
966 /* The last line does not end with a newline. Return it, and
967 if we are called again fgetc will still return EOF and
968 we'll return NULL then. */
977 result
[input_index
++] = c
;
978 while (input_index
>= result_size
)
981 result
= (char *) xrealloc (result
, result_size
);
985 result
[input_index
++] = '\0';
989 /* Variables which control command line editing and history
990 substitution. These variables are given default values at the end
992 static int command_editing_p
;
993 static int history_expansion_p
;
994 static int write_history_p
;
995 static int history_size
;
996 static char *history_filename
;
998 /* readline uses the word breaks for two things:
999 (1) In figuring out where to point the TEXT parameter to the
1000 rl_completion_entry_function. Since we don't use TEXT for much,
1001 it doesn't matter a lot what the word breaks are for this purpose, but
1002 it does affect how much stuff M-? lists.
1003 (2) If one of the matches contains a word break character, readline
1004 will quote it. That's why we switch between
1005 gdb_completer_word_break_characters and
1006 gdb_completer_command_word_break_characters. I'm not sure when
1007 we need this behavior (perhaps for funky characters in C++ symbols?). */
1009 /* Variables which are necessary for fancy command line editing. */
1010 char *gdb_completer_word_break_characters
=
1011 " \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,-";
1013 /* When completing on command names, we remove '-' from the list of
1014 word break characters, since we use it in command names. If the
1015 readline library sees one in any of the current completion strings,
1016 it thinks that the string needs to be quoted and automatically supplies
1018 char *gdb_completer_command_word_break_characters
=
1019 " \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,";
1021 /* Characters that can be used to quote completion strings. Note that we
1022 can't include '"' because the gdb C parser treats such quoted sequences
1024 char *gdb_completer_quote_characters
=
1027 /* Functions that are used as part of the fancy command line editing. */
1029 /* This can be used for functions which don't want to complete on symbols
1030 but don't want to complete on anything else either. */
1033 noop_completer (text
, prefix
)
1040 /* Complete on filenames. */
1042 filename_completer (text
, word
)
1046 /* From readline. */
1047 extern char *filename_completion_function ();
1048 int subsequent_name
;
1050 int return_val_used
;
1051 int return_val_alloced
;
1053 return_val_used
= 0;
1054 /* Small for testing. */
1055 return_val_alloced
= 1;
1056 return_val
= (char **) xmalloc (return_val_alloced
* sizeof (char *));
1058 subsequent_name
= 0;
1062 p
= filename_completion_function (text
, subsequent_name
);
1063 if (return_val_used
>= return_val_alloced
)
1065 return_val_alloced
*= 2;
1067 (char **) xrealloc (return_val
,
1068 return_val_alloced
* sizeof (char *));
1072 return_val
[return_val_used
++] = p
;
1075 /* Like emacs, don't complete on old versions. Especially useful
1076 in the "source" command. */
1077 if (p
[strlen (p
) - 1] == '~')
1083 /* Return exactly p. */
1084 return_val
[return_val_used
++] = p
;
1085 else if (word
> text
)
1087 /* Return some portion of p. */
1088 q
= xmalloc (strlen (p
) + 5);
1089 strcpy (q
, p
+ (word
- text
));
1090 return_val
[return_val_used
++] = q
;
1095 /* Return some of TEXT plus p. */
1096 q
= xmalloc (strlen (p
) + (text
- word
) + 5);
1097 strncpy (q
, word
, text
- word
);
1098 q
[text
- word
] = '\0';
1100 return_val
[return_val_used
++] = q
;
1104 subsequent_name
= 1;
1107 /* There is no way to do this just long enough to affect quote inserting
1108 without also affecting the next completion. This should be fixed in
1110 /* Insure that readline does the right thing
1111 with respect to inserting quotes. */
1112 rl_completer_word_break_characters
= "";
1117 /* Here are some useful test cases for completion. FIXME: These should
1118 be put in the test suite. They should be tested with both M-? and TAB.
1120 "show output-" "radix"
1121 "show output" "-radix"
1122 "p" ambiguous (commands starting with p--path, print, printf, etc.)
1123 "p " ambiguous (all symbols)
1124 "info t foo" no completions
1125 "info t " no completions
1126 "info t" ambiguous ("info target", "info terminal", etc.)
1127 "info ajksdlfk" no completions
1128 "info ajksdlfk " no completions
1130 "info " ambiguous (all info commands)
1131 "p \"a" no completions (string constant)
1132 "p 'a" ambiguous (all symbols starting with a)
1133 "p b-a" ambiguous (all symbols starting with a)
1134 "p b-" ambiguous (all symbols)
1135 "file Make" "file" (word break hard to screw up here)
1136 "file ../gdb.stabs/we" "ird" (needs to not break word at slash)
1139 /* Generate completions one by one for the completer. Each time we are
1140 called return another potential completion to the caller. The function
1141 is misnamed; it just completes on commands or passes the buck to the
1142 command's completer function; the stuff specific to symbol completion
1143 is in make_symbol_completion_list.
1145 TEXT is readline's idea of the "word" we are looking at; we don't really
1146 like readline's ideas about word breaking so we ignore it.
1148 MATCHES is the number of matches that have currently been collected from
1149 calling this completion function. When zero, then we need to initialize,
1150 otherwise the initialization has already taken place and we can just
1151 return the next potential completion string.
1153 Returns NULL if there are no more completions, else a pointer to a string
1154 which is a possible completion.
1156 RL_LINE_BUFFER is available to be looked at; it contains the entire text
1157 of the line. RL_POINT is the offset in that line of the cursor. You
1158 should pretend that the line ends at RL_POINT. */
1161 symbol_completion_function (text
, matches
)
1165 static char **list
= (char **)NULL
; /* Cache of completions */
1166 static int index
; /* Next cached completion */
1167 char *output
= NULL
;
1168 char *tmp_command
, *p
;
1169 /* Pointer within tmp_command which corresponds to text. */
1171 struct cmd_list_element
*c
, *result_list
;
1175 /* The caller is beginning to accumulate a new set of completions, so
1176 we need to find all of them now, and cache them for returning one at
1177 a time on future calls. */
1181 /* Free the storage used by LIST, but not by the strings inside.
1182 This is because rl_complete_internal () frees the strings. */
1188 /* Choose the default set of word break characters to break completions.
1189 If we later find out that we are doing completions on command strings
1190 (as opposed to strings supplied by the individual command completer
1191 functions, which can be any string) then we will switch to the
1192 special word break set for command strings, which leaves out the
1193 '-' character used in some commands. */
1195 rl_completer_word_break_characters
=
1196 gdb_completer_word_break_characters
;
1198 /* Decide whether to complete on a list of gdb commands or on symbols. */
1199 tmp_command
= (char *) alloca (rl_point
+ 1);
1202 strncpy (tmp_command
, rl_line_buffer
, rl_point
);
1203 tmp_command
[rl_point
] = '\0';
1204 /* Since text always contains some number of characters leading up
1205 to rl_point, we can find the equivalent position in tmp_command
1206 by subtracting that many characters from the end of tmp_command. */
1207 word
= tmp_command
+ rl_point
- strlen (text
);
1211 /* An empty line we want to consider ambiguous; that is, it
1212 could be any command. */
1213 c
= (struct cmd_list_element
*) -1;
1218 c
= lookup_cmd_1 (&p
, cmdlist
, &result_list
, 1);
1221 /* Move p up to the next interesting thing. */
1222 while (*p
== ' ' || *p
== '\t')
1229 /* It is an unrecognized command. So there are no
1230 possible completions. */
1233 else if (c
== (struct cmd_list_element
*) -1)
1237 /* lookup_cmd_1 advances p up to the first ambiguous thing, but
1238 doesn't advance over that thing itself. Do so now. */
1240 while (*q
&& (isalnum (*q
) || *q
== '-' || *q
== '_'))
1242 if (q
!= tmp_command
+ rl_point
)
1244 /* There is something beyond the ambiguous
1245 command, so there are no possible completions. For
1246 example, "info t " or "info t foo" does not complete
1247 to anything, because "info t" can be "info target" or
1253 /* We're trying to complete on the command which was ambiguous.
1254 This we can deal with. */
1257 list
= complete_on_cmdlist (*result_list
->prefixlist
, p
,
1262 list
= complete_on_cmdlist (cmdlist
, p
, word
);
1264 /* Insure that readline does the right thing with respect to
1265 inserting quotes. */
1266 rl_completer_word_break_characters
=
1267 gdb_completer_command_word_break_characters
;
1272 /* We've recognized a full command. */
1274 if (p
== tmp_command
+ rl_point
)
1276 /* There is no non-whitespace in the line beyond the command. */
1278 if (p
[-1] == ' ' || p
[-1] == '\t')
1280 /* The command is followed by whitespace; we need to complete
1281 on whatever comes after command. */
1284 /* It is a prefix command; what comes after it is
1285 a subcommand (e.g. "info "). */
1286 list
= complete_on_cmdlist (*c
->prefixlist
, p
, word
);
1288 /* Insure that readline does the right thing
1289 with respect to inserting quotes. */
1290 rl_completer_word_break_characters
=
1291 gdb_completer_command_word_break_characters
;
1295 /* It is a normal command; what comes after it is
1296 completed by the command's completer function. */
1297 list
= (*c
->completer
) (p
, word
);
1302 /* The command is not followed by whitespace; we need to
1303 complete on the command itself. e.g. "p" which is a
1304 command itself but also can complete to "print", "ptype"
1308 /* Find the command we are completing on. */
1310 while (q
> tmp_command
)
1312 if (isalnum (q
[-1]) || q
[-1] == '-' || q
[-1] == '_')
1318 list
= complete_on_cmdlist (result_list
, q
, word
);
1320 /* Insure that readline does the right thing
1321 with respect to inserting quotes. */
1322 rl_completer_word_break_characters
=
1323 gdb_completer_command_word_break_characters
;
1328 /* There is non-whitespace beyond the command. */
1330 if (c
->prefixlist
&& !c
->allow_unknown
)
1332 /* It is an unrecognized subcommand of a prefix command,
1333 e.g. "info adsfkdj". */
1338 /* It is a normal command. */
1339 list
= (*c
->completer
) (p
, word
);
1345 /* If we found a list of potential completions during initialization then
1346 dole them out one at a time. The vector of completions is NULL
1347 terminated, so after returning the last one, return NULL (and continue
1348 to do so) each time we are called after that, until a new list is
1353 output
= list
[index
];
1361 /* Can't do this because readline hasn't yet checked the word breaks
1362 for figuring out whether to insert a quote. */
1364 /* Make sure the word break characters are set back to normal for the
1365 next time that readline tries to complete something. */
1366 rl_completer_word_break_characters
=
1367 gdb_completer_word_break_characters
;
1373 /* Skip over a possibly quoted word (as defined by the quote characters
1374 and word break characters the completer uses). Returns pointer to the
1375 location after the "word". */
1381 char quote_char
= '\0';
1384 for (scan
= str
; *scan
!= '\0'; scan
++)
1386 if (quote_char
!= '\0')
1388 /* Ignore everything until the matching close quote char */
1389 if (*scan
== quote_char
)
1391 /* Found matching close quote. */
1396 else if (strchr (gdb_completer_quote_characters
, *scan
))
1398 /* Found start of a quoted string. */
1401 else if (strchr (gdb_completer_word_break_characters
, *scan
))
1415 #if STOP_SIGNAL == SIGTSTP
1416 signal (SIGTSTP
, SIG_DFL
);
1418 kill (getpid (), SIGTSTP
);
1419 signal (SIGTSTP
, stop_sig
);
1421 signal (STOP_SIGNAL
, stop_sig
);
1423 printf_unfiltered ("%s", prompt
);
1424 gdb_flush (gdb_stdout
);
1426 /* Forget about any previous command -- null line now will do nothing. */
1429 #endif /* STOP_SIGNAL */
1431 /* Initialize signal handlers. */
1441 signal (SIGINT
, request_quit
);
1443 /* If we initialize SIGQUIT to SIG_IGN, then the SIG_IGN will get
1444 passed to the inferior, which we don't want. It would be
1445 possible to do a "signal (SIGQUIT, SIG_DFL)" after we fork, but
1446 on BSD4.3 systems using vfork, that can affect the
1447 GDB process as well as the inferior (the signal handling tables
1448 might be in memory, shared between the two). Since we establish
1449 a handler for SIGQUIT, when we call exec it will set the signal
1450 to SIG_DFL for us. */
1451 signal (SIGQUIT
, do_nothing
);
1452 if (signal (SIGHUP
, do_nothing
) != SIG_IGN
)
1453 signal (SIGHUP
, disconnect
);
1454 signal (SIGFPE
, float_handler
);
1456 #if defined(SIGWINCH) && defined(SIGWINCH_HANDLER)
1457 signal (SIGWINCH
, SIGWINCH_HANDLER
);
1461 /* Read one line from the command input stream `instream'
1462 into the local static buffer `linebuffer' (whose current length
1464 The buffer is made bigger as necessary.
1465 Returns the address of the start of the line.
1467 NULL is returned for end of file.
1469 *If* the instream == stdin & stdin is a terminal, the line read
1470 is copied into the file line saver (global var char *line,
1471 length linesize) so that it can be duplicated.
1473 This routine either uses fancy command line editing or
1474 simple input as the user has requested. */
1477 command_line_input (prrompt
, repeat
, annotation_suffix
)
1480 char *annotation_suffix
;
1482 static char *linebuffer
= 0;
1483 static unsigned linelength
= 0;
1487 char *local_prompt
= prrompt
;
1492 if (annotation_level
> 1 && instream
== stdin
)
1494 local_prompt
= alloca ((prrompt
== NULL
? 0 : strlen (prrompt
))
1495 + strlen (annotation_suffix
) + 40);
1496 if (prrompt
== NULL
)
1497 local_prompt
[0] = '\0';
1499 strcpy (local_prompt
, prrompt
);
1500 strcat (local_prompt
, "\n\032\032");
1501 strcat (local_prompt
, annotation_suffix
);
1502 strcat (local_prompt
, "\n");
1505 if (linebuffer
== 0)
1508 linebuffer
= (char *) xmalloc (linelength
);
1513 /* Control-C quits instantly if typed while in this loop
1514 since it should not wait until the user types a newline. */
1518 signal (STOP_SIGNAL
, stop_sig
);
1523 /* Make sure that all output has been output. Some machines may let
1524 you get away with leaving out some of the gdb_flush, but not all. */
1526 gdb_flush (gdb_stdout
);
1527 gdb_flush (gdb_stderr
);
1529 if (source_file_name
!= NULL
)
1531 ++source_line_number
;
1532 sprintf (source_error
,
1533 "%s%s:%d: Error in sourced command file:\n",
1536 source_line_number
);
1537 error_pre_print
= source_error
;
1540 if (annotation_level
> 1 && instream
== stdin
)
1542 printf_unfiltered ("\n\032\032pre-");
1543 printf_unfiltered (annotation_suffix
);
1544 printf_unfiltered ("\n");
1547 /* Don't use fancy stuff if not talking to stdin. */
1548 if (command_editing_p
&& instream
== stdin
1549 && ISATTY (instream
))
1550 rl
= readline (local_prompt
);
1552 rl
= gdb_readline (local_prompt
);
1554 if (annotation_level
> 1 && instream
== stdin
)
1556 printf_unfiltered ("\n\032\032post-");
1557 printf_unfiltered (annotation_suffix
);
1558 printf_unfiltered ("\n");
1561 if (!rl
|| rl
== (char *) EOF
)
1566 if (strlen(rl
) + 1 + (p
- linebuffer
) > linelength
)
1568 linelength
= strlen(rl
) + 1 + (p
- linebuffer
);
1569 nline
= (char *) xrealloc (linebuffer
, linelength
);
1570 p
+= nline
- linebuffer
;
1574 /* Copy line. Don't copy null at end. (Leaves line alone
1575 if this was just a newline) */
1579 free (rl
); /* Allocated in readline. */
1581 if (p
== linebuffer
|| *(p
- 1) != '\\')
1584 p
--; /* Put on top of '\'. */
1585 local_prompt
= (char *) 0;
1590 signal (STOP_SIGNAL
, SIG_DFL
);
1597 #define SERVER_COMMAND_LENGTH 7
1599 (p
- linebuffer
> SERVER_COMMAND_LENGTH
)
1600 && STREQN (linebuffer
, "server ", SERVER_COMMAND_LENGTH
);
1603 /* Note that we don't set `line'. Between this and the check in
1604 dont_repeat, this insures that repeating will still do the
1607 return linebuffer
+ SERVER_COMMAND_LENGTH
;
1610 /* Do history expansion if that is wished. */
1611 if (history_expansion_p
&& instream
== stdin
1612 && ISATTY (instream
))
1614 char *history_value
;
1617 *p
= '\0'; /* Insert null now. */
1618 expanded
= history_expand (linebuffer
, &history_value
);
1621 /* Print the changes. */
1622 printf_unfiltered ("%s\n", history_value
);
1624 /* If there was an error, call this function again. */
1627 free (history_value
);
1628 return command_line_input (prrompt
, repeat
, annotation_suffix
);
1630 if (strlen (history_value
) > linelength
)
1632 linelength
= strlen (history_value
) + 1;
1633 linebuffer
= (char *) xrealloc (linebuffer
, linelength
);
1635 strcpy (linebuffer
, history_value
);
1636 p
= linebuffer
+ strlen(linebuffer
);
1637 free (history_value
);
1641 /* If we just got an empty line, and that is supposed
1642 to repeat the previous command, return the value in the
1646 if (p
== linebuffer
)
1649 while (*p1
== ' ' || *p1
== '\t')
1657 /* Add line to history if appropriate. */
1658 if (instream
== stdin
1659 && ISATTY (stdin
) && *linebuffer
)
1660 add_history (linebuffer
);
1662 /* Note: lines consisting solely of comments are added to the command
1663 history. This is useful when you type a command, and then
1664 realize you don't want to execute it quite yet. You can comment
1665 out the command and then later fetch it from the value history
1666 and remove the '#'. The kill ring is probably better, but some
1667 people are in the habit of commenting things out. */
1669 while ((c
= *p1
++) != '\0')
1672 while ((c
= *p1
++) != '"')
1674 /* Make sure an escaped '"' doesn't make us think the string
1682 while ((c
= *p1
++) != '\'')
1684 /* Make sure an escaped '\'' doesn't make us think the string
1693 /* Found a comment. */
1699 /* Save into global buffer if appropriate. */
1702 if (linelength
> linesize
)
1704 line
= xrealloc (line
, linelength
);
1705 linesize
= linelength
;
1707 strcpy (line
, linebuffer
);
1715 /* Expand the body_list of COMMAND so that it can hold NEW_LENGTH
1716 code bodies. This is typically used when we encounter an "else"
1717 clause for an "if" command. */
1720 realloc_body_list (command
, new_length
)
1721 struct command_line
*command
;
1725 struct command_line
**body_list
;
1727 n
= command
->body_count
;
1729 /* Nothing to do? */
1730 if (new_length
<= n
)
1733 body_list
= (struct command_line
**)
1734 xmalloc (sizeof (struct command_line
*) * new_length
);
1736 memcpy (body_list
, command
->body_list
, sizeof (struct command_line
*) * n
);
1738 free (command
->body_list
);
1739 command
->body_list
= body_list
;
1740 command
->body_count
= new_length
;
1743 /* Read one line from the input stream. If the command is an "else" or
1744 "end", return such an indication to the caller. */
1746 static enum misc_command_type
1747 read_next_line (command
)
1748 struct command_line
**command
;
1750 char *p
, *p1
, *prompt_ptr
, control_prompt
[256];
1753 if (control_level
>= 254)
1754 error ("Control nesting too deep!\n");
1756 /* Set a prompt based on the nesting of the control commands. */
1757 if (instream
== stdin
)
1759 for (i
= 0; i
< control_level
; i
++)
1760 control_prompt
[i
] = ' ';
1761 control_prompt
[i
] = '>';
1762 control_prompt
[i
+1] = '\0';
1763 prompt_ptr
= (char *)&control_prompt
[0];
1768 p
= command_line_input (prompt_ptr
, instream
== stdin
, NULL
);
1770 /* Not sure what to do here. */
1774 /* Strip leading and trailing whitespace. */
1775 while (*p
== ' ' || *p
== '\t')
1778 p1
= p
+ strlen (p
);
1779 while (p1
!= p
&& (p1
[-1] == ' ' || p1
[-1] == '\t'))
1782 /* Blanks and comments don't really do anything, but we need to
1783 distinguish them from else, end and other commands which can be
1785 if (p1
== p
|| p
[0] == '#')
1788 /* Is this the end of a simple, while, or if control structure? */
1789 if (p1
- p
== 3 && !strncmp (p
, "end", 3))
1792 /* Is the else clause of an if control structure? */
1793 if (p1
- p
== 4 && !strncmp (p
, "else", 4))
1794 return else_command
;
1796 /* Check for while, if, break, continue, etc and build a new command
1797 line structure for them. */
1798 if (p1
- p
> 5 && !strncmp (p
, "while", 5))
1799 *command
= build_command_line (while_control
, p
+ 6);
1800 else if (p1
- p
> 2 && !strncmp (p
, "if", 2))
1801 *command
= build_command_line (if_control
, p
+ 3);
1802 else if (p1
- p
== 5 && !strncmp (p
, "loop_break", 5))
1804 *command
= (struct command_line
*)
1805 xmalloc (sizeof (struct command_line
));
1806 (*command
)->next
= NULL
;
1807 (*command
)->line
= NULL
;
1808 (*command
)->control_type
= break_control
;
1809 (*command
)->body_count
= 0;
1810 (*command
)->body_list
= NULL
;
1812 else if (p1
- p
== 8 && !strncmp (p
, "loop_continue", 8))
1814 *command
= (struct command_line
*)
1815 xmalloc (sizeof (struct command_line
));
1816 (*command
)->next
= NULL
;
1817 (*command
)->line
= NULL
;
1818 (*command
)->control_type
= continue_control
;
1819 (*command
)->body_count
= 0;
1820 (*command
)->body_list
= NULL
;
1824 /* A normal command. */
1825 *command
= (struct command_line
*)
1826 xmalloc (sizeof (struct command_line
));
1827 (*command
)->next
= NULL
;
1828 (*command
)->line
= savestring (p
, p1
- p
);
1829 (*command
)->control_type
= simple_control
;
1830 (*command
)->body_count
= 0;
1831 (*command
)->body_list
= NULL
;
1834 /* Nothing special. */
1838 /* Recursively read in the control structures and create a command_line
1841 The parent_control parameter is the control structure in which the
1842 following commands are nested. */
1844 static enum command_control_type
1845 recurse_read_control_structure (current_cmd
)
1846 struct command_line
*current_cmd
;
1848 int current_body
, i
;
1849 enum misc_command_type val
;
1850 enum command_control_type ret
;
1851 struct command_line
**body_ptr
, *child_tail
, *next
;
1852 struct cleanup
*old_chains
, *tmp_chains
;
1858 /* Sanity checks. */
1859 if (current_cmd
->control_type
== simple_control
)
1861 error ("Recursed on a simple control type\n");
1862 return invalid_control
;
1865 if (current_body
> current_cmd
->body_count
)
1867 error ("Allocated body is smaller than this command type needs\n");
1868 return invalid_control
;
1871 /* Read lines from the input stream and build control structures. */
1877 val
= read_next_line (&next
);
1879 /* Just skip blanks and comments. */
1880 if (val
== nop_command
)
1883 if (val
== end_command
)
1885 if (current_cmd
->control_type
== while_control
1886 || current_cmd
->control_type
== if_control
)
1888 /* Success reading an entire control structure. */
1889 ret
= simple_control
;
1894 ret
= invalid_control
;
1899 /* Not the end of a control structure. */
1900 if (val
== else_command
)
1902 if (current_cmd
->control_type
== if_control
1903 && current_body
== 1)
1905 realloc_body_list (current_cmd
, 2);
1912 ret
= invalid_control
;
1919 child_tail
->next
= next
;
1923 /* We have just read the first line of the child's control
1924 structure. From now on, arrange to throw away the line
1925 we have if we quit or get an error. */
1926 body_ptr
= current_cmd
->body_list
;
1927 for (i
= 1; i
< current_body
; i
++)
1932 tmp_chains
= make_cleanup (free_command_lines
, body_ptr
);
1935 old_chains
= tmp_chains
;
1940 /* If the latest line is another control structure, then recurse
1942 if (next
->control_type
== while_control
1943 || next
->control_type
== if_control
)
1946 ret
= recurse_read_control_structure (next
);
1949 if (ret
!= simple_control
)
1955 if (ret
== invalid_control
&& old_chains
)
1956 do_cleanups (old_chains
);
1957 else if (old_chains
)
1958 discard_cleanups (old_chains
);
1964 /* Read lines from the input stream
1965 and accumulate them in a chain of struct command_line's
1966 which is then returned. */
1968 struct command_line
*
1969 read_command_lines ()
1971 struct command_line
*head
, *tail
, *next
;
1972 struct cleanup
*old_chain
;
1973 enum command_control_type ret
;
1974 enum misc_command_type val
;
1981 val
= read_next_line (&next
);
1983 /* Ignore blank lines or comments. */
1984 if (val
== nop_command
)
1987 if (val
== end_command
)
1989 ret
= simple_control
;
1993 if (val
!= ok_command
)
1995 ret
= invalid_control
;
1999 if (next
->control_type
== while_control
2000 || next
->control_type
== if_control
)
2003 ret
= recurse_read_control_structure (next
);
2006 if (ret
== invalid_control
)
2017 old_chain
= make_cleanup (free_command_lines
, &head
);
2026 if (ret
!= invalid_control
)
2028 discard_cleanups (old_chain
);
2032 do_cleanups (old_chain
);
2038 /* Free a chain of struct command_line's. */
2041 free_command_lines (lptr
)
2042 struct command_line
**lptr
;
2044 register struct command_line
*l
= *lptr
;
2045 register struct command_line
*next
;
2046 struct command_line
**blist
;
2051 if (l
->body_count
> 0)
2053 blist
= l
->body_list
;
2054 for (i
= 0; i
< l
->body_count
; i
++, blist
++)
2055 free_command_lines (blist
);
2064 /* Add an element to the list of info subcommands. */
2067 add_info (name
, fun
, doc
)
2069 void (*fun
) PARAMS ((char *, int));
2072 add_cmd (name
, no_class
, fun
, doc
, &infolist
);
2075 /* Add an alias to the list of info subcommands. */
2078 add_info_alias (name
, oldname
, abbrev_flag
)
2083 add_alias_cmd (name
, oldname
, 0, abbrev_flag
, &infolist
);
2086 /* The "info" command is defined as a prefix, with allow_unknown = 0.
2087 Therefore, its own definition is called only for "info" with no args. */
2091 info_command (arg
, from_tty
)
2095 printf_unfiltered ("\"info\" must be followed by the name of an info command.\n");
2096 help_list (infolist
, "info ", -1, gdb_stdout
);
2099 /* The "complete" command is used by Emacs to implement completion. */
2103 complete_command (arg
, from_tty
)
2114 rl_line_buffer
[0] = '\0';
2119 strcpy (rl_line_buffer
, arg
);
2120 rl_point
= strlen (arg
);
2123 for (completion
= symbol_completion_function (rl_line_buffer
, i
= 0);
2125 completion
= symbol_completion_function (rl_line_buffer
, ++i
))
2126 printf_unfiltered ("%s\n", completion
);
2129 /* The "show" command with no arguments shows all the settings. */
2133 show_command (arg
, from_tty
)
2137 cmd_show_list (showlist
, from_tty
, "");
2140 /* Add an element to the list of commands. */
2143 add_com (name
, class, fun
, doc
)
2145 enum command_class
class;
2146 void (*fun
) PARAMS ((char *, int));
2149 add_cmd (name
, class, fun
, doc
, &cmdlist
);
2152 /* Add an alias or abbreviation command to the list of commands. */
2155 add_com_alias (name
, oldname
, class, abbrev_flag
)
2158 enum command_class
class;
2161 add_alias_cmd (name
, oldname
, class, abbrev_flag
, &cmdlist
);
2168 error ("Argument required (%s).", why
);
2173 help_command (command
, from_tty
)
2175 int from_tty
; /* Ignored */
2177 help_cmd (command
, gdb_stdout
);
2181 validate_comname (comname
)
2187 error_no_arg ("name of command to define");
2192 if (!isalnum(*p
) && *p
!= '-')
2193 error ("Junk in argument list: \"%s\"", p
);
2198 /* This is just a placeholder in the command data structures. */
2200 user_defined_command (ignore
, from_tty
)
2207 define_command (comname
, from_tty
)
2211 register struct command_line
*cmds
;
2212 register struct cmd_list_element
*c
, *newc
, *hookc
= 0;
2213 char *tem
= comname
;
2214 #define HOOK_STRING "hook-"
2217 validate_comname (comname
);
2219 /* Look it up, and verify that we got an exact match. */
2220 c
= lookup_cmd (&tem
, cmdlist
, "", -1, 1);
2221 if (c
&& !STREQ (comname
, c
->name
))
2226 if (c
->class == class_user
|| c
->class == class_alias
)
2227 tem
= "Redefine command \"%s\"? ";
2229 tem
= "Really redefine built-in command \"%s\"? ";
2230 if (!query (tem
, c
->name
))
2231 error ("Command \"%s\" not redefined.", c
->name
);
2234 /* If this new command is a hook, then mark the command which it
2235 is hooking. Note that we allow hooking `help' commands, so that
2236 we can hook the `stop' pseudo-command. */
2238 if (!strncmp (comname
, HOOK_STRING
, HOOK_LEN
))
2240 /* Look up cmd it hooks, and verify that we got an exact match. */
2241 tem
= comname
+HOOK_LEN
;
2242 hookc
= lookup_cmd (&tem
, cmdlist
, "", -1, 0);
2243 if (hookc
&& !STREQ (comname
+HOOK_LEN
, hookc
->name
))
2247 warning ("Your new `%s' command does not hook any existing command.",
2249 if (!query ("Proceed? ", (char *)0))
2250 error ("Not confirmed.");
2254 comname
= savestring (comname
, strlen (comname
));
2256 /* If the rest of the commands will be case insensitive, this one
2257 should behave in the same manner. */
2258 for (tem
= comname
; *tem
; tem
++)
2259 if (isupper(*tem
)) *tem
= tolower(*tem
);
2263 printf_unfiltered ("Type commands for definition of \"%s\".\n\
2264 End with a line saying just \"end\".\n", comname
);
2265 gdb_flush (gdb_stdout
);
2269 cmds
= read_command_lines ();
2271 if (c
&& c
->class == class_user
)
2272 free_command_lines (&c
->user_commands
);
2274 newc
= add_cmd (comname
, class_user
, user_defined_command
,
2275 (c
&& c
->class == class_user
)
2276 ? c
->doc
: savestring ("User-defined.", 13), &cmdlist
);
2277 newc
->user_commands
= cmds
;
2279 /* If this new command is a hook, then mark both commands as being
2283 hookc
->hook
= newc
; /* Target gets hooked. */
2284 newc
->hookee
= hookc
; /* We are marked as hooking target cmd. */
2289 document_command (comname
, from_tty
)
2293 struct command_line
*doclines
;
2294 register struct cmd_list_element
*c
;
2295 char *tem
= comname
;
2297 validate_comname (comname
);
2299 c
= lookup_cmd (&tem
, cmdlist
, "", 0, 1);
2301 if (c
->class != class_user
)
2302 error ("Command \"%s\" is built-in.", comname
);
2305 printf_unfiltered ("Type documentation for \"%s\".\n\
2306 End with a line saying just \"end\".\n", comname
);
2308 doclines
= read_command_lines ();
2310 if (c
->doc
) free (c
->doc
);
2313 register struct command_line
*cl1
;
2314 register int len
= 0;
2316 for (cl1
= doclines
; cl1
; cl1
= cl1
->next
)
2317 len
+= strlen (cl1
->line
) + 1;
2319 c
->doc
= (char *) xmalloc (len
+ 1);
2322 for (cl1
= doclines
; cl1
; cl1
= cl1
->next
)
2324 strcat (c
->doc
, cl1
->line
);
2326 strcat (c
->doc
, "\n");
2330 free_command_lines (&doclines
);
2334 print_gnu_advertisement ()
2336 printf_unfiltered ("\
2337 GDB is free software and you are welcome to distribute copies of it\n\
2338 under certain conditions; type \"show copying\" to see the conditions.\n\
2339 There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\
2344 print_gdb_version (stream
)
2347 fprintf_filtered (stream
, "\
2348 GDB %s (%s", version
, host_name
);
2350 if (!STREQ (host_name
, target_name
))
2351 fprintf_filtered (stream
, " --target %s", target_name
);
2353 fprintf_filtered (stream
, "), ");
2355 fprintf_filtered (stream
, "Copyright 1994 Free Software Foundation, Inc.");
2360 show_version (args
, from_tty
)
2365 print_gnu_advertisement ();
2366 print_gdb_version (gdb_stdout
);
2367 printf_filtered ("\n");
2371 /* xgdb calls this to reprint the usual GDB prompt. Obsolete now that xgdb
2377 printf_unfiltered ("%s", prompt
);
2378 gdb_flush (gdb_stdout
);
2382 quit_command (args
, from_tty
)
2386 if (inferior_pid
!= 0 && target_has_execution
)
2390 if (query ("The program is running. Quit anyway (and detach it)? "))
2391 target_detach (args
, from_tty
);
2393 error ("Not confirmed.");
2397 if (query ("The program is running. Quit anyway (and kill it)? "))
2400 error ("Not confirmed.");
2403 /* UDI wants this, to kill the TIP. */
2406 /* Save the history information if it is appropriate to do so. */
2407 if (write_history_p
&& history_filename
)
2408 write_history (history_filename
);
2413 /* Returns whether GDB is running on a terminal and whether the user
2414 desires that questions be asked of them on that terminal. */
2417 input_from_terminal_p ()
2419 return gdb_has_a_terminal () && (instream
== stdin
) & caution
;
2424 pwd_command (args
, from_tty
)
2428 if (args
) error ("The \"pwd\" command does not take an argument: %s", args
);
2429 getcwd (gdb_dirbuf
, sizeof (gdb_dirbuf
));
2431 if (!STREQ (gdb_dirbuf
, current_directory
))
2432 printf_unfiltered ("Working directory %s\n (canonically %s).\n",
2433 current_directory
, gdb_dirbuf
);
2435 printf_unfiltered ("Working directory %s.\n", current_directory
);
2439 cd_command (dir
, from_tty
)
2444 /* Found something other than leading repetitions of "/..". */
2445 int found_real_path
;
2448 /* If the new directory is absolute, repeat is a no-op; if relative,
2449 repeat might be useful but is more likely to be a mistake. */
2453 error_no_arg ("new working directory");
2455 dir
= tilde_expand (dir
);
2456 make_cleanup (free
, dir
);
2458 if (chdir (dir
) < 0)
2459 perror_with_name (dir
);
2462 dir
= savestring (dir
, len
- (len
> 1 && dir
[len
-1] == '/'));
2464 current_directory
= dir
;
2467 if (current_directory
[0] == '/' && current_directory
[1] == '\0')
2468 current_directory
= concat (current_directory
, dir
, NULL
);
2470 current_directory
= concat (current_directory
, "/", dir
, NULL
);
2474 /* Now simplify any occurrences of `.' and `..' in the pathname. */
2476 found_real_path
= 0;
2477 for (p
= current_directory
; *p
;)
2479 if (p
[0] == '/' && p
[1] == '.' && (p
[2] == 0 || p
[2] == '/'))
2481 else if (p
[0] == '/' && p
[1] == '.' && p
[2] == '.'
2482 && (p
[3] == 0 || p
[3] == '/'))
2484 if (found_real_path
)
2486 /* Search backwards for the directory just before the "/.."
2487 and obliterate it and the "/..". */
2489 while (q
!= current_directory
&& q
[-1] != '/')
2492 if (q
== current_directory
)
2493 /* current_directory is
2494 a relative pathname ("can't happen"--leave it alone). */
2498 strcpy (q
- 1, p
+ 3);
2503 /* We are dealing with leading repetitions of "/..", for example
2504 "/../..", which is the Mach super-root. */
2509 found_real_path
= 1;
2514 forget_cached_source_info ();
2517 pwd_command ((char *) 0, 1);
2520 struct source_cleanup_lines_args
{
2523 char *old_pre_error
;
2524 char *old_error_pre_print
;
2528 source_cleanup_lines (args
)
2531 struct source_cleanup_lines_args
*p
=
2532 (struct source_cleanup_lines_args
*)args
;
2533 source_line_number
= p
->old_line
;
2534 source_file_name
= p
->old_file
;
2535 source_pre_error
= p
->old_pre_error
;
2536 error_pre_print
= p
->old_error_pre_print
;
2541 source_command (args
, from_tty
)
2546 struct cleanup
*old_cleanups
;
2548 struct source_cleanup_lines_args old_lines
;
2553 error ("source command requires pathname of file to source.");
2556 file
= tilde_expand (file
);
2557 old_cleanups
= make_cleanup (free
, file
);
2559 stream
= fopen (file
, FOPEN_RT
);
2561 perror_with_name (file
);
2563 make_cleanup (fclose
, stream
);
2565 old_lines
.old_line
= source_line_number
;
2566 old_lines
.old_file
= source_file_name
;
2567 old_lines
.old_pre_error
= source_pre_error
;
2568 old_lines
.old_error_pre_print
= error_pre_print
;
2569 make_cleanup (source_cleanup_lines
, &old_lines
);
2570 source_line_number
= 0;
2571 source_file_name
= file
;
2572 source_pre_error
= error_pre_print
== NULL
? "" : error_pre_print
;
2573 source_pre_error
= savestring (source_pre_error
, strlen (source_pre_error
));
2574 make_cleanup (free
, source_pre_error
);
2575 /* This will get set every time we read a line. So it won't stay "" for
2577 error_pre_print
= "";
2579 needed_length
= strlen (source_file_name
) + strlen (source_pre_error
) + 80;
2580 if (source_error_allocated
< needed_length
)
2582 source_error_allocated
*= 2;
2583 if (source_error_allocated
< needed_length
)
2584 source_error_allocated
= needed_length
;
2585 if (source_error
== NULL
)
2586 source_error
= xmalloc (source_error_allocated
);
2588 source_error
= xrealloc (source_error
, source_error_allocated
);
2591 read_command_file (stream
);
2593 do_cleanups (old_cleanups
);
2598 echo_command (text
, from_tty
)
2606 while ((c
= *p
++) != '\0')
2610 /* \ at end of argument is used after spaces
2611 so they won't be lost. */
2615 c
= parse_escape (&p
);
2617 printf_filtered ("%c", c
);
2620 printf_filtered ("%c", c
);
2623 /* Force this output to appear now. */
2625 gdb_flush (gdb_stdout
);
2629 /* Functions to manipulate command line editing control variables. */
2631 /* Number of commands to print in each call to show_commands. */
2632 #define Hist_print 10
2634 show_commands (args
, from_tty
)
2638 /* Index for history commands. Relative to history_base. */
2641 /* Number of the history entry which we are planning to display next.
2642 Relative to history_base. */
2645 /* The first command in the history which doesn't exist (i.e. one more
2646 than the number of the last command). Relative to history_base. */
2649 extern HIST_ENTRY
*history_get
PARAMS ((int));
2651 /* Print out some of the commands from the command history. */
2652 /* First determine the length of the history list. */
2653 hist_len
= history_size
;
2654 for (offset
= 0; offset
< history_size
; offset
++)
2656 if (!history_get (history_base
+ offset
))
2665 if (args
[0] == '+' && args
[1] == '\0')
2666 /* "info editing +" should print from the stored position. */
2669 /* "info editing <exp>" should print around command number <exp>. */
2670 num
= (parse_and_eval_address (args
) - history_base
) - Hist_print
/ 2;
2672 /* "show commands" means print the last Hist_print commands. */
2675 num
= hist_len
- Hist_print
;
2681 /* If there are at least Hist_print commands, we want to display the last
2682 Hist_print rather than, say, the last 6. */
2683 if (hist_len
- num
< Hist_print
)
2685 num
= hist_len
- Hist_print
;
2690 for (offset
= num
; offset
< num
+ Hist_print
&& offset
< hist_len
; offset
++)
2692 printf_filtered ("%5d %s\n", history_base
+ offset
,
2693 (history_get (history_base
+ offset
))->line
);
2696 /* The next command we want to display is the next one that we haven't
2700 /* If the user repeats this command with return, it should do what
2701 "show commands +" does. This is unnecessary if arg is null,
2702 because "show commands +" is not useful after "show commands". */
2703 if (from_tty
&& args
)
2710 /* Called by do_setshow_command. */
2713 set_history_size_command (args
, from_tty
, c
)
2716 struct cmd_list_element
*c
;
2718 if (history_size
== INT_MAX
)
2719 unstifle_history ();
2720 else if (history_size
>= 0)
2721 stifle_history (history_size
);
2724 history_size
= INT_MAX
;
2725 error ("History size must be non-negative");
2731 set_history (args
, from_tty
)
2735 printf_unfiltered ("\"set history\" must be followed by the name of a history subcommand.\n");
2736 help_list (sethistlist
, "set history ", -1, gdb_stdout
);
2741 show_history (args
, from_tty
)
2745 cmd_show_list (showhistlist
, from_tty
, "");
2748 int info_verbose
= 0; /* Default verbose msgs off */
2750 /* Called by do_setshow_command. An elaborate joke. */
2753 set_verbose (args
, from_tty
, c
)
2756 struct cmd_list_element
*c
;
2758 char *cmdname
= "verbose";
2759 struct cmd_list_element
*showcmd
;
2761 showcmd
= lookup_cmd_1 (&cmdname
, showlist
, NULL
, 1);
2765 c
->doc
= "Set verbose printing of informational messages.";
2766 showcmd
->doc
= "Show verbose printing of informational messages.";
2770 c
->doc
= "Set verbosity.";
2771 showcmd
->doc
= "Show verbosity.";
2776 float_handler (signo
)
2779 /* This message is based on ANSI C, section 4.7. Note that integer
2780 divide by zero causes this, so "float" is a misnomer. */
2781 signal (SIGFPE
, float_handler
);
2782 error ("Erroneous arithmetic operation.");
2794 enablebreaklist
= NULL
;
2799 showhistlist
= NULL
;
2800 unsethistlist
= NULL
;
2801 #if MAINTENANCE_CMDS
2802 maintenancelist
= NULL
;
2803 maintenanceinfolist
= NULL
;
2804 maintenanceprintlist
= NULL
;
2806 setprintlist
= NULL
;
2807 showprintlist
= NULL
;
2808 setchecklist
= NULL
;
2809 showchecklist
= NULL
;
2812 /* Init the history buffer. Note that we are called after the init file(s)
2813 * have been read so that the user can change the history file via his
2814 * .gdbinit file (for instance). The GDBHISTFILE environment variable
2815 * overrides all of this.
2823 tmpenv
= getenv ("HISTSIZE");
2825 history_size
= atoi (tmpenv
);
2826 else if (!history_size
)
2829 stifle_history (history_size
);
2831 tmpenv
= getenv ("GDBHISTFILE");
2833 history_filename
= savestring (tmpenv
, strlen(tmpenv
));
2834 else if (!history_filename
) {
2835 /* We include the current directory so that if the user changes
2836 directories the file written will be the same as the one
2838 history_filename
= concat (current_directory
, "/.gdb_history", NULL
);
2840 read_history (history_filename
);
2846 struct cmd_list_element
*c
;
2848 #ifdef DEFAULT_PROMPT
2849 prompt
= savestring (DEFAULT_PROMPT
, strlen(DEFAULT_PROMPT
));
2851 prompt
= savestring ("(gdb) ", 6);
2854 /* Set the important stuff up for command editing. */
2855 command_editing_p
= 1;
2856 history_expansion_p
= 0;
2857 write_history_p
= 0;
2859 /* Setup important stuff for command line editing. */
2860 rl_completion_entry_function
= (int (*)()) symbol_completion_function
;
2861 rl_completer_word_break_characters
= gdb_completer_word_break_characters
;
2862 rl_completer_quote_characters
= gdb_completer_quote_characters
;
2863 rl_readline_name
= "gdb";
2865 /* Define the classes of commands.
2866 They will appear in the help list in the reverse of this order. */
2868 add_cmd ("internals", class_maintenance
, NO_FUNCTION
,
2869 "Maintenance commands.\n\
2870 Some gdb commands are provided just for use by gdb maintainers.\n\
2871 These commands are subject to frequent change, and may not be as\n\
2872 well documented as user commands.",
2874 add_cmd ("obscure", class_obscure
, NO_FUNCTION
, "Obscure features.", &cmdlist
);
2875 add_cmd ("aliases", class_alias
, NO_FUNCTION
, "Aliases of other commands.", &cmdlist
);
2876 add_cmd ("user-defined", class_user
, NO_FUNCTION
, "User-defined commands.\n\
2877 The commands in this class are those defined by the user.\n\
2878 Use the \"define\" command to define a command.", &cmdlist
);
2879 add_cmd ("support", class_support
, NO_FUNCTION
, "Support facilities.", &cmdlist
);
2880 add_cmd ("status", class_info
, NO_FUNCTION
, "Status inquiries.", &cmdlist
);
2881 add_cmd ("files", class_files
, NO_FUNCTION
, "Specifying and examining files.", &cmdlist
);
2882 add_cmd ("breakpoints", class_breakpoint
, NO_FUNCTION
, "Making program stop at certain points.", &cmdlist
);
2883 add_cmd ("data", class_vars
, NO_FUNCTION
, "Examining data.", &cmdlist
);
2884 add_cmd ("stack", class_stack
, NO_FUNCTION
, "Examining the stack.\n\
2885 The stack is made up of stack frames. Gdb assigns numbers to stack frames\n\
2886 counting from zero for the innermost (currently executing) frame.\n\n\
2887 At any time gdb identifies one frame as the \"selected\" frame.\n\
2888 Variable lookups are done with respect to the selected frame.\n\
2889 When the program being debugged stops, gdb selects the innermost frame.\n\
2890 The commands below can be used to select other frames by number or address.",
2892 add_cmd ("running", class_run
, NO_FUNCTION
, "Running the program.", &cmdlist
);
2894 add_com ("pwd", class_files
, pwd_command
,
2895 "Print working directory. This is used for your program as well.");
2896 c
= add_cmd ("cd", class_files
, cd_command
,
2897 "Set working directory to DIR for debugger and program being debugged.\n\
2898 The change does not take effect for the program being debugged\n\
2899 until the next time it is started.", &cmdlist
);
2900 c
->completer
= filename_completer
;
2903 (add_set_cmd ("prompt", class_support
, var_string
, (char *)&prompt
,
2908 add_com ("echo", class_support
, echo_command
,
2909 "Print a constant string. Give string as argument.\n\
2910 C escape sequences may be used in the argument.\n\
2911 No newline is added at the end of the argument;\n\
2912 use \"\\n\" if you want a newline to be printed.\n\
2913 Since leading and trailing whitespace are ignored in command arguments,\n\
2914 if you want to print some you must use \"\\\" before leading whitespace\n\
2915 to be printed or after trailing whitespace.");
2916 add_com ("document", class_support
, document_command
,
2917 "Document a user-defined command.\n\
2918 Give command name as argument. Give documentation on following lines.\n\
2919 End with a line of just \"end\".");
2920 add_com ("define", class_support
, define_command
,
2921 "Define a new command name. Command name is argument.\n\
2922 Definition appears on following lines, one command per line.\n\
2923 End with a line of just \"end\".\n\
2924 Use the \"document\" command to give documentation for the new command.\n\
2925 Commands defined in this way do not take arguments.");
2928 c
= add_cmd ("source", class_support
, source_command
,
2929 "Read commands from a file named FILE.\n\
2930 Note that the file \"" GDBINIT_FILENAME
"\" is read automatically in this way\n\
2931 when gdb is started.", &cmdlist
);
2933 /* Punt file name, we can't help it easily. */
2934 c
= add_cmd ("source", class_support
, source_command
,
2935 "Read commands from a file named FILE.\n\
2936 Note that the file \".gdbinit\" is read automatically in this way\n\
2937 when gdb is started.", &cmdlist
);
2939 c
->completer
= filename_completer
;
2941 add_com ("quit", class_support
, quit_command
, "Exit gdb.");
2942 add_com ("help", class_support
, help_command
, "Print list of commands.");
2943 add_com_alias ("q", "quit", class_support
, 1);
2944 add_com_alias ("h", "help", class_support
, 1);
2947 c
= add_set_cmd ("verbose", class_support
, var_boolean
, (char *)&info_verbose
,
2950 add_show_from_set (c
, &showlist
);
2951 c
->function
.sfunc
= set_verbose
;
2952 set_verbose (NULL
, 0, c
);
2955 (add_set_cmd ("editing", class_support
, var_boolean
, (char *)&command_editing_p
,
2956 "Set editing of command lines as they are typed.\n\
2957 Use \"on\" to enable to enable the editing, and \"off\" to disable it.\n\
2958 Without an argument, command line editing is enabled. To edit, use\n\
2959 EMACS-like or VI-like commands like control-P or ESC.", &setlist
),
2962 add_prefix_cmd ("history", class_support
, set_history
,
2963 "Generic command for setting command history parameters.",
2964 &sethistlist
, "set history ", 0, &setlist
);
2965 add_prefix_cmd ("history", class_support
, show_history
,
2966 "Generic command for showing command history parameters.",
2967 &showhistlist
, "show history ", 0, &showlist
);
2970 (add_set_cmd ("expansion", no_class
, var_boolean
, (char *)&history_expansion_p
,
2971 "Set history expansion on command input.\n\
2972 Without an argument, history expansion is enabled.", &sethistlist
),
2976 (add_set_cmd ("save", no_class
, var_boolean
, (char *)&write_history_p
,
2977 "Set saving of the history record on exit.\n\
2978 Use \"on\" to enable to enable the saving, and \"off\" to disable it.\n\
2979 Without an argument, saving is enabled.", &sethistlist
),
2982 c
= add_set_cmd ("size", no_class
, var_integer
, (char *)&history_size
,
2983 "Set the size of the command history, \n\
2984 ie. the number of previous commands to keep a record of.", &sethistlist
);
2985 add_show_from_set (c
, &showhistlist
);
2986 c
->function
.sfunc
= set_history_size_command
;
2989 (add_set_cmd ("filename", no_class
, var_filename
, (char *)&history_filename
,
2990 "Set the filename in which to record the command history\n\
2991 (the list of previous commands of which a record is kept).", &sethistlist
),
2995 (add_set_cmd ("confirm", class_support
, var_boolean
,
2997 "Set whether to confirm potentially dangerous operations.",
3001 add_prefix_cmd ("info", class_info
, info_command
,
3002 "Generic command for showing things about the program being debugged.",
3003 &infolist
, "info ", 0, &cmdlist
);
3004 add_com_alias ("i", "info", class_info
, 1);
3006 add_com ("complete", class_obscure
, complete_command
,
3007 "List the completions for the rest of the line as a command.");
3009 add_prefix_cmd ("show", class_info
, show_command
,
3010 "Generic command for showing things about the debugger.",
3011 &showlist
, "show ", 0, &cmdlist
);
3012 /* Another way to get at the same thing. */
3013 add_info ("set", show_command
, "Show all GDB settings.");
3015 add_cmd ("commands", no_class
, show_commands
,
3016 "Show the the history of commands you typed.\n\
3017 You can supply a command number to start with, or a `+' to start after\n\
3018 the previous command number shown.",
3021 add_cmd ("version", no_class
, show_version
,
3022 "Show what version of GDB this is.", &showlist
);
3024 add_com ("while", class_support
, while_command
,
3025 "Execute nested commands WHILE the conditional expression is non zero.\n\
3026 The conditional expression must follow the word `while' and must in turn be\
3027 followed by a new line. The nested commands must be entered one per line,\
3028 and should be terminated by the word `end'.");
3030 add_com ("if", class_support
, if_command
,
3031 "Execute nested commands once IF the conditional expression is non zero.\n\
3032 The conditional expression must follow the word `if' and must in turn be\
3033 followed by a new line. The nested commands must be entered one per line,\
3034 and should be terminated by the word 'else' or `end'. If an else clause\
3035 is used, the same rules apply to its nested commands as to the first ones.");
3037 /* If target is open when baud changes, it doesn't take effect until the
3038 next open (I think, not sure). */
3039 add_show_from_set (add_set_cmd ("remotebaud", no_class
,
3040 var_zinteger
, (char *)&baud_rate
,
3041 "Set baud rate for remote serial I/O.\n\
3042 This value is used to set the speed of the serial port when debugging\n\
3043 using remote targets.", &setlist
),
3047 add_set_cmd ("remotedebug", no_class
, var_zinteger
, (char *)&remote_debug
,
3048 "Set debugging of remote protocol.\n\
3049 When enabled, each packet sent or received with the remote target\n\
3050 is displayed.", &setlist
),