Rearrange --help output.
[deliverable/binutils-gdb.git] / gdb / top.c
CommitLineData
c906108c 1/* Top level stuff for GDB, the GNU debugger.
a752853e 2
8acc9f48 3 Copyright (C) 1986-2013 Free Software Foundation, Inc.
c906108c 4
c5aa993b 5 This file is part of GDB.
c906108c 6
c5aa993b
JM
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
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
c5aa993b 10 (at your option) any later version.
c906108c 11
c5aa993b
JM
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.
c906108c 16
c5aa993b 17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
19
20#include "defs.h"
21#include "gdbcmd.h"
210661e7
EZ
22#include "cli/cli-cmds.h"
23#include "cli/cli-script.h"
24#include "cli/cli-setshow.h"
18a642a1 25#include "cli/cli-decode.h"
c906108c
SS
26#include "symtab.h"
27#include "inferior.h"
60250e8b 28#include "exceptions.h"
042be3a9 29#include <signal.h>
c906108c
SS
30#include "target.h"
31#include "breakpoint.h"
32#include "gdbtypes.h"
33#include "expression.h"
34#include "value.h"
35#include "language.h"
c5aa993b 36#include "terminal.h" /* For job_control. */
c906108c 37#include "annotate.h"
c5f0f3d0 38#include "completer.h"
c906108c 39#include "top.h"
d4f3574e 40#include "version.h"
210661e7 41#include "serial.h"
d16aafd8 42#include "doublest.h"
f9c696d2 43#include "gdb_assert.h"
f17517ea 44#include "main.h"
2e03ee74 45#include "event-loop.h"
8ea051c5 46#include "gdbthread.h"
9dea9163 47#include "python/python.h"
b4a14fd0 48#include "interps.h"
6dea1fbd 49#include "observer.h"
bd712aed 50#include "maint.h"
c906108c 51
371d5dec 52/* readline include files. */
dbda9972
AC
53#include "readline/readline.h"
54#include "readline/history.h"
c906108c
SS
55
56/* readline defines this. */
57#undef savestring
58
59#include <sys/types.h>
c906108c 60
c2c6d25f 61#include "event-top.h"
c906108c
SS
62#include "gdb_string.h"
63#include "gdb_stat.h"
64#include <ctype.h>
8b93c638
JM
65#include "ui-out.h"
66#include "cli-out.h"
2f9d54cf 67#include "tracepoint.h"
c906108c 68
ca7b0bbc
TT
69extern void initialize_all_files (void);
70
95298e72
PM
71#define PROMPT(X) the_prompts.prompt_stack[the_prompts.top + X].prompt
72#define PREFIX(X) the_prompts.prompt_stack[the_prompts.top + X].prefix
73#define SUFFIX(X) the_prompts.prompt_stack[the_prompts.top + X].suffix
74
371d5dec 75/* Default command line prompt. This is overriden in some configs. */
104c1213
JM
76
77#ifndef DEFAULT_PROMPT
78#define DEFAULT_PROMPT "(gdb) "
c906108c
SS
79#endif
80
e655c1a2 81/* Initialization file name for gdb. This is host-dependent. */
eaae3919 82
e655c1a2 83const char gdbinit[] = GDBINIT;
c906108c
SS
84
85int inhibit_gdbinit = 0;
86
87/* If nonzero, and GDB has been configured to be able to use windows,
88 attempt to open them upon startup. */
89
f15ab4a7 90int use_windows = 0;
c906108c 91
c906108c
SS
92extern char lang_frame_mismatch_warn[]; /* language.c */
93
050a2e1d
PA
94/* Flag for whether we want to confirm potentially dangerous
95 operations. Default is yes. */
96
e360902b 97int confirm = 1;
c906108c 98
920d2a44 99static void
e360902b 100show_confirm (struct ui_file *file, int from_tty,
920d2a44
AC
101 struct cmd_list_element *c, const char *value)
102{
3e43a32a
MS
103 fprintf_filtered (file, _("Whether to confirm potentially "
104 "dangerous operations is %s.\n"),
920d2a44
AC
105 value);
106}
c906108c 107
371d5dec
MS
108/* stdio stream that command input is being read from. Set to stdin
109 normally. Set by source_command to the file we are sourcing. Set
110 to NULL if we are executing a user-defined command or interacting
111 via a GUI. */
c906108c
SS
112
113FILE *instream;
114
698ba934
DJ
115/* Flag to indicate whether a user defined command is currently running. */
116
117int in_user_command;
118
c906108c
SS
119/* Current working directory. */
120
121char *current_directory;
122
123/* The directory name is actually stored here (usually). */
124char gdb_dirbuf[1024];
125
126/* Function to call before reading a command, if nonzero.
127 The function receives two args: an input stream,
128 and a prompt string. */
129
507f3c78 130void (*window_hook) (FILE *, char *);
c906108c 131
c906108c
SS
132/* Buffer used for reading command lines, and the size
133 allocated for it so far. */
134
dc7eb48e
PA
135char *saved_command_line;
136int saved_command_line_size = 100;
c906108c
SS
137
138/* Nonzero if the current command is modified by "server ". This
c2d11a7d 139 affects things like recording into the command history, commands
c906108c
SS
140 repeating on RETURN, etc. This is so a user interface (emacs, GUI,
141 whatever) can issue its own commands and also send along commands
142 from the user, and have the user not notice that the user interface
143 is issuing commands too. */
144int server_command;
145
146/* Baud rate specified for talking to serial target systems. Default
147 is left as -1, so targets can choose their own defaults. */
371d5dec
MS
148/* FIXME: This means that "show remotebaud" and gr_files_info can
149 print -1 or (unsigned int)-1. This is a Bad User Interface. */
c906108c
SS
150
151int baud_rate = -1;
152
371d5dec 153/* Timeout limit for response from target. */
c906108c 154
ce808e91
AC
155/* The default value has been changed many times over the years. It
156 was originally 5 seconds. But that was thought to be a long time
157 to sit and wait, so it was changed to 2 seconds. That was thought
158 to be plenty unless the connection was going through some terminal
159 server or multiplexer or other form of hairy serial connection.
160
161 In mid-1996, remote_timeout was moved from remote.c to top.c and
162 it began being used in other remote-* targets. It appears that the
163 default was changed to 20 seconds at that time, perhaps because the
85a453d5 164 Renesas E7000 ICE didn't always respond in a timely manner.
ce808e91
AC
165
166 But if 5 seconds is a long time to sit and wait for retransmissions,
167 20 seconds is far worse. This demonstrates the difficulty of using
168 a single variable for all protocol timeouts.
169
170 As remote.c is used much more than remote-e7000.c, it was changed
371d5dec 171 back to 2 seconds in 1999. */
ce808e91
AC
172
173int remote_timeout = 2;
c906108c
SS
174
175/* Non-zero tells remote* modules to output debugging info. */
176
177int remote_debug = 0;
178
6dd77b81
RH
179/* Sbrk location on entry to main. Used for statistics only. */
180#ifdef HAVE_SBRK
181char *lim_at_start;
182#endif
183
c906108c
SS
184/* Hooks for alternate command interfaces. */
185
371d5dec
MS
186/* Called after most modules have been initialized, but before taking
187 users command file.
1ad24239 188
371d5dec
MS
189 If the UI fails to initialize and it wants GDB to continue using
190 the default UI, then it should clear this hook before returning. */
c906108c 191
9a4105ab 192void (*deprecated_init_ui_hook) (char *argv0);
7a292a7a 193
371d5dec
MS
194/* This hook is called from within gdb's many mini-event loops which
195 could steal control from a real user interface's event loop. It
196 returns non-zero if the user is requesting a detach, zero
197 otherwise. */
7a292a7a 198
98bbd631 199int (*deprecated_ui_loop_hook) (int);
c906108c
SS
200
201/* Called instead of command_loop at top level. Can be invoked via
b5a2688f 202 throw_exception(). */
c906108c 203
9a4105ab 204void (*deprecated_command_loop_hook) (void);
c906108c
SS
205
206
c906108c
SS
207/* Called from print_frame_info to list the line we stopped in. */
208
371d5dec
MS
209void (*deprecated_print_frame_info_listing_hook) (struct symtab * s,
210 int line,
211 int stopline,
212 int noerror);
c906108c
SS
213/* Replaces most of query. */
214
9a4105ab 215int (*deprecated_query_hook) (const char *, va_list);
c906108c
SS
216
217/* Replaces most of warning. */
218
9a4105ab 219void (*deprecated_warning_hook) (const char *, va_list);
c906108c 220
9a4105ab
AC
221/* These three functions support getting lines of text from the user.
222 They are used in sequence. First deprecated_readline_begin_hook is
223 called with a text string that might be (for example) a message for
224 the user to type in a sequence of commands to be executed at a
225 breakpoint. If this function calls back to a GUI, it might take
226 this opportunity to pop up a text interaction window with this
227 message. Next, deprecated_readline_hook is called with a prompt
228 that is emitted prior to collecting the user input. It can be
229 called multiple times. Finally, deprecated_readline_end_hook is
230 called to notify the GUI that we are done with the interaction
231 window and it can close it. */
c906108c 232
9a4105ab
AC
233void (*deprecated_readline_begin_hook) (char *, ...);
234char *(*deprecated_readline_hook) (char *);
235void (*deprecated_readline_end_hook) (void);
c906108c 236
6426a772 237/* Called as appropriate to notify the interface that we have attached
371d5dec 238 to or detached from an already running process. */
6426a772 239
9a4105ab
AC
240void (*deprecated_attach_hook) (void);
241void (*deprecated_detach_hook) (void);
6426a772 242
371d5dec
MS
243/* Called during long calculations to allow GUI to repair window
244 damage, and to check for stop buttons, etc... */
c906108c 245
9a4105ab 246void (*deprecated_interactive_hook) (void);
c906108c 247
c378eb4e 248/* Tell the GUI someone changed the register REGNO. -1 means
c906108c 249 that the caller does not know which register changed or
371d5dec 250 that several registers have changed (see value_assign). */
9a4105ab 251void (*deprecated_register_changed_hook) (int regno);
c906108c 252
371d5dec
MS
253/* Called when going to wait for the target. Usually allows the GUI
254 to run while waiting for target events. */
c906108c 255
9a4105ab 256ptid_t (*deprecated_target_wait_hook) (ptid_t ptid,
47608cb1
PA
257 struct target_waitstatus *status,
258 int options);
c906108c 259
371d5dec
MS
260/* Used by UI as a wrapper around command execution. May do various
261 things like enabling/disabling buttons, etc... */
c906108c 262
371d5dec
MS
263void (*deprecated_call_command_hook) (struct cmd_list_element * c,
264 char *cmd, int from_tty);
c906108c 265
96baa820
JM
266/* Called after a `set' command has finished. Is only run if the
267 `set' command succeeded. */
268
9a4105ab 269void (*deprecated_set_hook) (struct cmd_list_element * c);
96baa820 270
c906108c
SS
271/* Called when the current thread changes. Argument is thread id. */
272
9a4105ab 273void (*deprecated_context_hook) (int id);
c906108c 274
c906108c
SS
275/* Handler for SIGHUP. */
276
277#ifdef SIGHUP
392a587b 278/* NOTE 1999-04-29: This function will be static again, once we modify
cd0fc7c3 279 gdb to use the event loop as the default command loop and we merge
c378eb4e 280 event-top.c into this file, top.c. */
b2cd6b29
JM
281/* static */ void
282quit_cover (void)
c906108c 283{
e360902b
PA
284 /* Stop asking user for confirmation --- we're exiting. This
285 prevents asking the user dumb questions. */
286 confirm = 0;
c5aa993b 287 quit_command ((char *) 0, 0);
c906108c
SS
288}
289#endif /* defined SIGHUP */
290\f
7a9dd1b2 291/* Line number we are currently in, in a file which is being sourced. */
392a587b 292/* NOTE 1999-04-29: This variable will be static again, once we modify
cd0fc7c3 293 gdb to use the event loop as the default command loop and we merge
c378eb4e 294 event-top.c into this file, top.c. */
cd0fc7c3 295/* static */ int source_line_number;
c906108c
SS
296
297/* Name of the file we are sourcing. */
392a587b 298/* NOTE 1999-04-29: This variable will be static again, once we modify
cd0fc7c3 299 gdb to use the event loop as the default command loop and we merge
c378eb4e 300 event-top.c into this file, top.c. */
05159abe 301/* static */ const char *source_file_name;
c906108c 302
c906108c
SS
303/* Clean up on error during a "source" command (or execution of a
304 user-defined command). */
305
d318976c 306void
e41a3b1a 307do_restore_instream_cleanup (void *stream)
c906108c
SS
308{
309 /* Restore the previous input stream. */
310 instream = stream;
311}
312
313/* Read commands from STREAM. */
314void
fba45db2 315read_command_file (FILE *stream)
c906108c
SS
316{
317 struct cleanup *cleanups;
318
e41a3b1a 319 cleanups = make_cleanup (do_restore_instream_cleanup, instream);
c906108c 320 instream = stream;
c5aa993b 321 command_loop ();
c906108c
SS
322 do_cleanups (cleanups);
323}
324\f
507f3c78 325void (*pre_init_ui_hook) (void);
c906108c 326
e41a3b1a 327#ifdef __MSDOS__
70976b65 328static void
e41a3b1a
AC
329do_chdir_cleanup (void *old_dir)
330{
331 chdir (old_dir);
b8c9b27d 332 xfree (old_dir);
e41a3b1a
AC
333}
334#endif
335
028d0ed5 336struct cleanup *
4e5d721f
DE
337prepare_execute_command (void)
338{
028d0ed5
TJB
339 struct value *mark;
340 struct cleanup *cleanup;
341
342 mark = value_mark ();
343 cleanup = make_cleanup_value_free_to_mark (mark);
4e5d721f 344
371d5dec
MS
345 /* With multiple threads running while the one we're examining is
346 stopped, the dcache can get stale without us being able to detect
347 it. For the duration of the command, though, use the dcache to
348 help things like backtrace. */
4e5d721f
DE
349 if (non_stop)
350 target_dcache_invalidate ();
028d0ed5
TJB
351
352 return cleanup;
4e5d721f
DE
353}
354
77cce10f
PA
355/* Tell the user if the language has changed (except first time) after
356 executing a command. */
357
358void
359check_frame_language_change (void)
360{
361 static int warned = 0;
362
363 /* First make sure that a new frame has been selected, in case the
364 command or the hooks changed the program state. */
365 deprecated_safe_get_selected_frame ();
366 if (current_language != expected_language)
367 {
368 if (language_mode == language_mode_auto && info_verbose)
369 {
370 language_info (1); /* Print what changed. */
371 }
372 warned = 0;
373 }
374
375 /* Warn the user if the working language does not match the language
376 of the current frame. Only warn the user if we are actually
377 running the program, i.e. there is a stack. */
378 /* FIXME: This should be cacheing the frame and only running when
379 the frame changes. */
380
381 if (has_stack_frames ())
382 {
383 enum language flang;
384
385 flang = get_frame_language ();
386 if (!warned
387 && flang != language_unknown
388 && flang != current_language->la_language)
389 {
390 printf_filtered ("%s\n", lang_frame_mismatch_warn);
391 warned = 1;
392 }
393 }
394}
395
648bf667 396/* Execute the line P as a command, in the current user context.
d318976c 397 Pass FROM_TTY as second argument to the defining function. */
c906108c 398
d318976c
FN
399void
400execute_command (char *p, int from_tty)
c906108c 401{
353d1d73 402 struct cleanup *cleanup_if_error, *cleanup;
52f0bd74 403 struct cmd_list_element *c;
d318976c 404 char *line;
4e5d721f 405
353d1d73 406 cleanup_if_error = make_bpstat_clear_actions_cleanup ();
028d0ed5 407 cleanup = prepare_execute_command ();
c906108c 408
d318976c
FN
409 /* Force cleanup of any alloca areas if using C alloca instead of
410 a builtin alloca. */
411 alloca (0);
c906108c 412
d318976c
FN
413 /* This can happen when command_line_input hits end of file. */
414 if (p == NULL)
5fe41fbf
TT
415 {
416 do_cleanups (cleanup);
5ae85e44 417 discard_cleanups (cleanup_if_error);
5fe41fbf
TT
418 return;
419 }
c906108c 420
49d03eab 421 target_log_command (p);
8b93c638 422
d318976c
FN
423 while (*p == ' ' || *p == '\t')
424 p++;
425 if (*p)
8b93c638 426 {
6f937416 427 const char *cmd = p;
d318976c
FN
428 char *arg;
429 line = p;
8b93c638 430
16026cd7
AS
431 /* If trace-commands is set then this will print this command. */
432 print_command_trace (p);
433
6f937416
PA
434 c = lookup_cmd (&cmd, cmdlist, "", 0, 1);
435 p = (char *) cmd;
8b93c638 436
d318976c
FN
437 /* Pass null arg rather than an empty one. */
438 arg = *p ? p : 0;
8b93c638 439
9f60d481
AC
440 /* FIXME: cagney/2002-02-02: The c->type test is pretty dodgy
441 while the is_complete_command(cfunc) test is just plain
442 bogus. They should both be replaced by a test of the form
443 c->strip_trailing_white_space_p. */
444 /* NOTE: cagney/2002-02-02: The function.cfunc in the below
445 can't be replaced with func. This is because it is the
446 cfunc, and not the func, that has the value that the
447 is_complete_command hack is testing for. */
448 /* Clear off trailing whitespace, except for set and complete
449 command. */
d318976c
FN
450 if (arg
451 && c->type != set_cmd
bbaca940 452 && !is_complete_command (c))
8b93c638 453 {
d318976c
FN
454 p = arg + strlen (arg) - 1;
455 while (p >= arg && (*p == ' ' || *p == '\t'))
456 p--;
457 *(p + 1) = '\0';
8b93c638
JM
458 }
459
371d5dec 460 /* If this command has been pre-hooked, run the hook first. */
5913bcb0 461 execute_cmd_pre_hook (c);
c906108c 462
d318976c 463 if (c->flags & DEPRECATED_WARN_USER)
6f937416 464 deprecated_cmd_warning (line);
c906108c 465
7d74f244
DE
466 /* c->user_commands would be NULL in the case of a python command. */
467 if (c->class == class_user && c->user_commands)
d318976c 468 execute_user_command (c, arg);
5b9afe8a
YQ
469 else if (c->type == set_cmd)
470 do_set_command (arg, from_tty, c);
471 else if (c->type == show_cmd)
472 do_show_command (arg, from_tty, c);
f436dd25 473 else if (!cmd_func_p (c))
8a3fe4f8 474 error (_("That is not a command, just a help topic."));
9a4105ab 475 else if (deprecated_call_command_hook)
050a2e1d 476 deprecated_call_command_hook (c, arg, from_tty);
d318976c 477 else
050a2e1d 478 cmd_func (c, arg, from_tty);
b4a14fd0
PA
479
480 /* If the interpreter is in sync mode (we're running a user
481 command's list, running command hooks or similars), and we
482 just ran a synchronous command that started the target, wait
483 for that command to end. */
0f641c01 484 if (!interpreter_async && sync_execution)
b4a14fd0
PA
485 {
486 while (gdb_do_one_event () >= 0)
487 if (!sync_execution)
488 break;
489 }
490
371d5dec 491 /* If this command has been post-hooked, run the hook last. */
5913bcb0 492 execute_cmd_post_hook (c);
c906108c 493
c906108c
SS
494 }
495
77cce10f 496 check_frame_language_change ();
028d0ed5 497
353d1d73
JK
498 do_cleanups (cleanup);
499 discard_cleanups (cleanup_if_error);
c906108c
SS
500}
501
5da1313b
JK
502/* Run execute_command for P and FROM_TTY. Capture its output into the
503 returned string, do not display it to the screen. BATCH_FLAG will be
504 temporarily set to true. */
505
506char *
507execute_command_to_string (char *p, int from_tty)
508{
509 struct ui_file *str_file;
510 struct cleanup *cleanup;
511 char *retval;
512
513 /* GDB_STDOUT should be better already restored during these
514 restoration callbacks. */
515 cleanup = set_batch_flag_and_make_cleanup_restore_page_info ();
516
b4a14fd0
PA
517 make_cleanup_restore_integer (&interpreter_async);
518 interpreter_async = 0;
519
5da1313b
JK
520 str_file = mem_fileopen ();
521
8d4d924b 522 make_cleanup_ui_file_delete (str_file);
5da1313b
JK
523 make_cleanup_restore_ui_file (&gdb_stdout);
524 make_cleanup_restore_ui_file (&gdb_stderr);
8d4d924b
JK
525 make_cleanup_restore_ui_file (&gdb_stdlog);
526 make_cleanup_restore_ui_file (&gdb_stdtarg);
527 make_cleanup_restore_ui_file (&gdb_stdtargerr);
528
79a45e25 529 if (ui_out_redirect (current_uiout, str_file) < 0)
8d4d924b
JK
530 warning (_("Current output protocol does not support redirection"));
531 else
79a45e25 532 make_cleanup_ui_out_redirect_pop (current_uiout);
5da1313b
JK
533
534 gdb_stdout = str_file;
535 gdb_stderr = str_file;
8d4d924b
JK
536 gdb_stdlog = str_file;
537 gdb_stdtarg = str_file;
538 gdb_stdtargerr = str_file;
5da1313b
JK
539
540 execute_command (p, from_tty);
541
542 retval = ui_file_xstrdup (str_file, NULL);
543
544 do_cleanups (cleanup);
545
546 return retval;
547}
548
d318976c
FN
549/* Read commands from `instream' and execute them
550 until end of file or error reading instream. */
c906108c 551
d318976c
FN
552void
553command_loop (void)
c906108c 554{
d318976c
FN
555 struct cleanup *old_chain;
556 char *command;
557 int stdin_is_tty = ISATTY (stdin);
c5aa993b 558
d318976c
FN
559 while (instream && !feof (instream))
560 {
d318976c 561 if (window_hook && instream == stdin)
ab821bc6 562 (*window_hook) (instream, get_prompt ());
c906108c 563
522002f9 564 clear_quit_flag ();
d318976c
FN
565 if (instream == stdin && stdin_is_tty)
566 reinitialize_more_filter ();
567 old_chain = make_cleanup (null_cleanup, 0);
c906108c 568
c378eb4e 569 /* Get a command-line. This calls the readline package. */
d318976c 570 command = command_line_input (instream == stdin ?
ab821bc6 571 get_prompt () : (char *) NULL,
d318976c 572 instream == stdin, "prompt");
d318976c 573 if (command == 0)
5fe41fbf
TT
574 {
575 do_cleanups (old_chain);
576 return;
577 }
c906108c 578
0f3bb72e 579 make_command_stats_cleanup (1);
9e0b60a8 580
d318976c 581 execute_command (command, instream == stdin);
347bddb7
PA
582
583 /* Do any commands attached to breakpoint we are stopped at. */
584 bpstat_do_actions ();
585
d318976c 586 do_cleanups (old_chain);
9e0b60a8 587 }
9e0b60a8 588}
d318976c 589\f
47a80e90
TT
590/* When nonzero, cause dont_repeat to do nothing. This should only be
591 set via prevent_dont_repeat. */
592
593static int suppress_dont_repeat = 0;
594
d318976c 595/* Commands call this if they do not want to be repeated by null lines. */
9e0b60a8 596
d318976c
FN
597void
598dont_repeat (void)
9e0b60a8 599{
47a80e90 600 if (suppress_dont_repeat || server_command)
d318976c 601 return;
9e0b60a8 602
d318976c 603 /* If we aren't reading from standard input, we are saving the last
371d5dec
MS
604 thing read from stdin in line and don't want to delete it. Null
605 lines won't repeat here in any case. */
d318976c 606 if (instream == stdin)
dc7eb48e 607 *saved_command_line = 0;
9e0b60a8 608}
47a80e90
TT
609
610/* Prevent dont_repeat from working, and return a cleanup that
611 restores the previous state. */
612
613struct cleanup *
614prevent_dont_repeat (void)
615{
616 struct cleanup *result = make_cleanup_restore_integer (&suppress_dont_repeat);
617
618 suppress_dont_repeat = 1;
619 return result;
620}
621
d318976c
FN
622\f
623/* Read a line from the stream "instream" without command line editing.
9e0b60a8 624
d318976c
FN
625 It prints PROMPT_ARG once at the start.
626 Action is compatible with "readline", e.g. space for the result is
627 malloc'd and should be freed by the caller.
9e0b60a8 628
d318976c
FN
629 A NULL return means end of file. */
630char *
631gdb_readline (char *prompt_arg)
9e0b60a8 632{
d318976c
FN
633 int c;
634 char *result;
635 int input_index = 0;
636 int result_size = 80;
9e0b60a8 637
d318976c 638 if (prompt_arg)
9e0b60a8 639 {
d318976c
FN
640 /* Don't use a _filtered function here. It causes the assumed
641 character position to be off, since the newline we read from
642 the user is not accounted for. */
643 fputs_unfiltered (prompt_arg, gdb_stdout);
9e0b60a8
JM
644 gdb_flush (gdb_stdout);
645 }
646
d318976c 647 result = (char *) xmalloc (result_size);
9e0b60a8
JM
648
649 while (1)
650 {
d318976c
FN
651 /* Read from stdin if we are executing a user defined command.
652 This is the right thing for prompt_for_continue, at least. */
653 c = fgetc (instream ? instream : stdin);
9e0b60a8 654
d318976c 655 if (c == EOF)
9e0b60a8 656 {
d318976c
FN
657 if (input_index > 0)
658 /* The last line does not end with a newline. Return it, and
659 if we are called again fgetc will still return EOF and
660 we'll return NULL then. */
9e0b60a8 661 break;
b8c9b27d 662 xfree (result);
d318976c 663 return NULL;
9e0b60a8 664 }
c5aa993b 665
d318976c 666 if (c == '\n')
9e0b60a8 667 {
d318976c
FN
668 if (input_index > 0 && result[input_index - 1] == '\r')
669 input_index--;
670 break;
9e0b60a8 671 }
9e0b60a8 672
d318976c
FN
673 result[input_index++] = c;
674 while (input_index >= result_size)
9e0b60a8 675 {
d318976c
FN
676 result_size *= 2;
677 result = (char *) xrealloc (result, result_size);
9e0b60a8 678 }
9e0b60a8
JM
679 }
680
d318976c
FN
681 result[input_index++] = '\0';
682 return result;
9e0b60a8
JM
683}
684
d318976c
FN
685/* Variables which control command line editing and history
686 substitution. These variables are given default values at the end
687 of this file. */
688static int command_editing_p;
920d2a44 689
d318976c
FN
690/* NOTE 1999-04-29: This variable will be static again, once we modify
691 gdb to use the event loop as the default command loop and we merge
c378eb4e 692 event-top.c into this file, top.c. */
920d2a44 693
d318976c 694/* static */ int history_expansion_p;
920d2a44 695
d318976c 696static int write_history_p;
920d2a44
AC
697static void
698show_write_history_p (struct ui_file *file, int from_tty,
699 struct cmd_list_element *c, const char *value)
700{
701 fprintf_filtered (file, _("Saving of the history record on exit is %s.\n"),
702 value);
703}
704
840a9a1f
PA
705/* The variable associated with the "set/show history size"
706 command. */
707static unsigned int history_size_setshow_var;
708
920d2a44
AC
709static void
710show_history_size (struct ui_file *file, int from_tty,
711 struct cmd_list_element *c, const char *value)
712{
713 fprintf_filtered (file, _("The size of the command history is %s.\n"),
714 value);
715}
716
d318976c 717static char *history_filename;
920d2a44
AC
718static void
719show_history_filename (struct ui_file *file, int from_tty,
720 struct cmd_list_element *c, const char *value)
721{
3e43a32a
MS
722 fprintf_filtered (file, _("The filename in which to record "
723 "the command history is \"%s\".\n"),
920d2a44
AC
724 value);
725}
9e0b60a8 726
b4f5539f 727/* This is like readline(), but it has some gdb-specific behavior.
2e03ee74 728 gdb may want readline in both the synchronous and async modes during
b4f5539f
TT
729 a single gdb invocation. At the ordinary top-level prompt we might
730 be using the async readline. That means we can't use
731 rl_pre_input_hook, since it doesn't work properly in async mode.
732 However, for a secondary prompt (" >", such as occurs during a
2e03ee74
DJ
733 `define'), gdb wants a synchronous response.
734
735 We used to call readline() directly, running it in synchronous
736 mode. But mixing modes this way is not supported, and as of
737 readline 5.x it no longer works; the arrow keys come unbound during
738 the synchronous call. So we make a nested call into the event
739 loop. That's what gdb_readline_wrapper is for. */
740
741/* A flag set as soon as gdb_readline_wrapper_line is called; we can't
742 rely on gdb_readline_wrapper_result, which might still be NULL if
743 the user types Control-D for EOF. */
744static int gdb_readline_wrapper_done;
745
746/* The result of the current call to gdb_readline_wrapper, once a newline
747 is seen. */
748static char *gdb_readline_wrapper_result;
749
750/* Any intercepted hook. Operate-and-get-next sets this, expecting it
751 to be called after the newline is processed (which will redisplay
752 the prompt). But in gdb_readline_wrapper we will not get a new
753 prompt until the next call, or until we return to the event loop.
754 So we disable this hook around the newline and restore it before we
755 return. */
756static void (*saved_after_char_processing_hook) (void);
757
758/* This function is called when readline has seen a complete line of
759 text. */
760
761static void
762gdb_readline_wrapper_line (char *line)
763{
764 gdb_assert (!gdb_readline_wrapper_done);
765 gdb_readline_wrapper_result = line;
766 gdb_readline_wrapper_done = 1;
767
768 /* Prevent operate-and-get-next from acting too early. */
769 saved_after_char_processing_hook = after_char_processing_hook;
770 after_char_processing_hook = NULL;
1b05479a
DJ
771
772 /* Prevent parts of the prompt from being redisplayed if annotations
773 are enabled, and readline's state getting out of sync. */
774 if (async_command_editing_p)
775 rl_callback_handler_remove ();
2e03ee74
DJ
776}
777
778struct gdb_readline_wrapper_cleanup
779 {
780 void (*handler_orig) (char *);
2e03ee74
DJ
781 int already_prompted_orig;
782 };
783
784static void
785gdb_readline_wrapper_cleanup (void *arg)
786{
787 struct gdb_readline_wrapper_cleanup *cleanup = arg;
788
2e03ee74 789 rl_already_prompted = cleanup->already_prompted_orig;
2e03ee74
DJ
790
791 gdb_assert (input_handler == gdb_readline_wrapper_line);
792 input_handler = cleanup->handler_orig;
793 gdb_readline_wrapper_result = NULL;
794 gdb_readline_wrapper_done = 0;
795
796 after_char_processing_hook = saved_after_char_processing_hook;
797 saved_after_char_processing_hook = NULL;
798
799 xfree (cleanup);
800}
801
b4f5539f
TT
802char *
803gdb_readline_wrapper (char *prompt)
804{
2e03ee74
DJ
805 struct cleanup *back_to;
806 struct gdb_readline_wrapper_cleanup *cleanup;
807 char *retval;
808
809 cleanup = xmalloc (sizeof (*cleanup));
810 cleanup->handler_orig = input_handler;
811 input_handler = gdb_readline_wrapper_line;
812
2e03ee74
DJ
813 cleanup->already_prompted_orig = rl_already_prompted;
814
815 back_to = make_cleanup (gdb_readline_wrapper_cleanup, cleanup);
816
817 /* Display our prompt and prevent double prompt display. */
1b05479a 818 display_gdb_prompt (prompt);
2e03ee74
DJ
819 rl_already_prompted = 1;
820
362646f5 821 if (after_char_processing_hook)
2e03ee74
DJ
822 (*after_char_processing_hook) ();
823 gdb_assert (after_char_processing_hook == NULL);
824
e0dd0826 825 while (gdb_do_one_event () >= 0)
2e03ee74
DJ
826 if (gdb_readline_wrapper_done)
827 break;
b4f5539f 828
2e03ee74
DJ
829 retval = gdb_readline_wrapper_result;
830 do_cleanups (back_to);
831 return retval;
b4f5539f
TT
832}
833
9e0b60a8 834\f
467d8519
TT
835/* The current saved history number from operate-and-get-next.
836 This is -1 if not valid. */
837static int operate_saved_history = -1;
838
839/* This is put on the appropriate hook and helps operate-and-get-next
840 do its work. */
b9362cc7 841static void
5ae5f592 842gdb_rl_operate_and_get_next_completion (void)
467d8519
TT
843{
844 int delta = where_history () - operate_saved_history;
5d502164 845
467d8519
TT
846 /* The `key' argument to rl_get_previous_history is ignored. */
847 rl_get_previous_history (delta, 0);
848 operate_saved_history = -1;
849
850 /* readline doesn't automatically update the display for us. */
12f4afab 851 rl_redisplay ();
467d8519
TT
852
853 after_char_processing_hook = NULL;
854 rl_pre_input_hook = NULL;
855}
856
857/* This is a gdb-local readline command handler. It accepts the
858 current command line (like RET does) and, if this command was taken
859 from the history, arranges for the next command in the history to
860 appear on the command line when the prompt returns.
861 We ignore the arguments. */
862static int
863gdb_rl_operate_and_get_next (int count, int key)
864{
b5686e99
MK
865 int where;
866
362646f5
AC
867 /* Use the async hook. */
868 after_char_processing_hook = gdb_rl_operate_and_get_next_completion;
467d8519 869
b5686e99
MK
870 /* Find the current line, and find the next line to use. */
871 where = where_history();
872
1fb2e2b5
PA
873 if ((history_is_stifled () && (history_length >= history_max_entries))
874 || (where >= history_length - 1))
b5686e99
MK
875 operate_saved_history = where;
876 else
877 operate_saved_history = where + 1;
878
467d8519
TT
879 return rl_newline (1, key);
880}
881\f
d318976c
FN
882/* Read one line from the command input stream `instream'
883 into the local static buffer `linebuffer' (whose current length
884 is `linelength').
885 The buffer is made bigger as necessary.
886 Returns the address of the start of the line.
9e0b60a8 887
d318976c 888 NULL is returned for end of file.
9e0b60a8 889
d318976c
FN
890 *If* the instream == stdin & stdin is a terminal, the line read
891 is copied into the file line saver (global var char *line,
892 length linesize) so that it can be duplicated.
9e0b60a8 893
d318976c
FN
894 This routine either uses fancy command line editing or
895 simple input as the user has requested. */
10689f25 896
d318976c
FN
897char *
898command_line_input (char *prompt_arg, int repeat, char *annotation_suffix)
9e0b60a8 899{
d318976c
FN
900 static char *linebuffer = 0;
901 static unsigned linelength = 0;
52f0bd74 902 char *p;
d318976c
FN
903 char *p1;
904 char *rl;
905 char *local_prompt = prompt_arg;
906 char *nline;
907 char got_eof = 0;
908
909 /* The annotation suffix must be non-NULL. */
910 if (annotation_suffix == NULL)
911 annotation_suffix = "";
9e0b60a8 912
d318976c
FN
913 if (annotation_level > 1 && instream == stdin)
914 {
915 local_prompt = alloca ((prompt_arg == NULL ? 0 : strlen (prompt_arg))
916 + strlen (annotation_suffix) + 40);
917 if (prompt_arg == NULL)
918 local_prompt[0] = '\0';
919 else
920 strcpy (local_prompt, prompt_arg);
921 strcat (local_prompt, "\n\032\032");
922 strcat (local_prompt, annotation_suffix);
923 strcat (local_prompt, "\n");
924 }
9e0b60a8 925
d318976c 926 if (linebuffer == 0)
9e0b60a8 927 {
d318976c
FN
928 linelength = 80;
929 linebuffer = (char *) xmalloc (linelength);
9e0b60a8 930 }
9e0b60a8 931
d318976c 932 p = linebuffer;
9e0b60a8 933
d318976c
FN
934 /* Control-C quits instantly if typed while in this loop
935 since it should not wait until the user types a newline. */
936 immediate_quit++;
522002f9 937 QUIT;
d318976c
FN
938#ifdef STOP_SIGNAL
939 if (job_control)
362646f5 940 signal (STOP_SIGNAL, handle_stop_sig);
d318976c
FN
941#endif
942
943 while (1)
9e0b60a8 944 {
371d5dec
MS
945 /* Make sure that all output has been output. Some machines may
946 let you get away with leaving out some of the gdb_flush, but
947 not all. */
d318976c
FN
948 wrap_here ("");
949 gdb_flush (gdb_stdout);
950 gdb_flush (gdb_stderr);
951
952 if (source_file_name != NULL)
637537d0 953 ++source_line_number;
d318976c
FN
954
955 if (annotation_level > 1 && instream == stdin)
956 {
306d9ac5
DC
957 puts_unfiltered ("\n\032\032pre-");
958 puts_unfiltered (annotation_suffix);
959 puts_unfiltered ("\n");
d318976c
FN
960 }
961
962 /* Don't use fancy stuff if not talking to stdin. */
698ba934 963 if (deprecated_readline_hook && input_from_terminal_p ())
d318976c 964 {
9a4105ab 965 rl = (*deprecated_readline_hook) (local_prompt);
d318976c 966 }
698ba934 967 else if (command_editing_p && input_from_terminal_p ())
d318976c 968 {
b4f5539f 969 rl = gdb_readline_wrapper (local_prompt);
d318976c 970 }
9e0b60a8 971 else
d318976c
FN
972 {
973 rl = gdb_readline (local_prompt);
974 }
9e0b60a8 975
d318976c
FN
976 if (annotation_level > 1 && instream == stdin)
977 {
306d9ac5
DC
978 puts_unfiltered ("\n\032\032post-");
979 puts_unfiltered (annotation_suffix);
980 puts_unfiltered ("\n");
d318976c 981 }
9e0b60a8 982
d318976c 983 if (!rl || rl == (char *) EOF)
9e0b60a8 984 {
d318976c
FN
985 got_eof = 1;
986 break;
9e0b60a8 987 }
d318976c
FN
988 if (strlen (rl) + 1 + (p - linebuffer) > linelength)
989 {
990 linelength = strlen (rl) + 1 + (p - linebuffer);
991 nline = (char *) xrealloc (linebuffer, linelength);
992 p += nline - linebuffer;
993 linebuffer = nline;
994 }
995 p1 = rl;
996 /* Copy line. Don't copy null at end. (Leaves line alone
371d5dec 997 if this was just a newline). */
d318976c
FN
998 while (*p1)
999 *p++ = *p1++;
9e0b60a8 1000
b8c9b27d 1001 xfree (rl); /* Allocated in readline. */
9e0b60a8 1002
d318976c
FN
1003 if (p == linebuffer || *(p - 1) != '\\')
1004 break;
9e0b60a8 1005
d318976c
FN
1006 p--; /* Put on top of '\'. */
1007 local_prompt = (char *) 0;
1008 }
9e0b60a8 1009
d318976c
FN
1010#ifdef STOP_SIGNAL
1011 if (job_control)
1012 signal (STOP_SIGNAL, SIG_DFL);
1013#endif
1014 immediate_quit--;
9e0b60a8 1015
d318976c
FN
1016 if (got_eof)
1017 return NULL;
9e0b60a8 1018
d318976c
FN
1019#define SERVER_COMMAND_LENGTH 7
1020 server_command =
1021 (p - linebuffer > SERVER_COMMAND_LENGTH)
bf896cb0 1022 && strncmp (linebuffer, "server ", SERVER_COMMAND_LENGTH) == 0;
d318976c 1023 if (server_command)
9e0b60a8 1024 {
d318976c
FN
1025 /* Note that we don't set `line'. Between this and the check in
1026 dont_repeat, this insures that repeating will still do the
1027 right thing. */
1028 *p = '\0';
1029 return linebuffer + SERVER_COMMAND_LENGTH;
9e0b60a8 1030 }
9e0b60a8 1031
d318976c
FN
1032 /* Do history expansion if that is wished. */
1033 if (history_expansion_p && instream == stdin
1034 && ISATTY (instream))
1035 {
1036 char *history_value;
1037 int expanded;
9e0b60a8 1038
d318976c
FN
1039 *p = '\0'; /* Insert null now. */
1040 expanded = history_expand (linebuffer, &history_value);
1041 if (expanded)
1042 {
1043 /* Print the changes. */
1044 printf_unfiltered ("%s\n", history_value);
9e0b60a8 1045
d318976c
FN
1046 /* If there was an error, call this function again. */
1047 if (expanded < 0)
1048 {
b8c9b27d 1049 xfree (history_value);
3e43a32a
MS
1050 return command_line_input (prompt_arg, repeat,
1051 annotation_suffix);
d318976c
FN
1052 }
1053 if (strlen (history_value) > linelength)
1054 {
1055 linelength = strlen (history_value) + 1;
1056 linebuffer = (char *) xrealloc (linebuffer, linelength);
1057 }
1058 strcpy (linebuffer, history_value);
1059 p = linebuffer + strlen (linebuffer);
d318976c 1060 }
91d2803c 1061 xfree (history_value);
d318976c 1062 }
9e0b60a8 1063
371d5dec
MS
1064 /* If we just got an empty line, and that is supposed to repeat the
1065 previous command, return the value in the global buffer. */
d318976c 1066 if (repeat && p == linebuffer)
dc7eb48e 1067 return saved_command_line;
d318976c
FN
1068 for (p1 = linebuffer; *p1 == ' ' || *p1 == '\t'; p1++);
1069 if (repeat && !*p1)
dc7eb48e 1070 return saved_command_line;
9e0b60a8 1071
d318976c 1072 *p = 0;
9e0b60a8 1073
d318976c
FN
1074 /* Add line to history if appropriate. */
1075 if (instream == stdin
1076 && ISATTY (stdin) && *linebuffer)
1077 add_history (linebuffer);
9e0b60a8 1078
d318976c
FN
1079 /* Note: lines consisting solely of comments are added to the command
1080 history. This is useful when you type a command, and then
1081 realize you don't want to execute it quite yet. You can comment
1082 out the command and then later fetch it from the value history
1083 and remove the '#'. The kill ring is probably better, but some
1084 people are in the habit of commenting things out. */
1085 if (*p1 == '#')
371d5dec 1086 *p1 = '\0'; /* Found a comment. */
9e0b60a8 1087
d318976c
FN
1088 /* Save into global buffer if appropriate. */
1089 if (repeat)
1090 {
dc7eb48e 1091 if (linelength > saved_command_line_size)
d318976c 1092 {
dc7eb48e
PA
1093 saved_command_line = xrealloc (saved_command_line, linelength);
1094 saved_command_line_size = linelength;
d318976c 1095 }
dc7eb48e
PA
1096 strcpy (saved_command_line, linebuffer);
1097 return saved_command_line;
d318976c 1098 }
9e0b60a8 1099
d318976c 1100 return linebuffer;
9e0b60a8
JM
1101}
1102\f
371d5dec 1103/* Print the GDB banner. */
9e0b60a8 1104void
fba45db2 1105print_gdb_version (struct ui_file *stream)
9e0b60a8
JM
1106{
1107 /* From GNU coding standards, first line is meant to be easy for a
1108 program to parse, and is just canonical program name and version
371d5dec 1109 number, which starts after last space. */
9e0b60a8 1110
c16158bc 1111 fprintf_filtered (stream, "GNU gdb %s%s\n", PKGVERSION, version);
9e0b60a8 1112
371d5dec 1113 /* Second line is a copyright notice. */
9e0b60a8 1114
3e43a32a 1115 fprintf_filtered (stream,
b9786c74 1116 "Copyright (C) 2013 Free Software Foundation, Inc.\n");
9e0b60a8
JM
1117
1118 /* Following the copyright is a brief statement that the program is
1119 free software, that users are free to copy and change it on
1120 certain conditions, that it is covered by the GNU GPL, and that
371d5dec 1121 there is no warranty. */
9e0b60a8
JM
1122
1123 fprintf_filtered (stream, "\
3e43a32a
MS
1124License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\
1125\nThis is free software: you are free to change and redistribute it.\n\
0b93d57c 1126There is NO WARRANTY, to the extent permitted by law. Type \"show copying\"\n\
b8533aec 1127and \"show warranty\" for details.\n");
9e0b60a8 1128
371d5dec 1129 /* After the required info we print the configuration information. */
9e0b60a8
JM
1130
1131 fprintf_filtered (stream, "This GDB was configured as \"");
6314a349 1132 if (strcmp (host_name, target_name) != 0)
9e0b60a8 1133 {
3e43a32a
MS
1134 fprintf_filtered (stream, "--host=%s --target=%s",
1135 host_name, target_name);
9e0b60a8
JM
1136 }
1137 else
1138 {
1139 fprintf_filtered (stream, "%s", host_name);
1140 }
6eaaf48b
EZ
1141 fprintf_filtered (stream, "\".\n\
1142Type \"show configuration\" for configuration details.");
c16158bc
JM
1143
1144 if (REPORT_BUGS_TO[0])
1145 {
6eaaf48b 1146 fprintf_filtered (stream,
c16158bc 1147 _("\nFor bug reporting instructions, please see:\n"));
7949220d 1148 fprintf_filtered (stream, "%s.", REPORT_BUGS_TO);
c16158bc 1149 }
9e0b60a8 1150}
6eaaf48b
EZ
1151
1152/* Print the details of GDB build-time configuration. */
1153void
1154print_gdb_configuration (struct ui_file *stream)
1155{
1156 fprintf_filtered (stream, _("\
1157This GDB was configured as follows:\n\
1158 configure --host=%s --target=%s\n\
1159"), host_name, target_name);
1160 fprintf_filtered (stream, _("\
1161 --with-auto-load-dir=%s\n\
1162 --with-auto-load-safe-path=%s\n\
1163"), AUTO_LOAD_DIR, AUTO_LOAD_SAFE_PATH);
1164#if HAVE_LIBEXPAT
1165 fprintf_filtered (stream, _("\
1166 --with-expat\n\
1167"));
1168#else
1169 fprintf_filtered (stream, _("\
1170 --without-expat\n\
1171"));
1172#endif
1173 if (GDB_DATADIR[0])
1174 fprintf_filtered (stream, _("\
1175 --with-gdb-datadir=%s%s\n\
1176"), GDB_DATADIR, GDB_DATADIR_RELOCATABLE ? " (relocatable)" : "");
1177#ifdef ICONV_BIN
1178 fprintf_filtered (stream, _("\
1179 --with-iconv-bin=%s%s\n\
1180"), ICONV_BIN, ICONV_BIN_RELOCATABLE ? " (relocatable)" : "");
1181#endif
1182 if (JIT_READER_DIR[0])
1183 fprintf_filtered (stream, _("\
1184 --with-jit-reader-dir=%s%s\n\
1185"), JIT_READER_DIR, JIT_READER_DIR_RELOCATABLE ? " (relocatable)" : "");
1186#if HAVE_LIBUNWIND_IA64_H
1187 fprintf_filtered (stream, _("\
1188 --with-libunwind-ia64\n\
1189"));
1190#else
1191 fprintf_filtered (stream, _("\
1192 --without-libunwind-ia64\n\
1193"));
1194#endif
1195#if HAVE_LIBLZMA
1196 fprintf_filtered (stream, _("\
1197 --with-lzma\n\
1198"));
1199#else
1200 fprintf_filtered (stream, _("\
1201 --without-lzma\n\
1202"));
1203#endif
1204#ifdef WITH_PYTHON_PATH
1205 fprintf_filtered (stream, _("\
1206 --with-python=%s%s\n\
1207"), WITH_PYTHON_PATH, PYTHON_PATH_RELOCATABLE ? " (relocatable)" : "");
1208#endif
1209#ifdef RELOC_SRCDIR
1210 fprintf_filtered (stream, _("\
1211 --with-relocated-sources=%s\n\
1212"), RELOC_SRCDIR);
1213#endif
1214 if (DEBUGDIR[0])
1215 fprintf_filtered (stream, _("\
1216 --with-separate-debug-dir=%s%s\n\
1217"), DEBUGDIR, DEBUGDIR_RELOCATABLE ? " (relocatable)" : "");
1218 if (TARGET_SYSTEM_ROOT[0])
1219 fprintf_filtered (stream, _("\
1220 --with-sysroot=%s%s\n\
1221"), TARGET_SYSTEM_ROOT, TARGET_SYSTEM_ROOT_RELOCATABLE ? " (relocatable)" : "");
1222 if (SYSTEM_GDBINIT[0])
1223 fprintf_filtered (stream, _("\
1224 --with-system-gdbinit=%s%s\n\
1225"), SYSTEM_GDBINIT, SYSTEM_GDBINIT_RELOCATABLE ? " (relocatable)" : "");
1226#if HAVE_ZLIB_H
1227 fprintf_filtered (stream, _("\
1228 --with-zlib\n\
1229"));
1230#else
1231 fprintf_filtered (stream, _("\
1232 --without-zlib\n\
1233"));
1234#endif
ab116149
YQ
1235#if HAVE_LIBBABELTRACE
1236 fprintf_filtered (stream, _("\
1237 --with-babeltrace\n\
1238"));
1239#else
1240 fprintf_filtered (stream, _("\
1241 --without-babeltrace\n\
1242"));
1243#endif
6eaaf48b 1244}
9e0b60a8 1245\f
95298e72 1246
ab821bc6
PA
1247/* The current top level prompt, settable with "set prompt", and/or
1248 with the python `gdb.prompt_hook' hook. */
1249static char *top_prompt;
9e0b60a8 1250
ab821bc6 1251/* Access method for the GDB prompt string. */
95298e72
PM
1252
1253char *
ab821bc6 1254get_prompt (void)
95298e72 1255{
ab821bc6 1256 return top_prompt;
95298e72
PM
1257}
1258
ab821bc6 1259/* Set method for the GDB prompt string. */
95298e72
PM
1260
1261void
ab821bc6 1262set_prompt (const char *s)
95298e72 1263{
ab821bc6 1264 char *p = xstrdup (s);
95298e72 1265
ab821bc6
PA
1266 xfree (top_prompt);
1267 top_prompt = p;
9e0b60a8 1268}
9e0b60a8 1269\f
c5aa993b 1270
b0abbc58 1271struct qt_args
9e0b60a8 1272{
b0abbc58
JJ
1273 char *args;
1274 int from_tty;
1275};
9e0b60a8 1276
54a012c9
PA
1277/* Callback for iterate_over_inferiors. Kills or detaches the given
1278 inferior, depending on how we originally gained control of it. */
1279
1280static int
1281kill_or_detach (struct inferior *inf, void *args)
1282{
1283 struct qt_args *qt = args;
1284 struct thread_info *thread;
1285
6c95b8df
PA
1286 if (inf->pid == 0)
1287 return 0;
1288
b8fa0bfa
PA
1289 thread = any_thread_of_process (inf->pid);
1290 if (thread != NULL)
9e0b60a8 1291 {
54a012c9 1292 switch_to_thread (thread->ptid);
c35b1492
PA
1293
1294 /* Leave core files alone. */
1295 if (target_has_execution)
1296 {
1297 if (inf->attach_flag)
1298 target_detach (qt->args, qt->from_tty);
1299 else
1300 target_kill ();
1301 }
9e0b60a8
JM
1302 }
1303
54a012c9
PA
1304 return 0;
1305}
1306
b8fa0bfa
PA
1307/* Callback for iterate_over_inferiors. Prints info about what GDB
1308 will do to each inferior on a "quit". ARG points to a struct
1309 ui_out where output is to be collected. */
1310
1311static int
1312print_inferior_quit_action (struct inferior *inf, void *arg)
1313{
1314 struct ui_file *stb = arg;
1315
6c95b8df
PA
1316 if (inf->pid == 0)
1317 return 0;
1318
b8fa0bfa
PA
1319 if (inf->attach_flag)
1320 fprintf_filtered (stb,
1321 _("\tInferior %d [%s] will be detached.\n"), inf->num,
1322 target_pid_to_str (pid_to_ptid (inf->pid)));
1323 else
1324 fprintf_filtered (stb,
1325 _("\tInferior %d [%s] will be killed.\n"), inf->num,
1326 target_pid_to_str (pid_to_ptid (inf->pid)));
1327
1328 return 0;
1329}
1330
1331/* If necessary, make the user confirm that we should quit. Return
1332 non-zero if we should quit, zero if we shouldn't. */
1333
1334int
1335quit_confirm (void)
1336{
1337 struct ui_file *stb;
1338 struct cleanup *old_chain;
1339 char *str;
1340 int qr;
1341
1342 /* Don't even ask if we're only debugging a core file inferior. */
1343 if (!have_live_inferiors ())
1344 return 1;
1345
1346 /* Build the query string as a single string. */
1347 stb = mem_fileopen ();
1348 old_chain = make_cleanup_ui_file_delete (stb);
1349
1350 /* This is something of a hack. But there's no reliable way to see
1351 if a GUI is running. The `use_windows' variable doesn't cut
1352 it. */
1353 if (deprecated_init_ui_hook)
1354 fprintf_filtered (stb, _("A debugging session is active.\n"
1355 "Do you still want to close the debugger?"));
1356 else
1357 {
1358 fprintf_filtered (stb, _("A debugging session is active.\n\n"));
1359 iterate_over_inferiors (print_inferior_quit_action, stb);
1360 fprintf_filtered (stb, _("\nQuit anyway? "));
1361 }
1362
1363 str = ui_file_xstrdup (stb, NULL);
1364 make_cleanup (xfree, str);
1365
1366 qr = query ("%s", str);
1367 do_cleanups (old_chain);
1368 return qr;
1369}
1370
b0abbc58
JJ
1371/* Quit without asking for confirmation. */
1372
1373void
1374quit_force (char *args, int from_tty)
1375{
1376 int exit_code = 0;
365c70b1 1377 struct qt_args qt;
2f9d54cf 1378 volatile struct gdb_exception ex;
b0abbc58
JJ
1379
1380 /* An optional expression may be used to cause gdb to terminate with the
371d5dec 1381 value of that expression. */
b0abbc58
JJ
1382 if (args)
1383 {
1384 struct value *val = parse_and_eval (args);
1385
1386 exit_code = (int) value_as_long (val);
1387 }
4b0ad762
AS
1388 else if (return_child_result)
1389 exit_code = return_child_result_value;
b0abbc58 1390
365c70b1
JJ
1391 qt.args = args;
1392 qt.from_tty = from_tty;
1393
2f9d54cf
PA
1394 /* Wrappers to make the code below a bit more readable. */
1395#define DO_TRY \
1396 TRY_CATCH (ex, RETURN_MASK_ALL)
1397
1398#define DO_PRINT_EX \
1399 if (ex.reason < 0) \
1400 exception_print (gdb_stderr, ex)
1401
b0abbc58 1402 /* We want to handle any quit errors and exit regardless. */
2f9d54cf
PA
1403
1404 /* Get out of tfind mode, and kill or detach all inferiors. */
1405 DO_TRY
1406 {
1407 disconnect_tracing ();
1408 iterate_over_inferiors (kill_or_detach, &qt);
1409 }
1410 DO_PRINT_EX;
1411
1412 /* Give all pushed targets a chance to do minimal cleanup, and pop
1413 them all out. */
1414 DO_TRY
1415 {
1416 pop_all_targets ();
1417 }
1418 DO_PRINT_EX;
1419
1420 /* Save the history information if it is appropriate to do so. */
1421 DO_TRY
1422 {
1423 if (write_history_p && history_filename)
1424 write_history (history_filename);
1425 }
1426 DO_PRINT_EX;
1427
1428 /* Do any final cleanups before exiting. */
1429 DO_TRY
1430 {
1431 do_final_cleanups (all_cleanups ());
1432 }
1433 DO_PRINT_EX;
b0abbc58 1434
9e0b60a8
JM
1435 exit (exit_code);
1436}
1437
698ba934
DJ
1438/* Returns whether GDB is running on a terminal and input is
1439 currently coming from that terminal. */
9e0b60a8
JM
1440
1441int
fba45db2 1442input_from_terminal_p (void)
9e0b60a8 1443{
c63a1f86
JK
1444 if (batch_flag)
1445 return 0;
1446
698ba934
DJ
1447 if (gdb_has_a_terminal () && instream == stdin)
1448 return 1;
1449
1450 /* If INSTREAM is unset, and we are not in a user command, we
1451 must be in Insight. That's like having a terminal, for our
1452 purposes. */
1453 if (instream == NULL && !in_user_command)
1454 return 1;
1455
1456 return 0;
9e0b60a8
JM
1457}
1458\f
9e0b60a8 1459static void
fba45db2 1460dont_repeat_command (char *ignored, int from_tty)
9e0b60a8 1461{
dc7eb48e
PA
1462 /* Can't call dont_repeat here because we're not necessarily reading
1463 from stdin. */
1464 *saved_command_line = 0;
9e0b60a8
JM
1465}
1466\f
1467/* Functions to manipulate command line editing control variables. */
1468
1469/* Number of commands to print in each call to show_commands. */
1470#define Hist_print 10
d318976c 1471void
fba45db2 1472show_commands (char *args, int from_tty)
9e0b60a8
JM
1473{
1474 /* Index for history commands. Relative to history_base. */
1475 int offset;
1476
1477 /* Number of the history entry which we are planning to display next.
1478 Relative to history_base. */
1479 static int num = 0;
1480
9e0b60a8 1481 /* Print out some of the commands from the command history. */
9e0b60a8
JM
1482
1483 if (args)
1484 {
1485 if (args[0] == '+' && args[1] == '\0')
1486 /* "info editing +" should print from the stored position. */
1487 ;
1488 else
1489 /* "info editing <exp>" should print around command number <exp>. */
0e828ed1 1490 num = (parse_and_eval_long (args) - history_base) - Hist_print / 2;
9e0b60a8
JM
1491 }
1492 /* "show commands" means print the last Hist_print commands. */
1493 else
1494 {
840a9a1f 1495 num = history_length - Hist_print;
9e0b60a8
JM
1496 }
1497
1498 if (num < 0)
1499 num = 0;
1500
1501 /* If there are at least Hist_print commands, we want to display the last
1502 Hist_print rather than, say, the last 6. */
840a9a1f 1503 if (history_length - num < Hist_print)
9e0b60a8 1504 {
840a9a1f 1505 num = history_length - Hist_print;
9e0b60a8
JM
1506 if (num < 0)
1507 num = 0;
1508 }
1509
840a9a1f
PA
1510 for (offset = num;
1511 offset < num + Hist_print && offset < history_length;
1512 offset++)
9e0b60a8
JM
1513 {
1514 printf_filtered ("%5d %s\n", history_base + offset,
c5aa993b 1515 (history_get (history_base + offset))->line);
9e0b60a8
JM
1516 }
1517
1518 /* The next command we want to display is the next one that we haven't
1519 displayed yet. */
1520 num += Hist_print;
1521
1522 /* If the user repeats this command with return, it should do what
1523 "show commands +" does. This is unnecessary if arg is null,
1524 because "show commands +" is not useful after "show commands". */
1525 if (from_tty && args)
1526 {
1527 args[0] = '+';
1528 args[1] = '\0';
1529 }
1530}
1531
1532/* Called by do_setshow_command. */
9e0b60a8 1533static void
fba45db2 1534set_history_size_command (char *args, int from_tty, struct cmd_list_element *c)
9e0b60a8 1535{
840a9a1f
PA
1536 /* Readline's history interface works with 'int', so it can only
1537 handle history sizes up to INT_MAX. The command itself is
1538 uinteger, so UINT_MAX means "unlimited", but we only get that if
1539 the user does "set history size 0" -- "set history size <UINT_MAX>"
1540 throws out-of-range. */
1541 if (history_size_setshow_var > INT_MAX
1542 && history_size_setshow_var != UINT_MAX)
9e0b60a8 1543 {
840a9a1f
PA
1544 unsigned int new_value = history_size_setshow_var;
1545
1546 /* Restore previous value before throwing. */
1547 if (history_is_stifled ())
1548 history_size_setshow_var = history_max_entries;
1549 else
1550 history_size_setshow_var = UINT_MAX;
1551
1552 error (_("integer %u out of range"), new_value);
9e0b60a8 1553 }
840a9a1f
PA
1554
1555 /* Commit the new value to readline's history. */
1556 if (history_size_setshow_var == UINT_MAX)
1557 unstifle_history ();
883b9c6c 1558 else
840a9a1f 1559 stifle_history (history_size_setshow_var);
9e0b60a8
JM
1560}
1561
d318976c 1562void
fba45db2 1563set_history (char *args, int from_tty)
9e0b60a8 1564{
3e43a32a
MS
1565 printf_unfiltered (_("\"set history\" must be followed "
1566 "by the name of a history subcommand.\n"));
9e0b60a8
JM
1567 help_list (sethistlist, "set history ", -1, gdb_stdout);
1568}
1569
d318976c 1570void
fba45db2 1571show_history (char *args, int from_tty)
9e0b60a8
JM
1572{
1573 cmd_show_list (showhistlist, from_tty, "");
1574}
1575
371d5dec 1576int info_verbose = 0; /* Default verbose msgs off. */
9e0b60a8
JM
1577
1578/* Called by do_setshow_command. An elaborate joke. */
d318976c 1579void
fba45db2 1580set_verbose (char *args, int from_tty, struct cmd_list_element *c)
9e0b60a8 1581{
6f937416 1582 const char *cmdname = "verbose";
9e0b60a8
JM
1583 struct cmd_list_element *showcmd;
1584
1585 showcmd = lookup_cmd_1 (&cmdname, showlist, NULL, 1);
1427fe5e 1586 gdb_assert (showcmd != NULL && showcmd != CMD_LIST_AMBIGUOUS);
9e0b60a8
JM
1587
1588 if (info_verbose)
1589 {
1590 c->doc = "Set verbose printing of informational messages.";
1591 showcmd->doc = "Show verbose printing of informational messages.";
1592 }
1593 else
1594 {
1595 c->doc = "Set verbosity.";
1596 showcmd->doc = "Show verbosity.";
1597 }
1598}
1599
9e0b60a8 1600/* Init the history buffer. Note that we are called after the init file(s)
371d5dec
MS
1601 have been read so that the user can change the history file via his
1602 .gdbinit file (for instance). The GDBHISTFILE environment variable
1603 overrides all of this. */
9e0b60a8
JM
1604
1605void
fba45db2 1606init_history (void)
9e0b60a8
JM
1607{
1608 char *tmpenv;
1609
1610 tmpenv = getenv ("HISTSIZE");
1611 if (tmpenv)
840a9a1f
PA
1612 {
1613 int var;
1614
1615 var = atoi (tmpenv);
1616 if (var < 0)
1617 {
1618 /* Prefer ending up with no history rather than overflowing
1619 readline's history interface, which uses signed 'int'
1620 everywhere. */
1621 var = 0;
1622 }
1623
1624 history_size_setshow_var = var;
1625 }
1626 /* If the init file hasn't set a size yet, pick the default. */
1627 else if (history_size_setshow_var == 0)
1628 history_size_setshow_var = 256;
9e0b60a8 1629
840a9a1f
PA
1630 /* Note that unlike "set history size 0", "HISTSIZE=0" really sets
1631 the history size to 0... */
1632 stifle_history (history_size_setshow_var);
9e0b60a8
JM
1633
1634 tmpenv = getenv ("GDBHISTFILE");
1635 if (tmpenv)
1b36a34b 1636 history_filename = xstrdup (tmpenv);
c5aa993b
JM
1637 else if (!history_filename)
1638 {
1639 /* We include the current directory so that if the user changes
1640 directories the file written will be the same as the one
1641 that was read. */
a0b3c4fd 1642#ifdef __MSDOS__
eb2f494a 1643 /* No leading dots in file names are allowed on MSDOS. */
1754f103
MK
1644 history_filename = concat (current_directory, "/_gdb_history",
1645 (char *)NULL);
a0b3c4fd 1646#else
1754f103
MK
1647 history_filename = concat (current_directory, "/.gdb_history",
1648 (char *)NULL);
a0b3c4fd 1649#endif
c5aa993b 1650 }
9e0b60a8
JM
1651 read_history (history_filename);
1652}
1653
920d2a44 1654static void
ab821bc6
PA
1655show_prompt (struct ui_file *file, int from_tty,
1656 struct cmd_list_element *c, const char *value)
920d2a44
AC
1657{
1658 fprintf_filtered (file, _("Gdb's prompt is \"%s\".\n"), value);
1659}
1660
1661static void
1662show_async_command_editing_p (struct ui_file *file, int from_tty,
1663 struct cmd_list_element *c, const char *value)
1664{
3e43a32a
MS
1665 fprintf_filtered (file, _("Editing of command lines as "
1666 "they are typed is %s.\n"),
920d2a44
AC
1667 value);
1668}
1669
1670static void
1671show_annotation_level (struct ui_file *file, int from_tty,
1672 struct cmd_list_element *c, const char *value)
1673{
1674 fprintf_filtered (file, _("Annotation_level is %s.\n"), value);
1675}
1676
1677static void
1678show_exec_done_display_p (struct ui_file *file, int from_tty,
1679 struct cmd_list_element *c, const char *value)
1680{
3e43a32a
MS
1681 fprintf_filtered (file, _("Notification of completion for "
1682 "asynchronous execution commands is %s.\n"),
920d2a44
AC
1683 value);
1684}
6dea1fbd
JK
1685
1686/* "set" command for the gdb_datadir configuration variable. */
1687
1688static void
1689set_gdb_datadir (char *args, int from_tty, struct cmd_list_element *c)
1690{
1691 observer_notify_gdb_datadir_changed ();
1692}
1693
9e0b60a8 1694static void
fba45db2 1695init_main (void)
9e0b60a8 1696{
ab821bc6
PA
1697 /* Initialize the prompt to a simple "(gdb) " prompt or to whatever
1698 the DEFAULT_PROMPT is. */
1699 set_prompt (DEFAULT_PROMPT);
1700
362646f5
AC
1701 /* Set things up for annotation_level > 1, if the user ever decides
1702 to use it. */
1703 async_annotation_suffix = "prompt";
362646f5 1704
9e0b60a8
JM
1705 /* Set the important stuff up for command editing. */
1706 command_editing_p = 1;
9e0b60a8
JM
1707 history_expansion_p = 0;
1708 write_history_p = 0;
1709
1710 /* Setup important stuff for command line editing. */
67c296a2 1711 rl_completion_word_break_hook = gdb_completion_word_break_characters;
38017ce8 1712 rl_completion_entry_function = readline_line_completion_function;
51065942 1713 rl_completer_word_break_characters = default_word_break_characters ();
d318976c 1714 rl_completer_quote_characters = get_gdb_completer_quote_characters ();
9e0b60a8 1715 rl_readline_name = "gdb";
7cb3ec5e 1716 rl_terminal_name = getenv ("TERM");
9e0b60a8 1717
467d8519
TT
1718 /* The name for this defun comes from Bash, where it originated.
1719 15 is Control-o, the same binding this function has in Bash. */
1720 rl_add_defun ("operate-and-get-next", gdb_rl_operate_and_get_next, 15);
1721
4d28ad1e 1722 add_setshow_string_cmd ("prompt", class_support,
ab821bc6 1723 &top_prompt,
3e43a32a
MS
1724 _("Set gdb's prompt"),
1725 _("Show gdb's prompt"),
ab821bc6
PA
1726 NULL, NULL,
1727 show_prompt,
4d28ad1e 1728 &setlist, &showlist);
9e0b60a8 1729
1bedd215 1730 add_com ("dont-repeat", class_support, dont_repeat_command, _("\
3e43a32a
MS
1731Don't repeat this command.\nPrimarily \
1732used inside of user-defined commands that should not be repeated when\n\
1bedd215 1733hitting return."));
9e0b60a8 1734
5bf193a2
AC
1735 add_setshow_boolean_cmd ("editing", class_support,
1736 &async_command_editing_p, _("\
1737Set editing of command lines as they are typed."), _("\
1738Show editing of command lines as they are typed."), _("\
9e0b60a8
JM
1739Use \"on\" to enable the editing, and \"off\" to disable it.\n\
1740Without an argument, command line editing is enabled. To edit, use\n\
5bf193a2
AC
1741EMACS-like or VI-like commands like control-P or ESC."),
1742 set_async_editing_command,
920d2a44 1743 show_async_command_editing_p,
5bf193a2
AC
1744 &setlist, &showlist);
1745
1746 add_setshow_boolean_cmd ("save", no_class, &write_history_p, _("\
1747Set saving of the history record on exit."), _("\
1748Show saving of the history record on exit."), _("\
9e0b60a8 1749Use \"on\" to enable the saving, and \"off\" to disable it.\n\
5bf193a2
AC
1750Without an argument, saving is enabled."),
1751 NULL,
920d2a44 1752 show_write_history_p,
5bf193a2 1753 &sethistlist, &showhistlist);
9e0b60a8 1754
840a9a1f 1755 add_setshow_uinteger_cmd ("size", no_class, &history_size_setshow_var, _("\
4d28ad1e
AC
1756Set the size of the command history,"), _("\
1757Show the size of the command history,"), _("\
f81d1120
PA
1758ie. the number of previous commands to keep a record of.\n\
1759If set to \"unlimited\", the number of commands kept in the history\n\
1760list is unlimited. This defaults to the value of the environment\n\
1761variable \"HISTSIZE\", or to 256 if this variable is not set."),
883b9c6c
YQ
1762 set_history_size_command,
1763 show_history_size,
1764 &sethistlist, &showhistlist);
4d28ad1e
AC
1765
1766 add_setshow_filename_cmd ("filename", no_class, &history_filename, _("\
1767Set the filename in which to record the command history"), _("\
1768Show the filename in which to record the command history"), _("\
1769(the list of previous commands of which a record is kept)."),
1770 NULL,
920d2a44 1771 show_history_filename,
4d28ad1e 1772 &sethistlist, &showhistlist);
9e0b60a8 1773
e360902b 1774 add_setshow_boolean_cmd ("confirm", class_support, &confirm, _("\
5bf193a2
AC
1775Set whether to confirm potentially dangerous operations."), _("\
1776Show whether to confirm potentially dangerous operations."), NULL,
1777 NULL,
e360902b 1778 show_confirm,
5bf193a2 1779 &setlist, &showlist);
9e0b60a8 1780
85c07804
AC
1781 add_setshow_zinteger_cmd ("annotate", class_obscure, &annotation_level, _("\
1782Set annotation_level."), _("\
1783Show annotation_level."), _("\
9e0b60a8 17840 == normal; 1 == fullname (for use when running under emacs)\n\
85c07804 17852 == output annotated suitably for use by programs that control GDB."),
ab821bc6 1786 NULL,
920d2a44 1787 show_annotation_level,
85c07804 1788 &setlist, &showlist);
362646f5 1789
5bf193a2
AC
1790 add_setshow_boolean_cmd ("exec-done-display", class_support,
1791 &exec_done_display_p, _("\
1792Set notification of completion for asynchronous execution commands."), _("\
1793Show notification of completion for asynchronous execution commands."), _("\
1794Use \"on\" to enable the notification, and \"off\" to disable it."),
1795 NULL,
920d2a44 1796 show_exec_done_display_p,
5bf193a2 1797 &setlist, &showlist);
b14b1491
TT
1798
1799 add_setshow_filename_cmd ("data-directory", class_maintenance,
1800 &gdb_datadir, _("Set GDB's data directory."),
1801 _("Show GDB's data directory."),
1802 _("\
1803When set, GDB uses the specified path to search for data files."),
6dea1fbd 1804 set_gdb_datadir, NULL,
b14b1491
TT
1805 &setlist,
1806 &showlist);
9e0b60a8 1807}
64cdedad
EZ
1808
1809void
1810gdb_init (char *argv0)
1811{
1812 if (pre_init_ui_hook)
1813 pre_init_ui_hook ();
1814
371d5dec 1815 /* Run the init function of each source file. */
64cdedad 1816
64cdedad
EZ
1817#ifdef __MSDOS__
1818 /* Make sure we return to the original directory upon exit, come
1819 what may, since the OS doesn't do that for us. */
1820 make_final_cleanup (do_chdir_cleanup, xstrdup (current_directory));
1821#endif
1822
371d5dec
MS
1823 init_cmd_lists (); /* This needs to be done first. */
1824 initialize_targets (); /* Setup target_terminal macros for utils.c. */
1825 initialize_utils (); /* Make errors and warnings possible. */
9dea9163
DE
1826
1827 /* Here is where we call all the _initialize_foo routines. */
64cdedad 1828 initialize_all_files ();
9dea9163 1829
6c95b8df
PA
1830 /* This creates the current_program_space. Do this after all the
1831 _initialize_foo routines have had a chance to install their
1832 per-sspace data keys. Also do this before
1833 initialize_current_architecture is called, because it accesses
1834 exec_bfd of the current program space. */
1835 initialize_progspace ();
1836 initialize_inferiors ();
64cdedad
EZ
1837 initialize_current_architecture ();
1838 init_cli_cmds();
843b20dc 1839 initialize_event_loop ();
371d5dec 1840 init_main (); /* But that omits this file! Do it now. */
64cdedad 1841
0ea3f30e
DJ
1842 initialize_stdin_serial ();
1843
362646f5 1844 async_init_signals ();
64cdedad 1845
371d5dec
MS
1846 /* We need a default language for parsing expressions, so simple
1847 things like "set width 0" won't fail if no language is explicitly
1848 set in a config file or implicitly set by reading an executable
1849 during startup. */
64cdedad 1850 set_language (language_c);
371d5dec 1851 expected_language = current_language; /* Don't warn about the change. */
64cdedad 1852
c378eb4e 1853 /* Allow another UI to initialize. If the UI fails to initialize,
9a4105ab
AC
1854 and it wants GDB to revert to the CLI, it should clear
1855 deprecated_init_ui_hook. */
1856 if (deprecated_init_ui_hook)
1857 deprecated_init_ui_hook (argv0);
9dea9163
DE
1858
1859#ifdef HAVE_PYTHON
371d5dec
MS
1860 /* Python initialization can require various commands to be
1861 installed. For example "info pretty-printer" needs the "info"
1862 prefix to be installed. Keep things simple and just do final
1863 python initialization here. */
9dea9163
DE
1864 finish_python_initialization ();
1865#endif
64cdedad 1866}
This page took 1.547017 seconds and 4 git commands to generate.