]>
Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Top level stuff for GDB, the GNU debugger. |
a752853e AC |
2 | |
3 | Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, | |
637537d0 | 4 | 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 |
a752853e | 5 | Free Software Foundation, Inc. |
c906108c | 6 | |
c5aa993b | 7 | This file is part of GDB. |
c906108c | 8 | |
c5aa993b JM |
9 | This program is free software; you can redistribute it and/or modify |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 2 of the License, or | |
12 | (at your option) any later version. | |
c906108c | 13 | |
c5aa993b JM |
14 | This program is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
c906108c | 18 | |
c5aa993b JM |
19 | You should have received a copy of the GNU General Public License |
20 | along with this program; if not, write to the Free Software | |
21 | Foundation, Inc., 59 Temple Place - Suite 330, | |
22 | Boston, MA 02111-1307, USA. */ | |
c906108c SS |
23 | |
24 | #include "defs.h" | |
25 | #include "gdbcmd.h" | |
26 | #include "call-cmds.h" | |
210661e7 EZ |
27 | #include "cli/cli-cmds.h" |
28 | #include "cli/cli-script.h" | |
29 | #include "cli/cli-setshow.h" | |
18a642a1 | 30 | #include "cli/cli-decode.h" |
c906108c SS |
31 | #include "symtab.h" |
32 | #include "inferior.h" | |
60250e8b | 33 | #include "exceptions.h" |
042be3a9 | 34 | #include <signal.h> |
c906108c SS |
35 | #include "target.h" |
36 | #include "breakpoint.h" | |
37 | #include "gdbtypes.h" | |
38 | #include "expression.h" | |
39 | #include "value.h" | |
40 | #include "language.h" | |
c5aa993b | 41 | #include "terminal.h" /* For job_control. */ |
c906108c | 42 | #include "annotate.h" |
c5f0f3d0 | 43 | #include "completer.h" |
c906108c | 44 | #include "top.h" |
d4f3574e | 45 | #include "version.h" |
210661e7 | 46 | #include "serial.h" |
d16aafd8 | 47 | #include "doublest.h" |
f9c696d2 | 48 | #include "gdb_assert.h" |
c906108c SS |
49 | |
50 | /* readline include files */ | |
dbda9972 AC |
51 | #include "readline/readline.h" |
52 | #include "readline/history.h" | |
c906108c SS |
53 | |
54 | /* readline defines this. */ | |
55 | #undef savestring | |
56 | ||
57 | #include <sys/types.h> | |
c906108c | 58 | |
c2c6d25f | 59 | #include "event-top.h" |
c906108c SS |
60 | #include "gdb_string.h" |
61 | #include "gdb_stat.h" | |
62 | #include <ctype.h> | |
8b93c638 JM |
63 | #include "ui-out.h" |
64 | #include "cli-out.h" | |
c906108c | 65 | |
104c1213 JM |
66 | /* Default command line prompt. This is overriden in some configs. */ |
67 | ||
68 | #ifndef DEFAULT_PROMPT | |
69 | #define DEFAULT_PROMPT "(gdb) " | |
c906108c SS |
70 | #endif |
71 | ||
72 | /* Initialization file name for gdb. This is overridden in some configs. */ | |
73 | ||
74 | #ifndef GDBINIT_FILENAME | |
75 | #define GDBINIT_FILENAME ".gdbinit" | |
76 | #endif | |
77 | char gdbinit[] = GDBINIT_FILENAME; | |
78 | ||
79 | int inhibit_gdbinit = 0; | |
80 | ||
81 | /* If nonzero, and GDB has been configured to be able to use windows, | |
82 | attempt to open them upon startup. */ | |
83 | ||
f15ab4a7 | 84 | int use_windows = 0; |
c906108c | 85 | |
c906108c SS |
86 | extern char lang_frame_mismatch_warn[]; /* language.c */ |
87 | ||
88 | /* Flag for whether we want all the "from_tty" gubbish printed. */ | |
89 | ||
c5aa993b | 90 | int caution = 1; /* Default is yes, sigh. */ |
920d2a44 AC |
91 | static void |
92 | show_caution (struct ui_file *file, int from_tty, | |
93 | struct cmd_list_element *c, const char *value) | |
94 | { | |
95 | fprintf_filtered (file, _("\ | |
96 | Whether to confirm potentially dangerous operations is %s.\n"), | |
97 | value); | |
98 | } | |
c906108c | 99 | |
c906108c SS |
100 | /* stdio stream that command input is being read from. Set to stdin normally. |
101 | Set by source_command to the file we are sourcing. Set to NULL if we are | |
102 | executing a user-defined command or interacting via a GUI. */ | |
103 | ||
104 | FILE *instream; | |
105 | ||
106 | /* Current working directory. */ | |
107 | ||
108 | char *current_directory; | |
109 | ||
110 | /* The directory name is actually stored here (usually). */ | |
111 | char gdb_dirbuf[1024]; | |
112 | ||
113 | /* Function to call before reading a command, if nonzero. | |
114 | The function receives two args: an input stream, | |
115 | and a prompt string. */ | |
116 | ||
507f3c78 | 117 | void (*window_hook) (FILE *, char *); |
c906108c SS |
118 | |
119 | int epoch_interface; | |
120 | int xgdb_verbose; | |
121 | ||
122 | /* gdb prints this when reading a command interactively */ | |
c5aa993b | 123 | static char *gdb_prompt_string; /* the global prompt string */ |
c906108c SS |
124 | |
125 | /* Buffer used for reading command lines, and the size | |
126 | allocated for it so far. */ | |
127 | ||
128 | char *line; | |
129 | int linesize = 100; | |
130 | ||
131 | /* Nonzero if the current command is modified by "server ". This | |
c2d11a7d | 132 | affects things like recording into the command history, commands |
c906108c SS |
133 | repeating on RETURN, etc. This is so a user interface (emacs, GUI, |
134 | whatever) can issue its own commands and also send along commands | |
135 | from the user, and have the user not notice that the user interface | |
136 | is issuing commands too. */ | |
137 | int server_command; | |
138 | ||
139 | /* Baud rate specified for talking to serial target systems. Default | |
140 | is left as -1, so targets can choose their own defaults. */ | |
141 | /* FIXME: This means that "show remotebaud" and gr_files_info can print -1 | |
142 | or (unsigned int)-1. This is a Bad User Interface. */ | |
143 | ||
144 | int baud_rate = -1; | |
145 | ||
146 | /* Timeout limit for response from target. */ | |
147 | ||
ce808e91 AC |
148 | /* The default value has been changed many times over the years. It |
149 | was originally 5 seconds. But that was thought to be a long time | |
150 | to sit and wait, so it was changed to 2 seconds. That was thought | |
151 | to be plenty unless the connection was going through some terminal | |
152 | server or multiplexer or other form of hairy serial connection. | |
153 | ||
154 | In mid-1996, remote_timeout was moved from remote.c to top.c and | |
155 | it began being used in other remote-* targets. It appears that the | |
156 | default was changed to 20 seconds at that time, perhaps because the | |
85a453d5 | 157 | Renesas E7000 ICE didn't always respond in a timely manner. |
ce808e91 AC |
158 | |
159 | But if 5 seconds is a long time to sit and wait for retransmissions, | |
160 | 20 seconds is far worse. This demonstrates the difficulty of using | |
161 | a single variable for all protocol timeouts. | |
162 | ||
163 | As remote.c is used much more than remote-e7000.c, it was changed | |
164 | back to 2 seconds in 1999. */ | |
165 | ||
166 | int remote_timeout = 2; | |
c906108c SS |
167 | |
168 | /* Non-zero tells remote* modules to output debugging info. */ | |
169 | ||
170 | int remote_debug = 0; | |
171 | ||
43ff13b4 JM |
172 | /* Non-zero means the target is running. Note: this is different from |
173 | saying that there is an active target and we are stopped at a | |
174 | breakpoint, for instance. This is a real indicator whether the | |
175 | target is off and running, which gdb is doing something else. */ | |
176 | int target_executing = 0; | |
177 | ||
c906108c SS |
178 | /* Level of control structure. */ |
179 | static int control_level; | |
180 | ||
6dd77b81 RH |
181 | /* Sbrk location on entry to main. Used for statistics only. */ |
182 | #ifdef HAVE_SBRK | |
183 | char *lim_at_start; | |
184 | #endif | |
185 | ||
c906108c SS |
186 | /* Signal to catch ^Z typed while reading a command: SIGTSTP or SIGCONT. */ |
187 | ||
188 | #ifndef STOP_SIGNAL | |
189 | #ifdef SIGTSTP | |
190 | #define STOP_SIGNAL SIGTSTP | |
a14ed312 | 191 | static void stop_sig (int); |
c906108c SS |
192 | #endif |
193 | #endif | |
194 | ||
c906108c SS |
195 | /* Hooks for alternate command interfaces. */ |
196 | ||
197 | /* Called after most modules have been initialized, but before taking users | |
1ad24239 KS |
198 | command file. |
199 | ||
200 | If the UI fails to initialize and it wants GDB to continue | |
201 | using the default UI, then it should clear this hook before returning. */ | |
c906108c | 202 | |
9a4105ab | 203 | void (*deprecated_init_ui_hook) (char *argv0); |
7a292a7a SS |
204 | |
205 | /* This hook is called from within gdb's many mini-event loops which could | |
206 | steal control from a real user interface's event loop. It returns | |
207 | non-zero if the user is requesting a detach, zero otherwise. */ | |
208 | ||
98bbd631 | 209 | int (*deprecated_ui_loop_hook) (int); |
c906108c SS |
210 | |
211 | /* Called instead of command_loop at top level. Can be invoked via | |
b5a2688f | 212 | throw_exception(). */ |
c906108c | 213 | |
9a4105ab | 214 | void (*deprecated_command_loop_hook) (void); |
c906108c SS |
215 | |
216 | ||
c906108c SS |
217 | /* Called from print_frame_info to list the line we stopped in. */ |
218 | ||
9a4105ab AC |
219 | void (*deprecated_print_frame_info_listing_hook) (struct symtab * s, int line, |
220 | int stopline, int noerror); | |
c906108c SS |
221 | /* Replaces most of query. */ |
222 | ||
9a4105ab | 223 | int (*deprecated_query_hook) (const char *, va_list); |
c906108c SS |
224 | |
225 | /* Replaces most of warning. */ | |
226 | ||
9a4105ab | 227 | void (*deprecated_warning_hook) (const char *, va_list); |
c906108c | 228 | |
9a4105ab AC |
229 | /* These three functions support getting lines of text from the user. |
230 | They are used in sequence. First deprecated_readline_begin_hook is | |
231 | called with a text string that might be (for example) a message for | |
232 | the user to type in a sequence of commands to be executed at a | |
233 | breakpoint. If this function calls back to a GUI, it might take | |
234 | this opportunity to pop up a text interaction window with this | |
235 | message. Next, deprecated_readline_hook is called with a prompt | |
236 | that is emitted prior to collecting the user input. It can be | |
237 | called multiple times. Finally, deprecated_readline_end_hook is | |
238 | called to notify the GUI that we are done with the interaction | |
239 | window and it can close it. */ | |
c906108c | 240 | |
9a4105ab AC |
241 | void (*deprecated_readline_begin_hook) (char *, ...); |
242 | char *(*deprecated_readline_hook) (char *); | |
243 | void (*deprecated_readline_end_hook) (void); | |
c906108c SS |
244 | |
245 | /* Called as appropriate to notify the interface of the specified breakpoint | |
246 | conditions. */ | |
247 | ||
9a4105ab AC |
248 | void (*deprecated_create_breakpoint_hook) (struct breakpoint * bpt); |
249 | void (*deprecated_delete_breakpoint_hook) (struct breakpoint * bpt); | |
250 | void (*deprecated_modify_breakpoint_hook) (struct breakpoint * bpt); | |
c906108c | 251 | |
6426a772 JM |
252 | /* Called as appropriate to notify the interface that we have attached |
253 | to or detached from an already running process. */ | |
254 | ||
9a4105ab AC |
255 | void (*deprecated_attach_hook) (void); |
256 | void (*deprecated_detach_hook) (void); | |
6426a772 | 257 | |
c906108c SS |
258 | /* Called during long calculations to allow GUI to repair window damage, and to |
259 | check for stop buttons, etc... */ | |
260 | ||
9a4105ab | 261 | void (*deprecated_interactive_hook) (void); |
c906108c SS |
262 | |
263 | /* Called when the registers have changed, as a hint to a GUI | |
264 | to minimize window update. */ | |
265 | ||
9a4105ab | 266 | void (*deprecated_registers_changed_hook) (void); |
c906108c SS |
267 | |
268 | /* Tell the GUI someone changed the register REGNO. -1 means | |
269 | that the caller does not know which register changed or | |
c5aa993b | 270 | that several registers have changed (see value_assign). */ |
9a4105ab | 271 | void (*deprecated_register_changed_hook) (int regno); |
c906108c SS |
272 | |
273 | /* Tell the GUI someone changed LEN bytes of memory at ADDR */ | |
9a4105ab | 274 | void (*deprecated_memory_changed_hook) (CORE_ADDR addr, int len); |
c906108c SS |
275 | |
276 | /* Called when going to wait for the target. Usually allows the GUI to run | |
277 | while waiting for target events. */ | |
278 | ||
9a4105ab AC |
279 | ptid_t (*deprecated_target_wait_hook) (ptid_t ptid, |
280 | struct target_waitstatus * status); | |
c906108c SS |
281 | |
282 | /* Used by UI as a wrapper around command execution. May do various things | |
283 | like enabling/disabling buttons, etc... */ | |
284 | ||
9a4105ab AC |
285 | void (*deprecated_call_command_hook) (struct cmd_list_element * c, char *cmd, |
286 | int from_tty); | |
c906108c | 287 | |
96baa820 JM |
288 | /* Called after a `set' command has finished. Is only run if the |
289 | `set' command succeeded. */ | |
290 | ||
9a4105ab | 291 | void (*deprecated_set_hook) (struct cmd_list_element * c); |
96baa820 | 292 | |
c906108c SS |
293 | /* Called when the current thread changes. Argument is thread id. */ |
294 | ||
9a4105ab | 295 | void (*deprecated_context_hook) (int id); |
c906108c SS |
296 | |
297 | /* Takes control from error (). Typically used to prevent longjmps out of the | |
298 | middle of the GUI. Usually used in conjunction with a catch routine. */ | |
299 | ||
c40d0d10 | 300 | void (*deprecated_error_hook) (void); |
11cf8741 | 301 | |
c906108c SS |
302 | /* Handler for SIGHUP. */ |
303 | ||
304 | #ifdef SIGHUP | |
392a587b | 305 | /* NOTE 1999-04-29: This function will be static again, once we modify |
cd0fc7c3 SS |
306 | gdb to use the event loop as the default command loop and we merge |
307 | event-top.c into this file, top.c */ | |
308 | /* static */ int | |
d0c8cdfb | 309 | quit_cover (void *s) |
c906108c | 310 | { |
c5aa993b JM |
311 | caution = 0; /* Throw caution to the wind -- we're exiting. |
312 | This prevents asking the user dumb questions. */ | |
313 | quit_command ((char *) 0, 0); | |
c906108c SS |
314 | return 0; |
315 | } | |
316 | #endif /* defined SIGHUP */ | |
317 | \f | |
318 | /* Line number we are currently in in a file which is being sourced. */ | |
392a587b | 319 | /* NOTE 1999-04-29: This variable will be static again, once we modify |
cd0fc7c3 SS |
320 | gdb to use the event loop as the default command loop and we merge |
321 | event-top.c into this file, top.c */ | |
322 | /* static */ int source_line_number; | |
c906108c SS |
323 | |
324 | /* Name of the file we are sourcing. */ | |
392a587b | 325 | /* NOTE 1999-04-29: This variable will be static again, once we modify |
cd0fc7c3 SS |
326 | gdb to use the event loop as the default command loop and we merge |
327 | event-top.c into this file, top.c */ | |
328 | /* static */ char *source_file_name; | |
c906108c | 329 | |
c906108c SS |
330 | /* Clean up on error during a "source" command (or execution of a |
331 | user-defined command). */ | |
332 | ||
d318976c | 333 | void |
e41a3b1a | 334 | do_restore_instream_cleanup (void *stream) |
c906108c SS |
335 | { |
336 | /* Restore the previous input stream. */ | |
337 | instream = stream; | |
338 | } | |
339 | ||
340 | /* Read commands from STREAM. */ | |
341 | void | |
fba45db2 | 342 | read_command_file (FILE *stream) |
c906108c SS |
343 | { |
344 | struct cleanup *cleanups; | |
345 | ||
e41a3b1a | 346 | cleanups = make_cleanup (do_restore_instream_cleanup, instream); |
c906108c | 347 | instream = stream; |
c5aa993b | 348 | command_loop (); |
c906108c SS |
349 | do_cleanups (cleanups); |
350 | } | |
351 | \f | |
507f3c78 | 352 | void (*pre_init_ui_hook) (void); |
c906108c | 353 | |
e41a3b1a AC |
354 | #ifdef __MSDOS__ |
355 | void | |
356 | do_chdir_cleanup (void *old_dir) | |
357 | { | |
358 | chdir (old_dir); | |
b8c9b27d | 359 | xfree (old_dir); |
e41a3b1a AC |
360 | } |
361 | #endif | |
362 | ||
d318976c FN |
363 | /* Execute the line P as a command. |
364 | Pass FROM_TTY as second argument to the defining function. */ | |
c906108c | 365 | |
d318976c FN |
366 | void |
367 | execute_command (char *p, int from_tty) | |
c906108c | 368 | { |
52f0bd74 AC |
369 | struct cmd_list_element *c; |
370 | enum language flang; | |
d318976c FN |
371 | static int warned = 0; |
372 | char *line; | |
67e1e03a | 373 | |
d318976c | 374 | free_all_values (); |
c906108c | 375 | |
d318976c FN |
376 | /* Force cleanup of any alloca areas if using C alloca instead of |
377 | a builtin alloca. */ | |
378 | alloca (0); | |
c906108c | 379 | |
d318976c FN |
380 | /* This can happen when command_line_input hits end of file. */ |
381 | if (p == NULL) | |
382 | return; | |
c906108c | 383 | |
d318976c | 384 | serial_log_command (p); |
8b93c638 | 385 | |
d318976c FN |
386 | while (*p == ' ' || *p == '\t') |
387 | p++; | |
388 | if (*p) | |
8b93c638 | 389 | { |
d318976c FN |
390 | char *arg; |
391 | line = p; | |
8b93c638 | 392 | |
d318976c | 393 | c = lookup_cmd (&p, cmdlist, "", 0, 1); |
8b93c638 | 394 | |
d318976c FN |
395 | /* If the target is running, we allow only a limited set of |
396 | commands. */ | |
362646f5 | 397 | if (target_can_async_p () && target_executing) |
d8fe84e3 EZ |
398 | if (strcmp (c->name, "help") != 0 |
399 | && strcmp (c->name, "pwd") != 0 | |
400 | && strcmp (c->name, "show") != 0 | |
401 | && strcmp (c->name, "stop") != 0) | |
8a3fe4f8 | 402 | error (_("Cannot execute this command while the target is running.")); |
8b93c638 | 403 | |
d318976c FN |
404 | /* Pass null arg rather than an empty one. */ |
405 | arg = *p ? p : 0; | |
8b93c638 | 406 | |
9f60d481 AC |
407 | /* FIXME: cagney/2002-02-02: The c->type test is pretty dodgy |
408 | while the is_complete_command(cfunc) test is just plain | |
409 | bogus. They should both be replaced by a test of the form | |
410 | c->strip_trailing_white_space_p. */ | |
411 | /* NOTE: cagney/2002-02-02: The function.cfunc in the below | |
412 | can't be replaced with func. This is because it is the | |
413 | cfunc, and not the func, that has the value that the | |
414 | is_complete_command hack is testing for. */ | |
415 | /* Clear off trailing whitespace, except for set and complete | |
416 | command. */ | |
d318976c FN |
417 | if (arg |
418 | && c->type != set_cmd | |
bbaca940 | 419 | && !is_complete_command (c)) |
8b93c638 | 420 | { |
d318976c FN |
421 | p = arg + strlen (arg) - 1; |
422 | while (p >= arg && (*p == ' ' || *p == '\t')) | |
423 | p--; | |
424 | *(p + 1) = '\0'; | |
8b93c638 JM |
425 | } |
426 | ||
d318976c | 427 | /* If this command has been pre-hooked, run the hook first. */ |
5913bcb0 | 428 | execute_cmd_pre_hook (c); |
c906108c | 429 | |
d318976c FN |
430 | if (c->flags & DEPRECATED_WARN_USER) |
431 | deprecated_cmd_warning (&line); | |
c906108c | 432 | |
d318976c FN |
433 | if (c->class == class_user) |
434 | execute_user_command (c, arg); | |
435 | else if (c->type == set_cmd || c->type == show_cmd) | |
436 | do_setshow_command (arg, from_tty & caution, c); | |
f436dd25 | 437 | else if (!cmd_func_p (c)) |
8a3fe4f8 | 438 | error (_("That is not a command, just a help topic.")); |
9a4105ab AC |
439 | else if (deprecated_call_command_hook) |
440 | deprecated_call_command_hook (c, arg, from_tty & caution); | |
d318976c | 441 | else |
f436dd25 | 442 | cmd_func (c, arg, from_tty & caution); |
d318976c FN |
443 | |
444 | /* If this command has been post-hooked, run the hook last. */ | |
5913bcb0 | 445 | execute_cmd_post_hook (c); |
c906108c | 446 | |
c906108c SS |
447 | } |
448 | ||
d318976c FN |
449 | /* Tell the user if the language has changed (except first time). */ |
450 | if (current_language != expected_language) | |
c906108c | 451 | { |
d318976c | 452 | if (language_mode == language_mode_auto) |
c906108c | 453 | { |
d318976c | 454 | language_info (1); /* Print what changed. */ |
c906108c | 455 | } |
d318976c | 456 | warned = 0; |
c906108c SS |
457 | } |
458 | ||
d318976c FN |
459 | /* Warn the user if the working language does not match the |
460 | language of the current frame. Only warn the user if we are | |
461 | actually running the program, i.e. there is a stack. */ | |
462 | /* FIXME: This should be cacheing the frame and only running when | |
463 | the frame changes. */ | |
464 | ||
465 | if (target_has_stack) | |
c906108c | 466 | { |
d318976c FN |
467 | flang = get_frame_language (); |
468 | if (!warned | |
469 | && flang != language_unknown | |
470 | && flang != current_language->la_language) | |
c906108c | 471 | { |
d318976c FN |
472 | printf_filtered ("%s\n", lang_frame_mismatch_warn); |
473 | warned = 1; | |
c906108c | 474 | } |
c906108c SS |
475 | } |
476 | } | |
477 | ||
d318976c FN |
478 | /* Read commands from `instream' and execute them |
479 | until end of file or error reading instream. */ | |
c906108c | 480 | |
d318976c FN |
481 | void |
482 | command_loop (void) | |
c906108c | 483 | { |
d318976c FN |
484 | struct cleanup *old_chain; |
485 | char *command; | |
486 | int stdin_is_tty = ISATTY (stdin); | |
487 | long time_at_cmd_start; | |
488 | #ifdef HAVE_SBRK | |
489 | long space_at_cmd_start = 0; | |
490 | #endif | |
491 | extern int display_time; | |
492 | extern int display_space; | |
c5aa993b | 493 | |
d318976c FN |
494 | while (instream && !feof (instream)) |
495 | { | |
d318976c FN |
496 | if (window_hook && instream == stdin) |
497 | (*window_hook) (instream, get_prompt ()); | |
c906108c | 498 | |
d318976c FN |
499 | quit_flag = 0; |
500 | if (instream == stdin && stdin_is_tty) | |
501 | reinitialize_more_filter (); | |
502 | old_chain = make_cleanup (null_cleanup, 0); | |
c906108c | 503 | |
d318976c FN |
504 | /* Get a command-line. This calls the readline package. */ |
505 | command = command_line_input (instream == stdin ? | |
506 | get_prompt () : (char *) NULL, | |
507 | instream == stdin, "prompt"); | |
d318976c FN |
508 | if (command == 0) |
509 | return; | |
c906108c | 510 | |
d318976c | 511 | time_at_cmd_start = get_run_time (); |
c906108c | 512 | |
d318976c | 513 | if (display_space) |
9e0b60a8 | 514 | { |
d318976c | 515 | #ifdef HAVE_SBRK |
d318976c | 516 | char *lim = (char *) sbrk (0); |
6dd77b81 | 517 | space_at_cmd_start = lim - lim_at_start; |
9e0b60a8 | 518 | #endif |
d318976c | 519 | } |
9e0b60a8 | 520 | |
d318976c FN |
521 | execute_command (command, instream == stdin); |
522 | /* Do any commands attached to breakpoint we stopped at. */ | |
523 | bpstat_do_actions (&stop_bpstat); | |
524 | do_cleanups (old_chain); | |
9e0b60a8 | 525 | |
d318976c | 526 | if (display_time) |
9e0b60a8 | 527 | { |
d318976c | 528 | long cmd_time = get_run_time () - time_at_cmd_start; |
9e0b60a8 | 529 | |
a3f17187 | 530 | printf_unfiltered (_("Command execution time: %ld.%06ld\n"), |
d318976c | 531 | cmd_time / 1000000, cmd_time % 1000000); |
9e0b60a8 | 532 | } |
9e0b60a8 | 533 | |
d318976c | 534 | if (display_space) |
9e0b60a8 | 535 | { |
d318976c | 536 | #ifdef HAVE_SBRK |
d318976c | 537 | char *lim = (char *) sbrk (0); |
6dd77b81 | 538 | long space_now = lim - lim_at_start; |
d318976c FN |
539 | long space_diff = space_now - space_at_cmd_start; |
540 | ||
a3f17187 | 541 | printf_unfiltered (_("Space used: %ld (%c%ld for this command)\n"), |
d318976c FN |
542 | space_now, |
543 | (space_diff >= 0 ? '+' : '-'), | |
544 | space_diff); | |
545 | #endif | |
9e0b60a8 | 546 | } |
9e0b60a8 | 547 | } |
9e0b60a8 | 548 | } |
9e0b60a8 | 549 | |
d318976c FN |
550 | /* Read commands from `instream' and execute them until end of file or |
551 | error reading instream. This command loop doesnt care about any | |
552 | such things as displaying time and space usage. If the user asks | |
553 | for those, they won't work. */ | |
554 | void | |
555 | simplified_command_loop (char *(*read_input_func) (char *), | |
556 | void (*execute_command_func) (char *, int)) | |
9e0b60a8 | 557 | { |
d318976c FN |
558 | struct cleanup *old_chain; |
559 | char *command; | |
560 | int stdin_is_tty = ISATTY (stdin); | |
9e0b60a8 | 561 | |
d318976c | 562 | while (instream && !feof (instream)) |
9e0b60a8 | 563 | { |
d318976c FN |
564 | quit_flag = 0; |
565 | if (instream == stdin && stdin_is_tty) | |
566 | reinitialize_more_filter (); | |
567 | old_chain = make_cleanup (null_cleanup, 0); | |
568 | ||
569 | /* Get a command-line. */ | |
570 | command = (*read_input_func) (instream == stdin ? | |
571 | get_prompt () : (char *) NULL); | |
9e0b60a8 | 572 | |
d318976c FN |
573 | if (command == 0) |
574 | return; | |
9e0b60a8 | 575 | |
d318976c | 576 | (*execute_command_func) (command, instream == stdin); |
9e0b60a8 | 577 | |
d318976c FN |
578 | /* Do any commands attached to breakpoint we stopped at. */ |
579 | bpstat_do_actions (&stop_bpstat); | |
9e0b60a8 | 580 | |
d318976c | 581 | do_cleanups (old_chain); |
c5aa993b | 582 | } |
9e0b60a8 | 583 | } |
d318976c FN |
584 | \f |
585 | /* Commands call this if they do not want to be repeated by null lines. */ | |
9e0b60a8 | 586 | |
d318976c FN |
587 | void |
588 | dont_repeat (void) | |
9e0b60a8 | 589 | { |
d318976c FN |
590 | if (server_command) |
591 | return; | |
9e0b60a8 | 592 | |
d318976c FN |
593 | /* If we aren't reading from standard input, we are saving the last |
594 | thing read from stdin in line and don't want to delete it. Null lines | |
595 | won't repeat here in any case. */ | |
596 | if (instream == stdin) | |
597 | *line = 0; | |
9e0b60a8 | 598 | } |
d318976c FN |
599 | \f |
600 | /* Read a line from the stream "instream" without command line editing. | |
9e0b60a8 | 601 | |
d318976c FN |
602 | It prints PROMPT_ARG once at the start. |
603 | Action is compatible with "readline", e.g. space for the result is | |
604 | malloc'd and should be freed by the caller. | |
9e0b60a8 | 605 | |
d318976c FN |
606 | A NULL return means end of file. */ |
607 | char * | |
608 | gdb_readline (char *prompt_arg) | |
9e0b60a8 | 609 | { |
d318976c FN |
610 | int c; |
611 | char *result; | |
612 | int input_index = 0; | |
613 | int result_size = 80; | |
9e0b60a8 | 614 | |
d318976c | 615 | if (prompt_arg) |
9e0b60a8 | 616 | { |
d318976c FN |
617 | /* Don't use a _filtered function here. It causes the assumed |
618 | character position to be off, since the newline we read from | |
619 | the user is not accounted for. */ | |
620 | fputs_unfiltered (prompt_arg, gdb_stdout); | |
9e0b60a8 JM |
621 | gdb_flush (gdb_stdout); |
622 | } | |
623 | ||
d318976c | 624 | result = (char *) xmalloc (result_size); |
9e0b60a8 JM |
625 | |
626 | while (1) | |
627 | { | |
d318976c FN |
628 | /* Read from stdin if we are executing a user defined command. |
629 | This is the right thing for prompt_for_continue, at least. */ | |
630 | c = fgetc (instream ? instream : stdin); | |
9e0b60a8 | 631 | |
d318976c | 632 | if (c == EOF) |
9e0b60a8 | 633 | { |
d318976c FN |
634 | if (input_index > 0) |
635 | /* The last line does not end with a newline. Return it, and | |
636 | if we are called again fgetc will still return EOF and | |
637 | we'll return NULL then. */ | |
9e0b60a8 | 638 | break; |
b8c9b27d | 639 | xfree (result); |
d318976c | 640 | return NULL; |
9e0b60a8 | 641 | } |
c5aa993b | 642 | |
d318976c | 643 | if (c == '\n') |
9e0b60a8 | 644 | { |
d318976c FN |
645 | if (input_index > 0 && result[input_index - 1] == '\r') |
646 | input_index--; | |
647 | break; | |
9e0b60a8 | 648 | } |
9e0b60a8 | 649 | |
d318976c FN |
650 | result[input_index++] = c; |
651 | while (input_index >= result_size) | |
9e0b60a8 | 652 | { |
d318976c FN |
653 | result_size *= 2; |
654 | result = (char *) xrealloc (result, result_size); | |
9e0b60a8 | 655 | } |
9e0b60a8 JM |
656 | } |
657 | ||
d318976c FN |
658 | result[input_index++] = '\0'; |
659 | return result; | |
9e0b60a8 JM |
660 | } |
661 | ||
d318976c FN |
662 | /* Variables which control command line editing and history |
663 | substitution. These variables are given default values at the end | |
664 | of this file. */ | |
665 | static int command_editing_p; | |
920d2a44 | 666 | |
d318976c FN |
667 | /* NOTE 1999-04-29: This variable will be static again, once we modify |
668 | gdb to use the event loop as the default command loop and we merge | |
669 | event-top.c into this file, top.c */ | |
920d2a44 | 670 | |
d318976c | 671 | /* static */ int history_expansion_p; |
920d2a44 | 672 | |
d318976c | 673 | static int write_history_p; |
920d2a44 AC |
674 | static void |
675 | show_write_history_p (struct ui_file *file, int from_tty, | |
676 | struct cmd_list_element *c, const char *value) | |
677 | { | |
678 | fprintf_filtered (file, _("Saving of the history record on exit is %s.\n"), | |
679 | value); | |
680 | } | |
681 | ||
d318976c | 682 | static int history_size; |
920d2a44 AC |
683 | static void |
684 | show_history_size (struct ui_file *file, int from_tty, | |
685 | struct cmd_list_element *c, const char *value) | |
686 | { | |
687 | fprintf_filtered (file, _("The size of the command history is %s.\n"), | |
688 | value); | |
689 | } | |
690 | ||
d318976c | 691 | static char *history_filename; |
920d2a44 AC |
692 | static void |
693 | show_history_filename (struct ui_file *file, int from_tty, | |
694 | struct cmd_list_element *c, const char *value) | |
695 | { | |
696 | fprintf_filtered (file, _("\ | |
697 | The filename in which to record the command history is \"%s\".\n"), | |
698 | value); | |
699 | } | |
9e0b60a8 | 700 | |
b4f5539f TT |
701 | /* This is like readline(), but it has some gdb-specific behavior. |
702 | gdb can use readline in both the synchronous and async modes during | |
703 | a single gdb invocation. At the ordinary top-level prompt we might | |
704 | be using the async readline. That means we can't use | |
705 | rl_pre_input_hook, since it doesn't work properly in async mode. | |
706 | However, for a secondary prompt (" >", such as occurs during a | |
707 | `define'), gdb just calls readline() directly, running it in | |
708 | synchronous mode. So for operate-and-get-next to work in this | |
709 | situation, we have to switch the hooks around. That is what | |
710 | gdb_readline_wrapper is for. */ | |
711 | char * | |
712 | gdb_readline_wrapper (char *prompt) | |
713 | { | |
714 | /* Set the hook that works in this case. */ | |
362646f5 | 715 | if (after_char_processing_hook) |
b4f5539f TT |
716 | { |
717 | rl_pre_input_hook = (Function *) after_char_processing_hook; | |
718 | after_char_processing_hook = NULL; | |
719 | } | |
720 | ||
721 | return readline (prompt); | |
722 | } | |
723 | ||
9e0b60a8 | 724 | \f |
d318976c FN |
725 | #ifdef STOP_SIGNAL |
726 | static void | |
727 | stop_sig (int signo) | |
9e0b60a8 | 728 | { |
d318976c FN |
729 | #if STOP_SIGNAL == SIGTSTP |
730 | signal (SIGTSTP, SIG_DFL); | |
46711df8 MK |
731 | #if HAVE_SIGPROCMASK |
732 | { | |
733 | sigset_t zero; | |
734 | ||
735 | sigemptyset (&zero); | |
736 | sigprocmask (SIG_SETMASK, &zero, 0); | |
737 | } | |
738 | #elif HAVE_SIGSETMASK | |
d318976c | 739 | sigsetmask (0); |
46711df8 | 740 | #endif |
d318976c FN |
741 | kill (getpid (), SIGTSTP); |
742 | signal (SIGTSTP, stop_sig); | |
743 | #else | |
744 | signal (STOP_SIGNAL, stop_sig); | |
745 | #endif | |
746 | printf_unfiltered ("%s", get_prompt ()); | |
747 | gdb_flush (gdb_stdout); | |
9e0b60a8 | 748 | |
d318976c FN |
749 | /* Forget about any previous command -- null line now will do nothing. */ |
750 | dont_repeat (); | |
9e0b60a8 | 751 | } |
d318976c | 752 | #endif /* STOP_SIGNAL */ |
9e0b60a8 | 753 | |
d318976c | 754 | /* Initialize signal handlers. */ |
64cdedad EZ |
755 | static void |
756 | float_handler (int signo) | |
757 | { | |
758 | /* This message is based on ANSI C, section 4.7. Note that integer | |
759 | divide by zero causes this, so "float" is a misnomer. */ | |
760 | signal (SIGFPE, float_handler); | |
8a3fe4f8 | 761 | error (_("Erroneous arithmetic operation.")); |
64cdedad EZ |
762 | } |
763 | ||
9e0b60a8 | 764 | static void |
d318976c | 765 | do_nothing (int signo) |
9e0b60a8 | 766 | { |
d318976c FN |
767 | /* Under System V the default disposition of a signal is reinstated after |
768 | the signal is caught and delivered to an application process. On such | |
769 | systems one must restore the replacement signal handler if one wishes | |
770 | to continue handling the signal in one's program. On BSD systems this | |
771 | is not needed but it is harmless, and it simplifies the code to just do | |
772 | it unconditionally. */ | |
773 | signal (signo, do_nothing); | |
9e0b60a8 JM |
774 | } |
775 | ||
467d8519 TT |
776 | /* The current saved history number from operate-and-get-next. |
777 | This is -1 if not valid. */ | |
778 | static int operate_saved_history = -1; | |
779 | ||
780 | /* This is put on the appropriate hook and helps operate-and-get-next | |
781 | do its work. */ | |
b9362cc7 | 782 | static void |
5ae5f592 | 783 | gdb_rl_operate_and_get_next_completion (void) |
467d8519 TT |
784 | { |
785 | int delta = where_history () - operate_saved_history; | |
786 | /* The `key' argument to rl_get_previous_history is ignored. */ | |
787 | rl_get_previous_history (delta, 0); | |
788 | operate_saved_history = -1; | |
789 | ||
790 | /* readline doesn't automatically update the display for us. */ | |
791 | rl_redisplay (); | |
792 | ||
793 | after_char_processing_hook = NULL; | |
794 | rl_pre_input_hook = NULL; | |
795 | } | |
796 | ||
797 | /* This is a gdb-local readline command handler. It accepts the | |
798 | current command line (like RET does) and, if this command was taken | |
799 | from the history, arranges for the next command in the history to | |
800 | appear on the command line when the prompt returns. | |
801 | We ignore the arguments. */ | |
802 | static int | |
803 | gdb_rl_operate_and_get_next (int count, int key) | |
804 | { | |
b5686e99 MK |
805 | int where; |
806 | ||
362646f5 AC |
807 | /* Use the async hook. */ |
808 | after_char_processing_hook = gdb_rl_operate_and_get_next_completion; | |
467d8519 | 809 | |
b5686e99 MK |
810 | /* Find the current line, and find the next line to use. */ |
811 | where = where_history(); | |
812 | ||
813 | /* FIXME: kettenis/20020817: max_input_history is renamed into | |
814 | history_max_entries in readline-4.2. When we do a new readline | |
815 | import, we should probably change it here too, even though | |
816 | readline maintains backwards compatibility for now by still | |
817 | defining max_input_history. */ | |
818 | if ((history_is_stifled () && (history_length >= max_input_history)) || | |
819 | (where >= history_length - 1)) | |
820 | operate_saved_history = where; | |
821 | else | |
822 | operate_saved_history = where + 1; | |
823 | ||
467d8519 TT |
824 | return rl_newline (1, key); |
825 | } | |
826 | \f | |
d318976c FN |
827 | /* Read one line from the command input stream `instream' |
828 | into the local static buffer `linebuffer' (whose current length | |
829 | is `linelength'). | |
830 | The buffer is made bigger as necessary. | |
831 | Returns the address of the start of the line. | |
9e0b60a8 | 832 | |
d318976c | 833 | NULL is returned for end of file. |
9e0b60a8 | 834 | |
d318976c FN |
835 | *If* the instream == stdin & stdin is a terminal, the line read |
836 | is copied into the file line saver (global var char *line, | |
837 | length linesize) so that it can be duplicated. | |
9e0b60a8 | 838 | |
d318976c FN |
839 | This routine either uses fancy command line editing or |
840 | simple input as the user has requested. */ | |
10689f25 | 841 | |
d318976c FN |
842 | char * |
843 | command_line_input (char *prompt_arg, int repeat, char *annotation_suffix) | |
9e0b60a8 | 844 | { |
d318976c FN |
845 | static char *linebuffer = 0; |
846 | static unsigned linelength = 0; | |
52f0bd74 | 847 | char *p; |
d318976c FN |
848 | char *p1; |
849 | char *rl; | |
850 | char *local_prompt = prompt_arg; | |
851 | char *nline; | |
852 | char got_eof = 0; | |
853 | ||
854 | /* The annotation suffix must be non-NULL. */ | |
855 | if (annotation_suffix == NULL) | |
856 | annotation_suffix = ""; | |
9e0b60a8 | 857 | |
d318976c FN |
858 | if (annotation_level > 1 && instream == stdin) |
859 | { | |
860 | local_prompt = alloca ((prompt_arg == NULL ? 0 : strlen (prompt_arg)) | |
861 | + strlen (annotation_suffix) + 40); | |
862 | if (prompt_arg == NULL) | |
863 | local_prompt[0] = '\0'; | |
864 | else | |
865 | strcpy (local_prompt, prompt_arg); | |
866 | strcat (local_prompt, "\n\032\032"); | |
867 | strcat (local_prompt, annotation_suffix); | |
868 | strcat (local_prompt, "\n"); | |
869 | } | |
9e0b60a8 | 870 | |
d318976c | 871 | if (linebuffer == 0) |
9e0b60a8 | 872 | { |
d318976c FN |
873 | linelength = 80; |
874 | linebuffer = (char *) xmalloc (linelength); | |
9e0b60a8 | 875 | } |
9e0b60a8 | 876 | |
d318976c | 877 | p = linebuffer; |
9e0b60a8 | 878 | |
d318976c FN |
879 | /* Control-C quits instantly if typed while in this loop |
880 | since it should not wait until the user types a newline. */ | |
881 | immediate_quit++; | |
882 | #ifdef STOP_SIGNAL | |
883 | if (job_control) | |
362646f5 | 884 | signal (STOP_SIGNAL, handle_stop_sig); |
d318976c FN |
885 | #endif |
886 | ||
887 | while (1) | |
9e0b60a8 | 888 | { |
d318976c FN |
889 | /* Make sure that all output has been output. Some machines may let |
890 | you get away with leaving out some of the gdb_flush, but not all. */ | |
891 | wrap_here (""); | |
892 | gdb_flush (gdb_stdout); | |
893 | gdb_flush (gdb_stderr); | |
894 | ||
895 | if (source_file_name != NULL) | |
637537d0 | 896 | ++source_line_number; |
d318976c FN |
897 | |
898 | if (annotation_level > 1 && instream == stdin) | |
899 | { | |
306d9ac5 DC |
900 | puts_unfiltered ("\n\032\032pre-"); |
901 | puts_unfiltered (annotation_suffix); | |
902 | puts_unfiltered ("\n"); | |
d318976c FN |
903 | } |
904 | ||
905 | /* Don't use fancy stuff if not talking to stdin. */ | |
9a4105ab | 906 | if (deprecated_readline_hook && instream == NULL) |
d318976c | 907 | { |
9a4105ab | 908 | rl = (*deprecated_readline_hook) (local_prompt); |
d318976c FN |
909 | } |
910 | else if (command_editing_p && instream == stdin && ISATTY (instream)) | |
911 | { | |
b4f5539f | 912 | rl = gdb_readline_wrapper (local_prompt); |
d318976c | 913 | } |
9e0b60a8 | 914 | else |
d318976c FN |
915 | { |
916 | rl = gdb_readline (local_prompt); | |
917 | } | |
9e0b60a8 | 918 | |
d318976c FN |
919 | if (annotation_level > 1 && instream == stdin) |
920 | { | |
306d9ac5 DC |
921 | puts_unfiltered ("\n\032\032post-"); |
922 | puts_unfiltered (annotation_suffix); | |
923 | puts_unfiltered ("\n"); | |
d318976c | 924 | } |
9e0b60a8 | 925 | |
d318976c | 926 | if (!rl || rl == (char *) EOF) |
9e0b60a8 | 927 | { |
d318976c FN |
928 | got_eof = 1; |
929 | break; | |
9e0b60a8 | 930 | } |
d318976c FN |
931 | if (strlen (rl) + 1 + (p - linebuffer) > linelength) |
932 | { | |
933 | linelength = strlen (rl) + 1 + (p - linebuffer); | |
934 | nline = (char *) xrealloc (linebuffer, linelength); | |
935 | p += nline - linebuffer; | |
936 | linebuffer = nline; | |
937 | } | |
938 | p1 = rl; | |
939 | /* Copy line. Don't copy null at end. (Leaves line alone | |
940 | if this was just a newline) */ | |
941 | while (*p1) | |
942 | *p++ = *p1++; | |
9e0b60a8 | 943 | |
b8c9b27d | 944 | xfree (rl); /* Allocated in readline. */ |
9e0b60a8 | 945 | |
d318976c FN |
946 | if (p == linebuffer || *(p - 1) != '\\') |
947 | break; | |
9e0b60a8 | 948 | |
d318976c FN |
949 | p--; /* Put on top of '\'. */ |
950 | local_prompt = (char *) 0; | |
951 | } | |
9e0b60a8 | 952 | |
d318976c FN |
953 | #ifdef STOP_SIGNAL |
954 | if (job_control) | |
955 | signal (STOP_SIGNAL, SIG_DFL); | |
956 | #endif | |
957 | immediate_quit--; | |
9e0b60a8 | 958 | |
d318976c FN |
959 | if (got_eof) |
960 | return NULL; | |
9e0b60a8 | 961 | |
d318976c FN |
962 | #define SERVER_COMMAND_LENGTH 7 |
963 | server_command = | |
964 | (p - linebuffer > SERVER_COMMAND_LENGTH) | |
bf896cb0 | 965 | && strncmp (linebuffer, "server ", SERVER_COMMAND_LENGTH) == 0; |
d318976c | 966 | if (server_command) |
9e0b60a8 | 967 | { |
d318976c FN |
968 | /* Note that we don't set `line'. Between this and the check in |
969 | dont_repeat, this insures that repeating will still do the | |
970 | right thing. */ | |
971 | *p = '\0'; | |
972 | return linebuffer + SERVER_COMMAND_LENGTH; | |
9e0b60a8 | 973 | } |
9e0b60a8 | 974 | |
d318976c FN |
975 | /* Do history expansion if that is wished. */ |
976 | if (history_expansion_p && instream == stdin | |
977 | && ISATTY (instream)) | |
978 | { | |
979 | char *history_value; | |
980 | int expanded; | |
9e0b60a8 | 981 | |
d318976c FN |
982 | *p = '\0'; /* Insert null now. */ |
983 | expanded = history_expand (linebuffer, &history_value); | |
984 | if (expanded) | |
985 | { | |
986 | /* Print the changes. */ | |
987 | printf_unfiltered ("%s\n", history_value); | |
9e0b60a8 | 988 | |
d318976c FN |
989 | /* If there was an error, call this function again. */ |
990 | if (expanded < 0) | |
991 | { | |
b8c9b27d | 992 | xfree (history_value); |
d318976c FN |
993 | return command_line_input (prompt_arg, repeat, annotation_suffix); |
994 | } | |
995 | if (strlen (history_value) > linelength) | |
996 | { | |
997 | linelength = strlen (history_value) + 1; | |
998 | linebuffer = (char *) xrealloc (linebuffer, linelength); | |
999 | } | |
1000 | strcpy (linebuffer, history_value); | |
1001 | p = linebuffer + strlen (linebuffer); | |
b8c9b27d | 1002 | xfree (history_value); |
d318976c FN |
1003 | } |
1004 | } | |
9e0b60a8 | 1005 | |
d318976c FN |
1006 | /* If we just got an empty line, and that is supposed |
1007 | to repeat the previous command, return the value in the | |
1008 | global buffer. */ | |
1009 | if (repeat && p == linebuffer) | |
1010 | return line; | |
1011 | for (p1 = linebuffer; *p1 == ' ' || *p1 == '\t'; p1++); | |
1012 | if (repeat && !*p1) | |
1013 | return line; | |
9e0b60a8 | 1014 | |
d318976c | 1015 | *p = 0; |
9e0b60a8 | 1016 | |
d318976c FN |
1017 | /* Add line to history if appropriate. */ |
1018 | if (instream == stdin | |
1019 | && ISATTY (stdin) && *linebuffer) | |
1020 | add_history (linebuffer); | |
9e0b60a8 | 1021 | |
d318976c FN |
1022 | /* Note: lines consisting solely of comments are added to the command |
1023 | history. This is useful when you type a command, and then | |
1024 | realize you don't want to execute it quite yet. You can comment | |
1025 | out the command and then later fetch it from the value history | |
1026 | and remove the '#'. The kill ring is probably better, but some | |
1027 | people are in the habit of commenting things out. */ | |
1028 | if (*p1 == '#') | |
1029 | *p1 = '\0'; /* Found a comment. */ | |
9e0b60a8 | 1030 | |
d318976c FN |
1031 | /* Save into global buffer if appropriate. */ |
1032 | if (repeat) | |
1033 | { | |
1034 | if (linelength > linesize) | |
1035 | { | |
1036 | line = xrealloc (line, linelength); | |
1037 | linesize = linelength; | |
1038 | } | |
1039 | strcpy (line, linebuffer); | |
1040 | return line; | |
1041 | } | |
9e0b60a8 | 1042 | |
d318976c | 1043 | return linebuffer; |
9e0b60a8 JM |
1044 | } |
1045 | \f | |
1046 | /* Print the GDB banner. */ | |
1047 | void | |
fba45db2 | 1048 | print_gdb_version (struct ui_file *stream) |
9e0b60a8 JM |
1049 | { |
1050 | /* From GNU coding standards, first line is meant to be easy for a | |
1051 | program to parse, and is just canonical program name and version | |
1052 | number, which starts after last space. */ | |
1053 | ||
1054 | fprintf_filtered (stream, "GNU gdb %s\n", version); | |
1055 | ||
1056 | /* Second line is a copyright notice. */ | |
1057 | ||
0bc2134e | 1058 | fprintf_filtered (stream, "Copyright 2004 Free Software Foundation, Inc.\n"); |
9e0b60a8 JM |
1059 | |
1060 | /* Following the copyright is a brief statement that the program is | |
1061 | free software, that users are free to copy and change it on | |
1062 | certain conditions, that it is covered by the GNU GPL, and that | |
1063 | there is no warranty. */ | |
1064 | ||
1065 | fprintf_filtered (stream, "\ | |
1066 | GDB is free software, covered by the GNU General Public License, and you are\n\ | |
1067 | welcome to change it and/or distribute copies of it under certain conditions.\n\ | |
1068 | Type \"show copying\" to see the conditions.\n\ | |
1069 | There is absolutely no warranty for GDB. Type \"show warranty\" for details.\n"); | |
1070 | ||
1071 | /* After the required info we print the configuration information. */ | |
1072 | ||
1073 | fprintf_filtered (stream, "This GDB was configured as \""); | |
6314a349 | 1074 | if (strcmp (host_name, target_name) != 0) |
9e0b60a8 JM |
1075 | { |
1076 | fprintf_filtered (stream, "--host=%s --target=%s", host_name, target_name); | |
1077 | } | |
1078 | else | |
1079 | { | |
1080 | fprintf_filtered (stream, "%s", host_name); | |
1081 | } | |
1082 | fprintf_filtered (stream, "\"."); | |
1083 | } | |
9e0b60a8 JM |
1084 | \f |
1085 | /* get_prompt: access method for the GDB prompt string. */ | |
1086 | ||
9e0b60a8 | 1087 | char * |
fba45db2 | 1088 | get_prompt (void) |
9e0b60a8 | 1089 | { |
362646f5 | 1090 | return PROMPT (0); |
9e0b60a8 JM |
1091 | } |
1092 | ||
1093 | void | |
fba45db2 | 1094 | set_prompt (char *s) |
9e0b60a8 JM |
1095 | { |
1096 | /* ??rehrauer: I don't know why this fails, since it looks as though | |
1097 | assignments to prompt are wrapped in calls to savestring... | |
c5aa993b | 1098 | if (prompt != NULL) |
b8c9b27d | 1099 | xfree (prompt); |
c5aa993b | 1100 | */ |
362646f5 | 1101 | PROMPT (0) = savestring (s, strlen (s)); |
9e0b60a8 | 1102 | } |
9e0b60a8 | 1103 | \f |
c5aa993b | 1104 | |
9e0b60a8 JM |
1105 | /* If necessary, make the user confirm that we should quit. Return |
1106 | non-zero if we should quit, zero if we shouldn't. */ | |
1107 | ||
1108 | int | |
fba45db2 | 1109 | quit_confirm (void) |
9e0b60a8 | 1110 | { |
39f77062 | 1111 | if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution) |
9e0b60a8 JM |
1112 | { |
1113 | char *s; | |
1114 | ||
1115 | /* This is something of a hack. But there's no reliable way to | |
c5aa993b JM |
1116 | see if a GUI is running. The `use_windows' variable doesn't |
1117 | cut it. */ | |
9a4105ab | 1118 | if (deprecated_init_ui_hook) |
9e0b60a8 JM |
1119 | s = "A debugging session is active.\nDo you still want to close the debugger?"; |
1120 | else if (attach_flag) | |
1121 | s = "The program is running. Quit anyway (and detach it)? "; | |
1122 | else | |
1123 | s = "The program is running. Exit anyway? "; | |
1124 | ||
306d9ac5 | 1125 | if (!query ("%s", s)) |
9e0b60a8 JM |
1126 | return 0; |
1127 | } | |
1128 | ||
1129 | return 1; | |
1130 | } | |
1131 | ||
b0abbc58 | 1132 | /* Helper routine for quit_force that requires error handling. */ |
9e0b60a8 | 1133 | |
b0abbc58 | 1134 | struct qt_args |
9e0b60a8 | 1135 | { |
b0abbc58 JJ |
1136 | char *args; |
1137 | int from_tty; | |
1138 | }; | |
9e0b60a8 | 1139 | |
b0abbc58 JJ |
1140 | static int |
1141 | quit_target (void *arg) | |
1142 | { | |
1143 | struct qt_args *qt = (struct qt_args *)arg; | |
9e0b60a8 | 1144 | |
39f77062 | 1145 | if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution) |
9e0b60a8 JM |
1146 | { |
1147 | if (attach_flag) | |
b0abbc58 | 1148 | target_detach (qt->args, qt->from_tty); |
9e0b60a8 | 1149 | else |
b0abbc58 | 1150 | target_kill (); |
9e0b60a8 JM |
1151 | } |
1152 | ||
1153 | /* UDI wants this, to kill the TIP. */ | |
f1c07ab0 | 1154 | target_close (¤t_target, 1); |
9e0b60a8 JM |
1155 | |
1156 | /* Save the history information if it is appropriate to do so. */ | |
1157 | if (write_history_p && history_filename) | |
1158 | write_history (history_filename); | |
1159 | ||
c5aa993b | 1160 | do_final_cleanups (ALL_CLEANUPS); /* Do any final cleanups before exiting */ |
9e0b60a8 | 1161 | |
b0abbc58 JJ |
1162 | return 0; |
1163 | } | |
1164 | ||
1165 | /* Quit without asking for confirmation. */ | |
1166 | ||
1167 | void | |
1168 | quit_force (char *args, int from_tty) | |
1169 | { | |
1170 | int exit_code = 0; | |
365c70b1 | 1171 | struct qt_args qt; |
b0abbc58 JJ |
1172 | |
1173 | /* An optional expression may be used to cause gdb to terminate with the | |
1174 | value of that expression. */ | |
1175 | if (args) | |
1176 | { | |
1177 | struct value *val = parse_and_eval (args); | |
1178 | ||
1179 | exit_code = (int) value_as_long (val); | |
1180 | } | |
1181 | ||
365c70b1 JJ |
1182 | qt.args = args; |
1183 | qt.from_tty = from_tty; | |
1184 | ||
b0abbc58 | 1185 | /* We want to handle any quit errors and exit regardless. */ |
365c70b1 | 1186 | catch_errors (quit_target, &qt, |
b0abbc58 JJ |
1187 | "Quitting: ", RETURN_MASK_ALL); |
1188 | ||
9e0b60a8 JM |
1189 | exit (exit_code); |
1190 | } | |
1191 | ||
9e0b60a8 JM |
1192 | /* Returns whether GDB is running on a terminal and whether the user |
1193 | desires that questions be asked of them on that terminal. */ | |
1194 | ||
1195 | int | |
fba45db2 | 1196 | input_from_terminal_p (void) |
9e0b60a8 JM |
1197 | { |
1198 | return gdb_has_a_terminal () && (instream == stdin) & caution; | |
1199 | } | |
1200 | \f | |
9e0b60a8 | 1201 | static void |
fba45db2 | 1202 | dont_repeat_command (char *ignored, int from_tty) |
9e0b60a8 | 1203 | { |
c5aa993b JM |
1204 | *line = 0; /* Can't call dont_repeat here because we're not |
1205 | necessarily reading from stdin. */ | |
9e0b60a8 JM |
1206 | } |
1207 | \f | |
1208 | /* Functions to manipulate command line editing control variables. */ | |
1209 | ||
1210 | /* Number of commands to print in each call to show_commands. */ | |
1211 | #define Hist_print 10 | |
d318976c | 1212 | void |
fba45db2 | 1213 | show_commands (char *args, int from_tty) |
9e0b60a8 JM |
1214 | { |
1215 | /* Index for history commands. Relative to history_base. */ | |
1216 | int offset; | |
1217 | ||
1218 | /* Number of the history entry which we are planning to display next. | |
1219 | Relative to history_base. */ | |
1220 | static int num = 0; | |
1221 | ||
1222 | /* The first command in the history which doesn't exist (i.e. one more | |
1223 | than the number of the last command). Relative to history_base. */ | |
1224 | int hist_len; | |
1225 | ||
9e0b60a8 JM |
1226 | /* Print out some of the commands from the command history. */ |
1227 | /* First determine the length of the history list. */ | |
1228 | hist_len = history_size; | |
1229 | for (offset = 0; offset < history_size; offset++) | |
1230 | { | |
1231 | if (!history_get (history_base + offset)) | |
1232 | { | |
1233 | hist_len = offset; | |
1234 | break; | |
1235 | } | |
1236 | } | |
1237 | ||
1238 | if (args) | |
1239 | { | |
1240 | if (args[0] == '+' && args[1] == '\0') | |
1241 | /* "info editing +" should print from the stored position. */ | |
1242 | ; | |
1243 | else | |
1244 | /* "info editing <exp>" should print around command number <exp>. */ | |
0e828ed1 | 1245 | num = (parse_and_eval_long (args) - history_base) - Hist_print / 2; |
9e0b60a8 JM |
1246 | } |
1247 | /* "show commands" means print the last Hist_print commands. */ | |
1248 | else | |
1249 | { | |
1250 | num = hist_len - Hist_print; | |
1251 | } | |
1252 | ||
1253 | if (num < 0) | |
1254 | num = 0; | |
1255 | ||
1256 | /* If there are at least Hist_print commands, we want to display the last | |
1257 | Hist_print rather than, say, the last 6. */ | |
1258 | if (hist_len - num < Hist_print) | |
1259 | { | |
1260 | num = hist_len - Hist_print; | |
1261 | if (num < 0) | |
1262 | num = 0; | |
1263 | } | |
1264 | ||
1265 | for (offset = num; offset < num + Hist_print && offset < hist_len; offset++) | |
1266 | { | |
1267 | printf_filtered ("%5d %s\n", history_base + offset, | |
c5aa993b | 1268 | (history_get (history_base + offset))->line); |
9e0b60a8 JM |
1269 | } |
1270 | ||
1271 | /* The next command we want to display is the next one that we haven't | |
1272 | displayed yet. */ | |
1273 | num += Hist_print; | |
1274 | ||
1275 | /* If the user repeats this command with return, it should do what | |
1276 | "show commands +" does. This is unnecessary if arg is null, | |
1277 | because "show commands +" is not useful after "show commands". */ | |
1278 | if (from_tty && args) | |
1279 | { | |
1280 | args[0] = '+'; | |
1281 | args[1] = '\0'; | |
1282 | } | |
1283 | } | |
1284 | ||
1285 | /* Called by do_setshow_command. */ | |
9e0b60a8 | 1286 | static void |
fba45db2 | 1287 | set_history_size_command (char *args, int from_tty, struct cmd_list_element *c) |
9e0b60a8 JM |
1288 | { |
1289 | if (history_size == INT_MAX) | |
1290 | unstifle_history (); | |
1291 | else if (history_size >= 0) | |
1292 | stifle_history (history_size); | |
1293 | else | |
1294 | { | |
1295 | history_size = INT_MAX; | |
8a3fe4f8 | 1296 | error (_("History size must be non-negative")); |
9e0b60a8 JM |
1297 | } |
1298 | } | |
1299 | ||
d318976c | 1300 | void |
fba45db2 | 1301 | set_history (char *args, int from_tty) |
9e0b60a8 | 1302 | { |
a3f17187 | 1303 | printf_unfiltered (_("\"set history\" must be followed by the name of a history subcommand.\n")); |
9e0b60a8 JM |
1304 | help_list (sethistlist, "set history ", -1, gdb_stdout); |
1305 | } | |
1306 | ||
d318976c | 1307 | void |
fba45db2 | 1308 | show_history (char *args, int from_tty) |
9e0b60a8 JM |
1309 | { |
1310 | cmd_show_list (showhistlist, from_tty, ""); | |
1311 | } | |
1312 | ||
1313 | int info_verbose = 0; /* Default verbose msgs off */ | |
1314 | ||
1315 | /* Called by do_setshow_command. An elaborate joke. */ | |
d318976c | 1316 | void |
fba45db2 | 1317 | set_verbose (char *args, int from_tty, struct cmd_list_element *c) |
9e0b60a8 JM |
1318 | { |
1319 | char *cmdname = "verbose"; | |
1320 | struct cmd_list_element *showcmd; | |
1321 | ||
1322 | showcmd = lookup_cmd_1 (&cmdname, showlist, NULL, 1); | |
1323 | ||
1324 | if (info_verbose) | |
1325 | { | |
1326 | c->doc = "Set verbose printing of informational messages."; | |
1327 | showcmd->doc = "Show verbose printing of informational messages."; | |
1328 | } | |
1329 | else | |
1330 | { | |
1331 | c->doc = "Set verbosity."; | |
1332 | showcmd->doc = "Show verbosity."; | |
1333 | } | |
1334 | } | |
1335 | ||
9e0b60a8 JM |
1336 | /* Init the history buffer. Note that we are called after the init file(s) |
1337 | * have been read so that the user can change the history file via his | |
1338 | * .gdbinit file (for instance). The GDBHISTFILE environment variable | |
1339 | * overrides all of this. | |
1340 | */ | |
1341 | ||
1342 | void | |
fba45db2 | 1343 | init_history (void) |
9e0b60a8 JM |
1344 | { |
1345 | char *tmpenv; | |
1346 | ||
1347 | tmpenv = getenv ("HISTSIZE"); | |
1348 | if (tmpenv) | |
1349 | history_size = atoi (tmpenv); | |
1350 | else if (!history_size) | |
1351 | history_size = 256; | |
1352 | ||
1353 | stifle_history (history_size); | |
1354 | ||
1355 | tmpenv = getenv ("GDBHISTFILE"); | |
1356 | if (tmpenv) | |
c5aa993b JM |
1357 | history_filename = savestring (tmpenv, strlen (tmpenv)); |
1358 | else if (!history_filename) | |
1359 | { | |
1360 | /* We include the current directory so that if the user changes | |
1361 | directories the file written will be the same as the one | |
1362 | that was read. */ | |
a0b3c4fd | 1363 | #ifdef __MSDOS__ |
eb2f494a AC |
1364 | /* No leading dots in file names are allowed on MSDOS. */ |
1365 | history_filename = concat (current_directory, "/_gdb_history", NULL); | |
a0b3c4fd | 1366 | #else |
c5aa993b | 1367 | history_filename = concat (current_directory, "/.gdb_history", NULL); |
a0b3c4fd | 1368 | #endif |
c5aa993b | 1369 | } |
9e0b60a8 JM |
1370 | read_history (history_filename); |
1371 | } | |
1372 | ||
920d2a44 AC |
1373 | static void |
1374 | show_new_async_prompt (struct ui_file *file, int from_tty, | |
1375 | struct cmd_list_element *c, const char *value) | |
1376 | { | |
1377 | fprintf_filtered (file, _("Gdb's prompt is \"%s\".\n"), value); | |
1378 | } | |
1379 | ||
1380 | static void | |
1381 | show_async_command_editing_p (struct ui_file *file, int from_tty, | |
1382 | struct cmd_list_element *c, const char *value) | |
1383 | { | |
1384 | fprintf_filtered (file, _("\ | |
1385 | Editing of command lines as they are typed is %s.\n"), | |
1386 | value); | |
1387 | } | |
1388 | ||
1389 | static void | |
1390 | show_annotation_level (struct ui_file *file, int from_tty, | |
1391 | struct cmd_list_element *c, const char *value) | |
1392 | { | |
1393 | fprintf_filtered (file, _("Annotation_level is %s.\n"), value); | |
1394 | } | |
1395 | ||
1396 | static void | |
1397 | show_exec_done_display_p (struct ui_file *file, int from_tty, | |
1398 | struct cmd_list_element *c, const char *value) | |
1399 | { | |
1400 | fprintf_filtered (file, _("\ | |
1401 | Notification of completion for asynchronous execution commands is %s.\n"), | |
1402 | value); | |
1403 | } | |
9e0b60a8 | 1404 | static void |
fba45db2 | 1405 | init_main (void) |
9e0b60a8 JM |
1406 | { |
1407 | struct cmd_list_element *c; | |
1408 | ||
362646f5 AC |
1409 | /* initialize the prompt stack to a simple "(gdb) " prompt or to |
1410 | whatever the DEFAULT_PROMPT is. */ | |
1411 | the_prompts.top = 0; | |
1412 | PREFIX (0) = ""; | |
1413 | PROMPT (0) = savestring (DEFAULT_PROMPT, strlen (DEFAULT_PROMPT)); | |
1414 | SUFFIX (0) = ""; | |
1415 | /* Set things up for annotation_level > 1, if the user ever decides | |
1416 | to use it. */ | |
1417 | async_annotation_suffix = "prompt"; | |
1418 | /* Set the variable associated with the setshow prompt command. */ | |
1419 | new_async_prompt = savestring (PROMPT (0), strlen (PROMPT (0))); | |
1420 | ||
1421 | /* If gdb was started with --annotate=2, this is equivalent to the | |
1422 | user entering the command 'set annotate 2' at the gdb prompt, so | |
1423 | we need to do extra processing. */ | |
1424 | if (annotation_level > 1) | |
1425 | set_async_annotation_level (NULL, 0, NULL); | |
9e0b60a8 JM |
1426 | |
1427 | /* Set the important stuff up for command editing. */ | |
1428 | command_editing_p = 1; | |
9e0b60a8 JM |
1429 | history_expansion_p = 0; |
1430 | write_history_p = 0; | |
1431 | ||
1432 | /* Setup important stuff for command line editing. */ | |
38017ce8 | 1433 | rl_completion_entry_function = readline_line_completion_function; |
51065942 | 1434 | rl_completer_word_break_characters = default_word_break_characters (); |
d318976c | 1435 | rl_completer_quote_characters = get_gdb_completer_quote_characters (); |
9e0b60a8 | 1436 | rl_readline_name = "gdb"; |
7cb3ec5e | 1437 | rl_terminal_name = getenv ("TERM"); |
9e0b60a8 | 1438 | |
467d8519 TT |
1439 | /* The name for this defun comes from Bash, where it originated. |
1440 | 15 is Control-o, the same binding this function has in Bash. */ | |
1441 | rl_add_defun ("operate-and-get-next", gdb_rl_operate_and_get_next, 15); | |
1442 | ||
4d28ad1e AC |
1443 | add_setshow_string_cmd ("prompt", class_support, |
1444 | &new_async_prompt, _("\ | |
1445 | Set gdb's prompt"), _("\ | |
1446 | Show gdb's prompt"), NULL, | |
1447 | set_async_prompt, | |
920d2a44 | 1448 | show_new_async_prompt, |
4d28ad1e | 1449 | &setlist, &showlist); |
9e0b60a8 | 1450 | |
1bedd215 AC |
1451 | add_com ("dont-repeat", class_support, dont_repeat_command, _("\ |
1452 | Don't repeat this command.\n\ | |
9e0b60a8 | 1453 | Primarily used inside of user-defined commands that should not be repeated when\n\ |
1bedd215 | 1454 | hitting return.")); |
9e0b60a8 | 1455 | |
5bf193a2 AC |
1456 | add_setshow_boolean_cmd ("editing", class_support, |
1457 | &async_command_editing_p, _("\ | |
1458 | Set editing of command lines as they are typed."), _("\ | |
1459 | Show editing of command lines as they are typed."), _("\ | |
9e0b60a8 JM |
1460 | Use \"on\" to enable the editing, and \"off\" to disable it.\n\ |
1461 | Without an argument, command line editing is enabled. To edit, use\n\ | |
5bf193a2 AC |
1462 | EMACS-like or VI-like commands like control-P or ESC."), |
1463 | set_async_editing_command, | |
920d2a44 | 1464 | show_async_command_editing_p, |
5bf193a2 AC |
1465 | &setlist, &showlist); |
1466 | ||
1467 | add_setshow_boolean_cmd ("save", no_class, &write_history_p, _("\ | |
1468 | Set saving of the history record on exit."), _("\ | |
1469 | Show saving of the history record on exit."), _("\ | |
9e0b60a8 | 1470 | Use \"on\" to enable the saving, and \"off\" to disable it.\n\ |
5bf193a2 AC |
1471 | Without an argument, saving is enabled."), |
1472 | NULL, | |
920d2a44 | 1473 | show_write_history_p, |
5bf193a2 | 1474 | &sethistlist, &showhistlist); |
9e0b60a8 | 1475 | |
4d28ad1e AC |
1476 | add_setshow_integer_cmd ("size", no_class, &history_size, _("\ |
1477 | Set the size of the command history,"), _("\ | |
1478 | Show the size of the command history,"), _("\ | |
1479 | ie. the number of previous commands to keep a record of."), | |
1480 | set_history_size_command, | |
920d2a44 | 1481 | show_history_size, |
4d28ad1e AC |
1482 | &sethistlist, &showhistlist); |
1483 | ||
1484 | add_setshow_filename_cmd ("filename", no_class, &history_filename, _("\ | |
1485 | Set the filename in which to record the command history"), _("\ | |
1486 | Show the filename in which to record the command history"), _("\ | |
1487 | (the list of previous commands of which a record is kept)."), | |
1488 | NULL, | |
920d2a44 | 1489 | show_history_filename, |
4d28ad1e | 1490 | &sethistlist, &showhistlist); |
9e0b60a8 | 1491 | |
5bf193a2 AC |
1492 | add_setshow_boolean_cmd ("confirm", class_support, &caution, _("\ |
1493 | Set whether to confirm potentially dangerous operations."), _("\ | |
1494 | Show whether to confirm potentially dangerous operations."), NULL, | |
1495 | NULL, | |
920d2a44 | 1496 | show_caution, |
5bf193a2 | 1497 | &setlist, &showlist); |
9e0b60a8 | 1498 | |
85c07804 AC |
1499 | add_setshow_zinteger_cmd ("annotate", class_obscure, &annotation_level, _("\ |
1500 | Set annotation_level."), _("\ | |
1501 | Show annotation_level."), _("\ | |
9e0b60a8 | 1502 | 0 == normal; 1 == fullname (for use when running under emacs)\n\ |
85c07804 AC |
1503 | 2 == output annotated suitably for use by programs that control GDB."), |
1504 | set_async_annotation_level, | |
920d2a44 | 1505 | show_annotation_level, |
85c07804 | 1506 | &setlist, &showlist); |
362646f5 | 1507 | |
5bf193a2 AC |
1508 | add_setshow_boolean_cmd ("exec-done-display", class_support, |
1509 | &exec_done_display_p, _("\ | |
1510 | Set notification of completion for asynchronous execution commands."), _("\ | |
1511 | Show notification of completion for asynchronous execution commands."), _("\ | |
1512 | Use \"on\" to enable the notification, and \"off\" to disable it."), | |
1513 | NULL, | |
920d2a44 | 1514 | show_exec_done_display_p, |
5bf193a2 | 1515 | &setlist, &showlist); |
9e0b60a8 | 1516 | } |
64cdedad EZ |
1517 | |
1518 | void | |
1519 | gdb_init (char *argv0) | |
1520 | { | |
1521 | if (pre_init_ui_hook) | |
1522 | pre_init_ui_hook (); | |
1523 | ||
1524 | /* Run the init function of each source file */ | |
1525 | ||
1526 | getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)); | |
1527 | current_directory = gdb_dirbuf; | |
1528 | ||
1529 | #ifdef __MSDOS__ | |
1530 | /* Make sure we return to the original directory upon exit, come | |
1531 | what may, since the OS doesn't do that for us. */ | |
1532 | make_final_cleanup (do_chdir_cleanup, xstrdup (current_directory)); | |
1533 | #endif | |
1534 | ||
1535 | init_cmd_lists (); /* This needs to be done first */ | |
1536 | initialize_targets (); /* Setup target_terminal macros for utils.c */ | |
1537 | initialize_utils (); /* Make errors and warnings possible */ | |
1538 | initialize_all_files (); | |
1539 | initialize_current_architecture (); | |
1540 | init_cli_cmds(); | |
1541 | init_main (); /* But that omits this file! Do it now */ | |
1542 | ||
362646f5 | 1543 | async_init_signals (); |
64cdedad EZ |
1544 | |
1545 | /* We need a default language for parsing expressions, so simple things like | |
1546 | "set width 0" won't fail if no language is explicitly set in a config file | |
1547 | or implicitly set by reading an executable during startup. */ | |
1548 | set_language (language_c); | |
1549 | expected_language = current_language; /* don't warn about the change. */ | |
1550 | ||
9a4105ab AC |
1551 | /* Allow another UI to initialize. If the UI fails to initialize, |
1552 | and it wants GDB to revert to the CLI, it should clear | |
1553 | deprecated_init_ui_hook. */ | |
1554 | if (deprecated_init_ui_hook) | |
1555 | deprecated_init_ui_hook (argv0); | |
64cdedad | 1556 | } |