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"
33 /* readline include files */
37 /* readline defines this. */
41 #include <sys/types.h>
48 #include <sys/param.h>
52 #ifdef SET_STACK_LIMIT_HUGE
54 #include <sys/resource.h>
56 int original_stack_limit
;
60 /* If this definition isn't overridden by the header files, assume
61 that isatty and fileno exist on this system. */
63 #define ISATTY(FP) (isatty (fileno (FP)))
66 /* Initialization file name for gdb. This is overridden in some configs. */
68 #ifndef GDBINIT_FILENAME
69 #define GDBINIT_FILENAME ".gdbinit"
71 char gdbinit
[] = GDBINIT_FILENAME
;
73 #define ALL_CLEANUPS ((struct cleanup *)0)
75 /* Version number of GDB, as a string. */
79 /* Flag for whether we want all the "from_tty" gubbish printed. */
81 int caution
= 1; /* Default is yes, sigh. */
84 * Define all cmd_list_element's
87 /* Chain containing all defined commands. */
89 struct cmd_list_element
*cmdlist
;
91 /* Chain containing all defined info subcommands. */
93 struct cmd_list_element
*infolist
;
95 /* Chain containing all defined enable subcommands. */
97 struct cmd_list_element
*enablelist
;
99 /* Chain containing all defined disable subcommands. */
101 struct cmd_list_element
*disablelist
;
103 /* Chain containing all defined delete subcommands. */
105 struct cmd_list_element
*deletelist
;
107 /* Chain containing all defined "enable breakpoint" subcommands. */
109 struct cmd_list_element
*enablebreaklist
;
111 /* Chain containing all defined set subcommands */
113 struct cmd_list_element
*setlist
;
115 /* Chain containing all defined show subcommands. */
116 struct cmd_list_element
*showlist
;
118 /* Chain containing all defined \"set history\". */
120 struct cmd_list_element
*sethistlist
;
122 /* Chain containing all defined \"show history\". */
123 struct cmd_list_element
*showhistlist
;
125 /* Chain containing all defined \"unset history\". */
127 struct cmd_list_element
*unsethistlist
;
129 /* stdio stream that command input is being read from. */
133 /* Current working directory. */
135 char *current_directory
;
137 /* The directory name is actually stored here (usually). */
138 static char dirbuf
[MAXPATHLEN
];
140 /* Function to call before reading a command, if nonzero.
141 The function receives two args: an input stream,
142 and a prompt string. */
144 void (*window_hook
) ();
146 extern int frame_file_full_name
;
150 /* The external commands we call... */
151 extern void init_source_path ();
152 extern void directory_command ();
153 extern void exec_file_command ();
154 extern void symbol_file_command ();
155 extern void core_file_command ();
156 extern void tty_command ();
158 extern void help_list ();
159 extern void initialize_all_files ();
160 extern void init_malloc ();
162 /* Forward declarations for this file */
163 void free_command_lines ();
164 char *gdb_readline ();
165 char *command_line_input ();
166 static void initialize_main ();
167 static void initialize_cmd_lists ();
168 static void init_signals ();
169 static void quit_command ();
170 void command_loop ();
171 static void source_command ();
172 static void print_gdb_version ();
173 static void float_handler ();
174 static void cd_command ();
175 static void read_command_file ();
179 /* gdb prints this when reading a command interactively */
182 /* Buffer used for reading command lines, and the size
183 allocated for it so far. */
188 /* Baud rate specified for talking to serial target systems. Default
189 is left as a zero pointer, so targets can choose their own defaults. */
193 /* Signal to catch ^Z typed while reading a command: SIGTSTP or SIGCONT. */
197 #define STOP_SIGNAL SIGTSTP
201 /* Some System V have job control but not sigsetmask(). */
202 #if !defined (HAVE_SIGSETMASK)
203 #define HAVE_SIGSETMASK !defined (USG)
207 #define sigsetmask(n)
210 /* This is how `error' returns to command level. */
212 jmp_buf to_top_level
;
215 return_to_top_level ()
219 bpstat_clear_actions(stop_bpstat
); /* Clear queued breakpoint commands */
220 clear_momentary_breakpoints ();
221 disable_current_display ();
222 do_cleanups (ALL_CLEANUPS
);
223 longjmp (to_top_level
, 1);
226 /* Call FUNC with arg ARGS, catching any errors.
227 If there is no error, return the value returned by FUNC.
228 If there is an error, return zero after printing ERRSTRING
229 (which is in addition to the specific error message already printed). */
232 catch_errors (func
, args
, errstring
)
239 struct cleanup
*saved_cleanup_chain
;
241 saved_cleanup_chain
= save_cleanups ();
243 bcopy (to_top_level
, saved
, sizeof (jmp_buf));
245 if (setjmp (to_top_level
) == 0)
246 val
= (*func
) (args
);
250 fprintf (stderr
, "%s\n", errstring
);
254 restore_cleanups (saved_cleanup_chain
);
256 bcopy (saved
, to_top_level
, sizeof (jmp_buf));
260 /* Handler for SIGHUP. */
265 kill_inferior_fast ();
266 signal (SIGHUP
, SIG_DFL
);
267 kill (getpid (), SIGHUP
);
270 /* Clean up on error during a "source" command (or execution of a
271 user-defined command). */
274 source_cleanup (stream
)
277 /* Restore the previous input stream. */
281 /* Read commands from STREAM. */
283 read_command_file (stream
)
286 struct cleanup
*cleanups
;
288 cleanups
= make_cleanup (source_cleanup
, instream
);
291 do_cleanups (cleanups
);
300 static int inhibit_gdbinit
= 0;
301 static int quiet
= 0;
302 static int batch
= 0;
304 /* Pointers to various arguments from command line. */
306 char *execarg
= NULL
;
307 char *corearg
= NULL
;
311 /* Pointers to all arguments of +command option. */
313 /* Allocated size of cmdarg. */
315 /* Number of elements of cmdarg used. */
318 /* Indices of all arguments of +directory option. */
320 /* Allocated size. */
322 /* Number of elements used. */
327 /* This needs to happen before the first use of malloc. */
330 #if defined (ALIGN_STACK_ON_STARTUP)
331 i
= (int) &count
& 0x3;
337 cmdarg
= (char **) xmalloc (cmdsize
* sizeof (*cmdarg
));
340 dirarg
= (char **) xmalloc (dirsize
* sizeof (*dirarg
));
344 line
= (char *) xmalloc (linesize
);
345 line
[0] = '\0'; /* Terminate saved (now empty) cmd line */
349 current_directory
= dirbuf
;
351 #ifdef SET_STACK_LIMIT_HUGE
355 /* Set the stack limit huge so that alloca (particularly stringtab
356 * in dbxread.c) does not fail. */
357 getrlimit (RLIMIT_STACK
, &rlim
);
358 original_stack_limit
= rlim
.rlim_cur
;
359 rlim
.rlim_cur
= rlim
.rlim_max
;
360 setrlimit (RLIMIT_STACK
, &rlim
);
362 #endif /* SET_STACK_LIMIT_HUGE */
364 /* Parse arguments and options. */
367 static int print_help
;
368 /* When var field is 0, use flag field to record the equivalent
369 short option (or arbitrary numbers starting at 10 for those
370 with no equivalent). */
371 static struct option long_options
[] =
373 {"quiet", 0, &quiet
, 1},
374 {"nx", 0, &inhibit_gdbinit
, 1},
375 {"batch", 0, &batch
, 1},
376 {"epoch", 0, &epoch_interface
, 1},
377 {"fullname", 0, &frame_file_full_name
, 1},
378 {"help", 0, &print_help
, 1},
380 {"symbols", 1, 0, 's'},
385 {"command", 1, 0, 'x'},
387 {"directory", 1, 0, 'd'},
391 /* Allow machine descriptions to add more options... */
392 #ifdef ADDITIONAL_OPTIONS
400 c
= getopt_long_only (argc
, argv
, "",
401 long_options
, &option_index
);
405 /* Long option that takes an argument. */
406 if (c
== 0 && long_options
[option_index
].flag
== 0)
407 c
= long_options
[option_index
].val
;
412 /* Long option that just sets a flag. */
431 cmdarg
[ncmd
++] = optarg
;
435 cmdarg
= (char **) xrealloc ((char *)cmdarg
,
436 cmdsize
* sizeof (*cmdarg
));
440 dirarg
[ndir
++] = optarg
;
444 dirarg
= (char **) xrealloc ((char *)dirarg
,
445 dirsize
* sizeof (*dirarg
));
457 #ifdef ADDITIONAL_OPTION_CASES
458 ADDITIONAL_OPTION_CASES
462 "Use `%s +help' for a complete list of options.\n",
471 This is GDB, the GNU debugger. Use the command\n\
472 gdb [options] [executable [core-file]]\n\
473 to enter the debugger.\n\
475 Options available are:\n\
476 -help Print this message.\n\
477 -quiet Do not print version number on startup.\n\
478 -fullname Output information used by emacs-GDB interface.\n\
479 -epoch Output information used by epoch emacs-GDB interface.\n\
480 -batch Exit after processing options.\n\
481 -nx Do not read .gdbinit file.\n\
482 -tty=TTY Use TTY for input/output by the program being debugged.\n\
483 -cd=DIR Change current directory to DIR.\n\
484 -directory=DIR Search for source files in DIR.\n\
485 -command=FILE Execute GDB commands from FILE.\n\
486 -symbols=SYMFILE Read symbols from SYMFILE.\n\
487 -exec=EXECFILE Use EXECFILE as the executable.\n\
488 -se=FILE Use FILE as symbol file and executable file.\n\
489 -core=COREFILE Analyze the core dump COREFILE.\n\
490 -b BAUDRATE Set serial port baud rate used for remote debugging\n\
492 #ifdef ADDITIONAL_OPTION_HELP
493 fputs (ADDITIONAL_OPTION_HELP
, stderr
);
496 For more information, type \"help\" from within GDB, or consult the\n\
497 GDB manual (available as on-line info or a printed manual).\n", stderr
);
498 /* Exiting after printing this message seems like
499 the most useful thing to do. */
503 /* OK, that's all the options. The other arguments are filenames. */
505 for (; optind
< argc
; optind
++)
509 symarg
= argv
[optind
];
510 execarg
= argv
[optind
];
513 corearg
= argv
[optind
];
517 "Excess command line arguments ignored. (%s%s)\n",
518 argv
[optind
], (optind
== argc
- 1) ? "" : " ...");
525 /* Run the init function of each source file */
527 initialize_cmd_lists (); /* This needs to be done first */
528 initialize_all_files ();
529 initialize_main (); /* But that omits this file! Do it now */
534 /* Print all the junk in one place, with a blank line after it
535 to separate it from important stuff like "no such file".
536 Also, we skip most of the noise, like Emacs, if started with
537 a file name rather than with no arguments. */
539 print_gdb_version (1);
540 printf ("Type \"help\" for a list of commands.\n\n");
544 /* Now perform all the actions indicated by the arguments. */
547 if (!setjmp (to_top_level
))
549 cd_command (cdarg
, 0);
553 do_cleanups (ALL_CLEANUPS
);
555 for (i
= 0; i
< ndir
; i
++)
556 if (!setjmp (to_top_level
))
557 directory_command (dirarg
[i
], 0);
559 do_cleanups (ALL_CLEANUPS
);
563 && strcmp (execarg
, symarg
) == 0)
565 /* The exec file and the symbol-file are the same. If we can't open
566 it, better only print one error message. */
567 if (!setjmp (to_top_level
))
569 exec_file_command (execarg
, !batch
);
570 symbol_file_command (symarg
, !batch
);
576 if (!setjmp (to_top_level
))
577 exec_file_command (execarg
, !batch
);
579 if (!setjmp (to_top_level
))
580 symbol_file_command (symarg
, !batch
);
582 do_cleanups (ALL_CLEANUPS
);
585 if (!setjmp (to_top_level
))
586 core_file_command (corearg
, !batch
);
587 else if (isdigit (corearg
[0]) && !setjmp (to_top_level
))
588 attach_command (corearg
, !batch
);
589 do_cleanups (ALL_CLEANUPS
);
592 if (!setjmp (to_top_level
))
593 tty_command (ttyarg
, !batch
);
594 do_cleanups (ALL_CLEANUPS
);
596 #ifdef ADDITIONAL_OPTION_HANDLER
597 ADDITIONAL_OPTION_HANDLER
;
601 struct stat homebuf
, cwdbuf
;
602 char *homedir
, *homeinit
;
604 /* Read init file, if it exists in home directory */
605 homedir
= getenv ("HOME");
608 homeinit
= (char *) alloca (strlen (getenv ("HOME")) +
609 strlen (gdbinit
) + 10);
610 strcpy (homeinit
, getenv ("HOME"));
611 strcat (homeinit
, "/");
612 strcat (homeinit
, gdbinit
);
613 if (!inhibit_gdbinit
&& access (homeinit
, R_OK
) == 0)
614 if (!setjmp (to_top_level
))
615 source_command (homeinit
, 0);
616 do_cleanups (ALL_CLEANUPS
);
618 /* Do stats; no need to do them elsewhere since we'll only
619 need them if homedir is set. Make sure that they are
620 zero in case one of them fails (this guarantees that they
621 won't match if either exists). */
623 bzero (&homebuf
, sizeof (struct stat
));
624 bzero (&cwdbuf
, sizeof (struct stat
));
626 stat (homeinit
, &homebuf
);
627 stat (gdbinit
, &cwdbuf
); /* We'll only need this if
631 /* Read the input file in the current directory, *if* it isn't
632 the same file (it should exist, also). */
635 || bcmp ((char *) &homebuf
,
637 sizeof (struct stat
)))
638 if (!inhibit_gdbinit
&& access (gdbinit
, R_OK
) == 0)
639 if (!setjmp (to_top_level
))
640 source_command (gdbinit
, 0);
641 do_cleanups (ALL_CLEANUPS
);
644 for (i
= 0; i
< ncmd
; i
++)
645 if (!setjmp (to_top_level
))
647 if (cmdarg
[i
][0] == '-' && cmdarg
[i
][1] == '\0')
648 read_command_file (stdin
);
650 source_command (cmdarg
[i
], !batch
);
651 do_cleanups (ALL_CLEANUPS
);
657 /* We have hit the end of the batch file. */
661 /* Do any host- or target-specific hacks. This is used for i960 targets
662 to force the user to set a nindy target and spec its parameters. */
664 #ifdef BEFORE_MAIN_LOOP_HOOK
665 BEFORE_MAIN_LOOP_HOOK
;
668 /* The command loop. */
672 if (!setjmp (to_top_level
))
674 do_cleanups (ALL_CLEANUPS
); /* Do complete cleanup */
676 quit_command ((char *)0, instream
== stdin
);
679 /* No exit -- exit is through quit_command. */
682 /* Execute the line P as a command.
683 Pass FROM_TTY as second argument to the defining function. */
686 execute_command (p
, from_tty
)
690 register struct cmd_list_element
*c
;
691 register struct command_line
*cmdlines
;
695 /* This can happen when command_line_input hits end of file. */
699 while (*p
== ' ' || *p
== '\t') p
++;
704 c
= lookup_cmd (&p
, cmdlist
, "", 0, 1);
705 /* Pass null arg rather than an empty one. */
707 if (c
->class == class_user
)
709 struct cleanup
*old_chain
;
712 error ("User-defined commands cannot take arguments.");
713 cmdlines
= c
->user_commands
;
718 /* Set the instream to 0, indicating execution of a
719 user-defined function. */
720 old_chain
= make_cleanup (source_cleanup
, instream
);
721 instream
= (FILE *) 0;
724 execute_command (cmdlines
->line
, 0);
725 cmdlines
= cmdlines
->next
;
727 do_cleanups (old_chain
);
729 else if (c
->type
== set_cmd
|| c
->type
== show_cmd
)
730 do_setshow_command (arg
, from_tty
& caution
, c
);
731 else if (c
->function
== NO_FUNCTION
)
732 error ("That is not a command, just a help topic.");
734 (*c
->function
) (arg
, from_tty
& caution
);
740 command_loop_marker (foo
)
745 /* Read commands from `instream' and execute them
746 until end of file or error reading instream. */
750 struct cleanup
*old_chain
;
752 int stdin_is_tty
= ISATTY (stdin
);
754 while (!feof (instream
))
756 if (window_hook
&& instream
== stdin
)
757 (*window_hook
) (instream
, prompt
);
760 if (instream
== stdin
&& stdin_is_tty
)
761 reinitialize_more_filter ();
762 old_chain
= make_cleanup (command_loop_marker
, 0);
763 command
= command_line_input (instream
== stdin
? prompt
: 0,
767 execute_command (command
, instream
== stdin
);
768 /* Do any commands attached to breakpoint we stopped at. */
769 bpstat_do_actions (&stop_bpstat
);
770 do_cleanups (old_chain
);
774 /* Commands call this if they do not want to be repeated by null lines. */
779 /* If we aren't reading from standard input, we are saving the last
780 thing read from stdin in line and don't want to delete it. Null lines
781 won't repeat here in any case. */
782 if (instream
== stdin
)
786 /* Read a line from the stream "instream" without command line editing.
788 It prints PRROMPT once at the start.
789 Action is compatible with "readline", e.g. space for the result is
790 malloc'd and should be freed by the caller.
792 A NULL return means end of file. */
794 gdb_readline (prrompt
)
800 int result_size
= 80;
808 result
= (char *) xmalloc (result_size
);
812 /* Read from stdin if we are executing a user defined command.
813 This is the right thing for prompt_for_continue, at least. */
814 c
= fgetc (instream
? instream
: stdin
);
825 result
[input_index
++] = c
;
826 while (input_index
>= result_size
)
829 result
= (char *) xrealloc (result
, result_size
);
833 result
[input_index
++] = '\0';
837 /* Declaration for fancy readline with command line editing. */
840 /* Variables which control command line editing and history
841 substitution. These variables are given default values at the end
843 static int command_editing_p
;
844 static int history_expansion_p
;
845 static int write_history_p
;
846 static int history_size
;
847 static char *history_filename
;
849 /* Variables which are necessary for fancy command line editing. */
850 char *gdb_completer_word_break_characters
=
851 " \t\n!@#$%^&*()-+=|~`}{[]\"';:?/>.<,";
853 /* Functions that are used as part of the fancy command line editing. */
855 /* This can be used for functions which don't want to complete on symbols
856 but don't want to complete on anything else either. */
859 noop_completer (text
)
865 /* Generate symbol names one by one for the completer. If STATE is
866 zero, then we need to initialize, otherwise the initialization has
867 already taken place. TEXT is what we expect the symbol to start
868 with. RL_LINE_BUFFER is available to be looked at; it contains the
869 entire text of the line. RL_POINT is the offset in that line of
870 the cursor. You should pretend that the line ends at RL_POINT.
871 The result is NULL if there are no more completions, else a char
872 string which is a possible completion. */
874 symbol_completion_function (text
, state
)
878 static char **list
= (char **)NULL
;
881 extern char *rl_line_buffer
;
883 char *tmp_command
, *p
;
884 struct cmd_list_element
*c
, *result_list
;
888 /* Free the storage used by LIST, but not by the strings inside. This is
889 because rl_complete_internal () frees the strings. */
895 /* Decide whether to complete on a list of gdb commands or on
897 tmp_command
= (char *) alloca (rl_point
+ 1);
900 strncpy (tmp_command
, rl_line_buffer
, rl_point
);
901 tmp_command
[rl_point
] = '\0';
905 /* An empty line we want to consider ambiguous; that is,
906 it could be any command. */
907 c
= (struct cmd_list_element
*) -1;
911 c
= lookup_cmd_1 (&p
, cmdlist
, &result_list
, 1);
913 /* Move p up to the next interesting thing. */
914 while (*p
== ' ' || *p
== '\t')
918 /* He's typed something unrecognizable. Sigh. */
920 else if (c
== (struct cmd_list_element
*) -1)
922 /* If we didn't recognize everything up to the thing that
923 needs completing, and we don't know what command it is
924 yet, we are in trouble. Part of the trouble might be
925 that the list of delimiters used by readline includes
926 '-', which we use in commands. Check for this. */
927 if (p
+ strlen(text
) != tmp_command
+ rl_point
) {
928 if (tmp_command
[rl_point
- strlen(text
) - 1] == '-')
931 /* This really should not produce an error. Better would
932 be to pretend to hit RETURN here; this would produce a
933 response like "Ambiguous command: foo, foobar, etc",
934 and leave the line available for re-entry with ^P. Instead,
935 this error blows away the user's typed input without
936 any way to get it back. */
937 error (" Unrecognized command.");
941 /* He's typed something ambiguous. This is easier. */
943 list
= complete_on_cmdlist (*result_list
->prefixlist
, text
);
945 list
= complete_on_cmdlist (cmdlist
, text
);
949 /* If we've gotten this far, gdb has recognized a full
950 command. There are several possibilities:
952 1) We need to complete on the command.
953 2) We need to complete on the possibilities coming after
955 2) We need to complete the text of what comes after the
959 /* Always (might be longer versions of thie command). */
960 list
= complete_on_cmdlist (result_list
, text
);
961 else if (!*p
&& !*text
)
964 list
= complete_on_cmdlist (*c
->prefixlist
, "");
966 list
= (*c
->completer
) ("");
970 if (c
->prefixlist
&& !c
->allow_unknown
)
973 /* Something like "info adsfkdj". But error() is not
974 the proper response; just return no completions
977 error ("\"%s\" command requires a subcommand.",
984 list
= (*c
->completer
) (text
);
989 /* If the debugged program wasn't compiled with symbols, or if we're
990 clearly completing on a command and no command matches, return
993 return ((char *)NULL
);
995 output
= list
[index
];
1006 #if STOP_SIGNAL == SIGTSTP
1007 signal (SIGTSTP
, SIG_DFL
);
1009 kill (getpid (), SIGTSTP
);
1010 signal (SIGTSTP
, stop_sig
);
1012 signal (STOP_SIGNAL
, stop_sig
);
1014 printf ("%s", prompt
);
1017 /* Forget about any previous command -- null line now will do nothing. */
1020 #endif /* STOP_SIGNAL */
1022 /* Initialize signal handlers. */
1031 extern void request_quit ();
1033 signal (SIGINT
, request_quit
);
1035 /* If we initialize SIGQUIT to SIG_IGN, then the SIG_IGN will get
1036 passed to the inferior, which we don't want. It would be
1037 possible to do a "signal (SIGQUIT, SIG_DFL)" after we fork, but
1038 on BSD4.3 systems using vfork, that can affect the
1039 GDB process as well as the inferior (the signal handling tables
1040 might be in memory, shared between the two). Since we establish
1041 a handler for SIGQUIT, when we call exec it will set the signal
1042 to SIG_DFL for us. */
1043 signal (SIGQUIT
, do_nothing
);
1044 if (signal (SIGHUP
, do_nothing
) != SIG_IGN
)
1045 signal (SIGHUP
, disconnect
);
1046 signal (SIGFPE
, float_handler
);
1049 /* Read one line from the command input stream `instream'
1050 into the local static buffer `linebuffer' (whose current length
1052 The buffer is made bigger as necessary.
1053 Returns the address of the start of the line.
1055 NULL is returned for end of file.
1057 *If* the instream == stdin & stdin is a terminal, the line read
1058 is copied into the file line saver (global var char *line,
1059 length linesize) so that it can be duplicated.
1061 This routine either uses fancy command line editing or
1062 simple input as the user has requested. */
1065 command_line_input (prrompt
, repeat
)
1069 static char *linebuffer
= 0;
1070 static int linelength
= 0;
1074 char *local_prompt
= prrompt
;
1079 if (linebuffer
== 0)
1082 linebuffer
= (char *) xmalloc (linelength
);
1087 /* Control-C quits instantly if typed while in this loop
1088 since it should not wait until the user types a newline. */
1091 signal (STOP_SIGNAL
, stop_sig
);
1096 /* Reports are that some Sys V's don't flush stdout/err on reads
1097 from stdin, when stdin/out are sockets rather than ttys. So we
1098 have to do it ourselves, to make emacs-gdb and xxgdb work.
1099 On other machines, doing this once per input should be a cheap nop. */
1103 /* Don't use fancy stuff if not talking to stdin. */
1104 if (command_editing_p
&& instream
== stdin
1105 && ISATTY (instream
))
1106 rl
= readline (local_prompt
);
1108 rl
= gdb_readline (local_prompt
);
1110 if (!rl
|| rl
== (char *) EOF
)
1115 if (strlen(rl
) + 1 + (p
- linebuffer
) > linelength
)
1117 linelength
= strlen(rl
) + 1 + (p
- linebuffer
);
1118 nline
= (char *) xrealloc (linebuffer
, linelength
);
1119 p
+= nline
- linebuffer
;
1123 /* Copy line. Don't copy null at end. (Leaves line alone
1124 if this was just a newline) */
1128 free (rl
); /* Allocated in readline. */
1130 if (p
== linebuffer
|| *(p
- 1) != '\\')
1133 p
--; /* Put on top of '\'. */
1134 local_prompt
= (char *) 0;
1138 signal (SIGTSTP
, SIG_DFL
);
1145 /* Do history expansion if that is wished. */
1146 if (history_expansion_p
&& instream
== stdin
1147 && ISATTY (instream
))
1149 char *history_value
;
1152 *p
= '\0'; /* Insert null now. */
1153 expanded
= history_expand (linebuffer
, &history_value
);
1156 /* Print the changes. */
1157 printf ("%s\n", history_value
);
1159 /* If there was an error, call this function again. */
1162 free (history_value
);
1163 return command_line_input (prrompt
, repeat
);
1165 if (strlen (history_value
) > linelength
)
1167 linelength
= strlen (history_value
) + 1;
1168 linebuffer
= (char *) xrealloc (linebuffer
, linelength
);
1170 strcpy (linebuffer
, history_value
);
1171 p
= linebuffer
+ strlen(linebuffer
);
1172 free (history_value
);
1176 /* If we just got an empty line, and that is supposed
1177 to repeat the previous command, return the value in the
1181 if (p
== linebuffer
)
1184 while (*p1
== ' ' || *p1
== '\t')
1192 /* Add line to history if appropriate. */
1193 if (instream
== stdin
1194 && ISATTY (stdin
) && *linebuffer
)
1195 add_history (linebuffer
);
1197 /* Note: lines consisting soley of comments are added to the command
1198 history. This is useful when you type a command, and then
1199 realize you don't want to execute it quite yet. You can comment
1200 out the command and then later fetch it from the value history
1201 and remove the '#'. The kill ring is probably better, but some
1202 people are in the habit of commenting things out. */
1204 while ((c
= *p1
++) != '\0')
1207 while ((c
= *p1
++) != '"')
1209 /* Make sure an escaped '"' doesn't make us think the string
1217 while ((c
= *p1
++) != '\'')
1219 /* Make sure an escaped '\'' doesn't make us think the string
1228 /* Found a comment. */
1234 /* Save into global buffer if appropriate. */
1237 if (linelength
> linesize
)
1239 line
= xrealloc (line
, linelength
);
1240 linesize
= linelength
;
1242 strcpy (line
, linebuffer
);
1249 /* Read lines from the input stream
1250 and accumulate them in a chain of struct command_line's
1251 which is then returned. */
1253 struct command_line
*
1254 read_command_lines ()
1256 struct command_line
*first
= 0;
1257 register struct command_line
*next
, *tail
= 0;
1258 register char *p
, *p1
;
1259 struct cleanup
*old_chain
= 0;
1264 p
= command_line_input (0, instream
== stdin
);
1266 /* Treat end of file like "end". */
1269 /* Remove leading and trailing blanks. */
1270 while (*p
== ' ' || *p
== '\t') p
++;
1271 p1
= p
+ strlen (p
);
1272 while (p1
!= p
&& (p1
[-1] == ' ' || p1
[-1] == '\t')) p1
--;
1274 /* Is this "end"? */
1275 if (p1
- p
== 3 && !strncmp (p
, "end", 3))
1278 /* No => add this line to the chain of command lines. */
1279 next
= (struct command_line
*) xmalloc (sizeof (struct command_line
));
1280 next
->line
= savestring (p
, p1
- p
);
1288 /* We just read the first line.
1289 From now on, arrange to throw away the lines we have
1290 if we quit or get an error while inside this function. */
1292 old_chain
= make_cleanup (free_command_lines
, &first
);
1299 /* Now we are about to return the chain to our caller,
1300 so freeing it becomes his responsibility. */
1302 discard_cleanups (old_chain
);
1306 /* Free a chain of struct command_line's. */
1309 free_command_lines (lptr
)
1310 struct command_line
**lptr
;
1312 register struct command_line
*l
= *lptr
;
1313 register struct command_line
*next
;
1324 /* Add an element to the list of info subcommands. */
1327 add_info (name
, fun
, doc
)
1332 add_cmd (name
, no_class
, fun
, doc
, &infolist
);
1335 /* Add an alias to the list of info subcommands. */
1338 add_info_alias (name
, oldname
, abbrev_flag
)
1343 add_alias_cmd (name
, oldname
, 0, abbrev_flag
, &infolist
);
1346 /* The "info" command is defined as a prefix, with allow_unknown = 0.
1347 Therefore, its own definition is called only for "info" with no args. */
1351 info_command (arg
, from_tty
)
1355 printf ("\"info\" must be followed by the name of an info command.\n");
1356 help_list (infolist
, "info ", -1, stdout
);
1359 /* The "show" command with no arguments shows all the settings. */
1363 show_command (arg
, from_tty
)
1367 cmd_show_list (showlist
, from_tty
, "");
1370 /* Add an element to the list of commands. */
1373 add_com (name
, class, fun
, doc
)
1375 enum command_class
class;
1379 add_cmd (name
, class, fun
, doc
, &cmdlist
);
1382 /* Add an alias or abbreviation command to the list of commands. */
1385 add_com_alias (name
, oldname
, class, abbrev_flag
)
1388 enum command_class
class;
1391 add_alias_cmd (name
, oldname
, class, abbrev_flag
, &cmdlist
);
1398 error ("Argument required (%s).", why
);
1403 help_command (command
, from_tty
)
1405 int from_tty
; /* Ignored */
1407 help_cmd (command
, stdout
);
1411 validate_comname (comname
)
1417 error_no_arg ("name of command to define");
1422 if (!(*p
>= 'A' && *p
<= 'Z')
1423 && !(*p
>= 'a' && *p
<= 'z')
1424 && !(*p
>= '0' && *p
<= '9')
1426 error ("Junk in argument list: \"%s\"", p
);
1432 define_command (comname
, from_tty
)
1436 register struct command_line
*cmds
;
1437 register struct cmd_list_element
*c
, *newc
;
1438 char *tem
= comname
;
1439 extern void not_just_help_class_command ();
1441 validate_comname (comname
);
1443 c
= lookup_cmd (&tem
, cmdlist
, "", -1, 1);
1446 if (c
->class == class_user
|| c
->class == class_alias
)
1447 tem
= "Redefine command \"%s\"? ";
1449 tem
= "Really redefine built-in command \"%s\"? ";
1450 if (!query (tem
, comname
))
1451 error ("Command \"%s\" not redefined.", comname
);
1456 printf ("Type commands for definition of \"%s\".\n\
1457 End with a line saying just \"end\".\n", comname
);
1460 comname
= savestring (comname
, strlen (comname
));
1462 cmds
= read_command_lines ();
1464 if (c
&& c
->class == class_user
)
1465 free_command_lines (&c
->user_commands
);
1467 newc
= add_cmd (comname
, class_user
, not_just_help_class_command
,
1468 (c
&& c
->class == class_user
)
1469 ? c
->doc
: savestring ("User-defined.", 13), &cmdlist
);
1470 newc
->user_commands
= cmds
;
1474 document_command (comname
, from_tty
)
1478 struct command_line
*doclines
;
1479 register struct cmd_list_element
*c
;
1480 char *tem
= comname
;
1482 validate_comname (comname
);
1484 c
= lookup_cmd (&tem
, cmdlist
, "", 0, 1);
1486 if (c
->class != class_user
)
1487 error ("Command \"%s\" is built-in.", comname
);
1490 printf ("Type documentation for \"%s\".\n\
1491 End with a line saying just \"end\".\n", comname
);
1493 doclines
= read_command_lines ();
1495 if (c
->doc
) free (c
->doc
);
1498 register struct command_line
*cl1
;
1499 register int len
= 0;
1501 for (cl1
= doclines
; cl1
; cl1
= cl1
->next
)
1502 len
+= strlen (cl1
->line
) + 1;
1504 c
->doc
= (char *) xmalloc (len
+ 1);
1507 for (cl1
= doclines
; cl1
; cl1
= cl1
->next
)
1509 strcat (c
->doc
, cl1
->line
);
1511 strcat (c
->doc
, "\n");
1515 free_command_lines (&doclines
);
1519 print_gdb_version (shout
)
1522 printf ("GDB %s, Copyright (C) 1991 Free Software Foundation, Inc.\n",
1526 There is ABSOLUTELY NO WARRANTY for GDB; type \"info warranty\" for details.\n\
1527 GDB is free software and you are welcome to distribute copies of it\n\
1528 under certain conditions; type \"info copying\" to see the conditions.\n");
1533 show_version (args
, from_tty
)
1538 print_gdb_version (0);
1542 /* xgdb calls this to reprint the usual GDB prompt. */
1547 printf ("%s", prompt
);
1552 quit_command (args
, from_tty
)
1556 if (inferior_pid
!= 0 && target_has_execution
)
1558 if (query ("The program is running. Quit anyway? "))
1560 target_kill (args
, from_tty
);
1563 error ("Not confirmed.");
1565 /* Save the history information if it is appropriate to do so. */
1566 if (write_history_p
&& history_filename
)
1567 write_history (history_filename
);
1572 input_from_terminal_p ()
1574 return (instream
== stdin
) & caution
;
1579 pwd_command (args
, from_tty
)
1583 if (args
) error ("The \"pwd\" command does not take an argument: %s", args
);
1586 if (strcmp (dirbuf
, current_directory
))
1587 printf ("Working directory %s\n (canonically %s).\n",
1588 current_directory
, dirbuf
);
1590 printf ("Working directory %s.\n", current_directory
);
1594 cd_command (dir
, from_tty
)
1601 /* If the new directory is absolute, repeat is a no-op; if relative,
1602 repeat might be useful but is more likely to be a mistake. */
1606 error_no_arg ("new working directory");
1608 dir
= tilde_expand (dir
);
1609 make_cleanup (free
, dir
);
1612 dir
= savestring (dir
, len
- (len
> 1 && dir
[len
-1] == '/'));
1614 current_directory
= dir
;
1617 current_directory
= concat (current_directory
, "/", dir
);
1621 /* Now simplify any occurrences of `.' and `..' in the pathname. */
1629 for (p
= current_directory
; *p
;)
1631 if (!strncmp (p
, "/./", 2)
1632 && (p
[2] == 0 || p
[2] == '/'))
1634 else if (!strncmp (p
, "/..", 3)
1635 && (p
[3] == 0 || p
[3] == '/')
1636 && p
!= current_directory
)
1639 while (q
!= current_directory
&& q
[-1] != '/') q
--;
1640 if (q
!= current_directory
)
1650 if (chdir (dir
) < 0)
1651 perror_with_name (dir
);
1653 forget_cached_source_info ();
1656 pwd_command ((char *) 0, 1);
1661 source_command (args
, from_tty
)
1666 struct cleanup
*cleanups
;
1670 /* Let source without arguments read .gdbinit. */
1673 file
= tilde_expand (file
);
1674 make_cleanup (free
, file
);
1676 stream
= fopen (file
, "r");
1678 perror_with_name (file
);
1680 cleanups
= make_cleanup (fclose
, stream
);
1682 read_command_file (stream
);
1684 do_cleanups (cleanups
);
1689 echo_command (text
, from_tty
)
1701 /* \ at end of argument is used after spaces
1702 so they won't be lost. */
1706 c
= parse_escape (&p
);
1718 dump_me_command (args
, from_tty
)
1722 if (query ("Should GDB dump core? "))
1724 signal (SIGQUIT
, SIG_DFL
);
1725 kill (getpid (), SIGQUIT
);
1729 /* Functions to manipulate command line editing control variables. */
1731 /* Number of commands to print in each call to show_commands. */
1732 #define Hist_print 10
1734 show_commands (args
, from_tty
)
1738 /* Index for history commands. Relative to history_base. */
1741 /* Number of the history entry which we are planning to display next.
1742 Relative to history_base. */
1745 /* The first command in the history which doesn't exist (i.e. one more
1746 than the number of the last command). Relative to history_base. */
1749 struct _hist_entry
*history_get();
1750 extern int history_base
;
1753 /* This is all reported by individual "show" commands. */
1754 printf_filtered ("Interactive command editing is %s.\n",
1755 command_editing_p
? "on" : "off");
1757 printf_filtered ("History expansion of command input is %s.\n",
1758 history_expansion_p
? "on" : "off");
1759 printf_filtered ("Writing of a history record upon exit is %s.\n",
1760 write_history_p
? "enabled" : "disabled");
1761 printf_filtered ("The size of the history list (number of stored commands) is %d.\n",
1763 printf_filtered ("The name of the history record is \"%s\".\n\n",
1764 history_filename
? history_filename
: "");
1767 /* Print out some of the commands from the command history. */
1768 /* First determine the length of the history list. */
1769 hist_len
= history_size
;
1770 for (offset
= 0; offset
< history_size
; offset
++)
1772 if (!history_get (history_base
+ offset
))
1781 if (args
[0] == '+' && args
[1] == '\0')
1782 /* "info editing +" should print from the stored position. */
1785 /* "info editing <exp>" should print around command number <exp>. */
1786 num
= (parse_and_eval_address (args
) - history_base
) - Hist_print
/ 2;
1788 /* "info editing" means print the last Hist_print commands. */
1791 num
= hist_len
- Hist_print
;
1797 /* If there are at least Hist_print commands, we want to display the last
1798 Hist_print rather than, say, the last 6. */
1799 if (hist_len
- num
< Hist_print
)
1801 num
= hist_len
- Hist_print
;
1807 /* No need for a header now that "info editing" only prints one thing. */
1808 if (num
== hist_len
- Hist_print
)
1809 printf_filtered ("The list of the last %d commands is:\n\n", Hist_print
);
1811 printf_filtered ("Some of the stored commands are:\n\n");
1814 for (offset
= num
; offset
< num
+ Hist_print
&& offset
< hist_len
; offset
++)
1816 printf_filtered ("%5d %s\n", history_base
+ offset
,
1817 (history_get (history_base
+ offset
))->line
);
1820 /* The next command we want to display is the next one that we haven't
1824 /* If the user repeats this command with return, it should do what
1825 "info editing +" does. This is unnecessary if arg is null,
1826 because "info editing +" is not useful after "info editing". */
1827 if (from_tty
&& args
)
1834 /* Called by do_setshow_command. */
1837 set_history_size_command (args
, from_tty
, c
)
1840 struct cmd_list_element
*c
;
1842 if (history_size
== UINT_MAX
)
1843 unstifle_history ();
1845 stifle_history (history_size
);
1850 set_history (args
, from_tty
)
1854 printf ("\"set history\" must be followed by the name of a history subcommand.\n");
1855 help_list (sethistlist
, "set history ", -1, stdout
);
1860 show_history (args
, from_tty
)
1864 cmd_show_list (showhistlist
, from_tty
, "");
1867 int info_verbose
= 0; /* Default verbose msgs off */
1869 /* Called by do_setshow_command. An elaborate joke. */
1872 set_verbose (args
, from_tty
, c
)
1875 struct cmd_list_element
*c
;
1877 char *cmdname
= "verbose";
1878 struct cmd_list_element
*showcmd
;
1880 showcmd
= lookup_cmd_1 (&cmdname
, showlist
, NULL
, 1);
1884 c
->doc
= "Set verbose printing of informational messages.";
1885 showcmd
->doc
= "Show verbose printing of informational messages.";
1889 c
->doc
= "Set verbosity.";
1890 showcmd
->doc
= "Show verbosity.";
1897 /* This message is based on ANSI C, section 4.7. Note that integer
1898 divide by zero causes this, so "float" is a misnomer. */
1899 error ("Erroneous arithmetic operation.");
1902 /* Return whether we are running a batch file or from terminal. */
1906 return !(instream
== stdin
&& ISATTY (stdin
));
1911 initialize_cmd_lists ()
1913 cmdlist
= (struct cmd_list_element
*) 0;
1914 infolist
= (struct cmd_list_element
*) 0;
1915 enablelist
= (struct cmd_list_element
*) 0;
1916 disablelist
= (struct cmd_list_element
*) 0;
1917 deletelist
= (struct cmd_list_element
*) 0;
1918 enablebreaklist
= (struct cmd_list_element
*) 0;
1919 setlist
= (struct cmd_list_element
*) 0;
1921 sethistlist
= (struct cmd_list_element
*) 0;
1922 showhistlist
= NULL
;
1923 unsethistlist
= (struct cmd_list_element
*) 0;
1929 struct cmd_list_element
*c
;
1933 #ifdef DEFAULT_PROMPT
1934 prompt
= savestring (DEFAULT_PROMPT
, strlen(DEFAULT_PROMPT
));
1936 prompt
= savestring ("(gdb) ", 6);
1939 /* Set the important stuff up for command editing. */
1940 command_editing_p
= 1;
1941 history_expansion_p
= 0;
1942 write_history_p
= 0;
1944 if (tmpenv
= getenv ("HISTSIZE"))
1945 history_size
= atoi (tmpenv
);
1949 stifle_history (history_size
);
1951 if (tmpenv
= getenv ("GDBHISTFILE"))
1952 history_filename
= savestring (tmpenv
, strlen(tmpenv
));
1954 /* We include the current directory so that if the user changes
1955 directories the file written will be the same as the one
1957 history_filename
= concat (current_directory
, "/.gdb_history", "");
1959 read_history (history_filename
);
1961 /* Setup important stuff for command line editing. */
1962 rl_completion_entry_function
= (int (*)()) symbol_completion_function
;
1963 rl_completer_word_break_characters
= gdb_completer_word_break_characters
;
1964 rl_readline_name
= "gdb";
1966 /* Define the classes of commands.
1967 They will appear in the help list in the reverse of this order. */
1969 add_cmd ("obscure", class_obscure
, NO_FUNCTION
, "Obscure features.", &cmdlist
);
1970 add_cmd ("aliases", class_alias
, NO_FUNCTION
, "Aliases of other commands.", &cmdlist
);
1971 add_cmd ("user-defined", class_user
, NO_FUNCTION
, "User-defined commands.\n\
1972 The commands in this class are those defined by the user.\n\
1973 Use the \"define\" command to define a command.", &cmdlist
);
1974 add_cmd ("support", class_support
, NO_FUNCTION
, "Support facilities.", &cmdlist
);
1975 add_cmd ("status", class_info
, NO_FUNCTION
, "Status inquiries.", &cmdlist
);
1976 add_cmd ("files", class_files
, NO_FUNCTION
, "Specifying and examining files.", &cmdlist
);
1977 add_cmd ("breakpoints", class_breakpoint
, NO_FUNCTION
, "Making program stop at certain points.", &cmdlist
);
1978 add_cmd ("data", class_vars
, NO_FUNCTION
, "Examining data.", &cmdlist
);
1979 add_cmd ("stack", class_stack
, NO_FUNCTION
, "Examining the stack.\n\
1980 The stack is made up of stack frames. Gdb assigns numbers to stack frames\n\
1981 counting from zero for the innermost (currently executing) frame.\n\n\
1982 At any time gdb identifies one frame as the \"selected\" frame.\n\
1983 Variable lookups are done with respect to the selected frame.\n\
1984 When the program being debugged stops, gdb selects the innermost frame.\n\
1985 The commands below can be used to select other frames by number or address.",
1987 add_cmd ("running", class_run
, NO_FUNCTION
, "Running the program.", &cmdlist
);
1989 add_com ("pwd", class_files
, pwd_command
,
1990 "Print working directory. This is used for your program as well.");
1991 add_com ("cd", class_files
, cd_command
,
1992 "Set working directory to DIR for debugger and program being debugged.\n\
1993 The change does not take effect for the program being debugged\n\
1994 until the next time it is started.");
1997 (add_set_cmd ("prompt", class_support
, var_string
, (char *)&prompt
,
2002 add_com ("echo", class_support
, echo_command
,
2003 "Print a constant string. Give string as argument.\n\
2004 C escape sequences may be used in the argument.\n\
2005 No newline is added at the end of the argument;\n\
2006 use \"\\n\" if you want a newline to be printed.\n\
2007 Since leading and trailing whitespace are ignored in command arguments,\n\
2008 if you want to print some you must use \"\\\" before leading whitespace\n\
2009 to be printed or after trailing whitespace.");
2010 add_com ("document", class_support
, document_command
,
2011 "Document a user-defined command.\n\
2012 Give command name as argument. Give documentation on following lines.\n\
2013 End with a line of just \"end\".");
2014 add_com ("define", class_support
, define_command
,
2015 "Define a new command name. Command name is argument.\n\
2016 Definition appears on following lines, one command per line.\n\
2017 End with a line of just \"end\".\n\
2018 Use the \"document\" command to give documentation for the new command.\n\
2019 Commands defined in this way do not take arguments.");
2022 add_com ("source", class_support
, source_command
,
2023 "Read commands from a file named FILE.\n\
2024 Note that the file \"" GDBINIT_FILENAME
"\" is read automatically in this way\n\
2025 when gdb is started.");
2027 /* Punt file name, we can't help it easily. */
2028 add_com ("source", class_support
, source_command
,
2029 "Read commands from a file named FILE.\n\
2030 Note that the file \".gdbinit\" is read automatically in this way\n\
2031 when gdb is started.");
2034 add_com ("quit", class_support
, quit_command
, "Exit gdb.");
2035 add_com ("help", class_support
, help_command
, "Print list of commands.");
2036 add_com_alias ("q", "quit", class_support
, 1);
2037 add_com_alias ("h", "help", class_support
, 1);
2040 c
= add_set_cmd ("verbose", class_support
, var_boolean
, (char *)&info_verbose
,
2043 add_show_from_set (c
, &showlist
);
2044 c
->function
= set_verbose
;
2045 set_verbose (NULL
, 0, c
);
2047 add_com ("dump-me", class_obscure
, dump_me_command
,
2048 "Get fatal error; make debugger dump its core.");
2051 (add_set_cmd ("editing", class_support
, var_boolean
, (char *)&command_editing_p
,
2052 "Set command line editing.\n\
2053 Use \"on\" to enable to enable the editing, and \"off\" to disable it.\n\
2054 Without an argument, command line editing is enabled.", &setlist
),
2057 add_prefix_cmd ("history", class_support
, set_history
,
2058 "Generic command for setting command history parameters.",
2059 &sethistlist
, "set history ", 0, &setlist
);
2060 add_prefix_cmd ("history", class_support
, show_history
,
2061 "Generic command for showing command history parameters.",
2062 &showhistlist
, "show history ", 0, &showlist
);
2065 (add_set_cmd ("expansion", no_class
, var_boolean
, (char *)&history_expansion_p
,
2066 "Set history expansion on command input.\n\
2067 Without an argument, history expansion is enabled.", &sethistlist
),
2071 (add_set_cmd ("save", no_class
, var_boolean
, (char *)&write_history_p
,
2072 "Set saving of the history record on exit.\n\
2073 Use \"on\" to enable to enable the saving, and \"off\" to disable it.\n\
2074 Without an argument, saving is enabled.", &sethistlist
),
2077 c
= add_set_cmd ("size", no_class
, var_uinteger
, (char *)&history_size
,
2078 "Set the size of the command history, \n\
2079 ie. the number of previous commands to keep a record of.", &sethistlist
);
2080 add_show_from_set (c
, &showhistlist
);
2081 c
->function
= set_history_size_command
;
2084 (add_set_cmd ("filename", no_class
, var_filename
, (char *)&history_filename
,
2085 "Set the filename in which to record the command history\n\
2086 (the list of previous commands of which a record is kept).", &sethistlist
),
2090 (add_set_cmd ("confirm", class_support
, var_boolean
,
2092 "Set whether to confirm potentially dangerous operations.",
2096 add_prefix_cmd ("info", class_info
, info_command
,
2097 "Generic command for printing status.",
2098 &infolist
, "info ", 0, &cmdlist
);
2099 add_com_alias ("i", "info", class_info
, 1);
2101 add_prefix_cmd ("show", class_info
, show_command
,
2102 "Generic command for showing things set with \"set\".",
2103 &showlist
, "show ", 0, &cmdlist
);
2104 /* Another way to get at the same thing. */
2105 add_info ("set", show_command
, "Show all GDB settings.");
2107 add_cmd ("commands", no_class
, show_commands
, "Status of command editor.",
2110 add_cmd ("version", no_class
, show_version
,
2111 "Report what version of GDB this is.", &showlist
);