import gdb-2000-02-02 snapshot
[deliverable/binutils-gdb.git] / gdb / main.c
CommitLineData
c906108c 1/* Top level stuff for GDB, the GNU debugger.
d9fcf2fb 2 Copyright 1986-1995, 1999-2000 Free Software Foundation, Inc.
c906108c 3
c5aa993b 4 This file is part of GDB.
c906108c 5
c5aa993b
JM
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
c906108c 10
c5aa993b
JM
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
c906108c 15
c5aa993b
JM
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
c906108c
SS
20
21#include "defs.h"
c906108c
SS
22#include "top.h"
23#include "target.h"
24#include "inferior.h"
25#include "call-cmds.h"
26
27#include "getopt.h"
28
29#include <sys/types.h>
30#include "gdb_stat.h"
31#include <ctype.h>
32
33#include "gdb_string.h"
9e0b60a8 34#include "event-loop.h"
8b93c638 35#include "ui-out.h"
da59e081
JM
36#if defined (TUI) || defined (GDBTK)
37/* FIXME: cagney/2000-01-31: This #include is to allow older code such
38 as that found in the TUI to continue to build. */
39#include "tui/tui-file.h"
40#endif
c906108c 41
c906108c
SS
42/* If nonzero, display time usage both at startup and for each command. */
43
44int display_time;
45
46/* If nonzero, display space usage both at startup and for each command. */
47
48int display_space;
49
cd0fc7c3 50/* Whether this is the async version or not. The async version is
c5aa993b
JM
51 invoked on the command line with the -nw --async options. In this
52 version, the usual command_loop is substituted by and event loop which
53 processes UI events asynchronously. */
6426a772 54int event_loop_p = 1;
cd0fc7c3 55
c906108c
SS
56/* Whether this is the command line version or not */
57int tui_version = 0;
58
59/* Whether xdb commands will be handled */
60int xdb_commands = 0;
61
62/* Whether dbx commands will be handled */
63int dbx_commands = 0;
64
d9fcf2fb
JM
65struct ui_file *gdb_stdout;
66struct ui_file *gdb_stderr;
67struct ui_file *gdb_stdlog;
68struct ui_file *gdb_stdtarg;
c906108c 69
2acceee2
JM
70/* Used to initialize error() - defined in utils.c */
71
72extern void error_init (void);
73
c906108c
SS
74/* Whether to enable writing into executable and core files */
75extern int write_files;
76
d9fcf2fb 77static void print_gdb_help (struct ui_file *);
c906108c
SS
78
79/* These two are used to set the external editor commands when gdb is farming
80 out files to be edited by another program. */
81
82extern int enable_external_editor;
c5aa993b 83extern char *external_editor_command;
c906108c
SS
84
85#ifdef __CYGWIN__
c5aa993b
JM
86#include <windows.h> /* for MAX_PATH */
87#include <sys/cygwin.h> /* for cygwin32_conv_to_posix_path */
c906108c
SS
88#endif
89
11cf8741
JM
90/* Call command_loop. If it happens to return, pass that through as a
91 non-zero return status. */
92
93static int
94captured_command_loop (void *data)
c906108c 95{
11cf8741
JM
96 if (command_loop_hook == NULL)
97 command_loop ();
98 else
99 command_loop_hook ();
100 /* FIXME: cagney/1999-11-05: A correct command_loop() implementaton
101 would clean things up (restoring the cleanup chain) to the state
102 they were just prior to the call. Technically, this means that
103 the do_cleanups() below is redundant. Unfortunatly, many FUNC's
104 are not that well behaved. do_cleanups should either be replaced
105 with a do_cleanups call (to cover the problem) or an assertion
106 check to detect bad FUNCs code. */
107 do_cleanups (ALL_CLEANUPS);
108 /* If the command_loop returned, normally (rather than threw an
109 error) we try to quit. If the quit is aborted, catch_errors()
110 which called this catch the signal and restart the command
111 loop. */
112 quit_command (NULL, instream == stdin);
113 return 1;
114}
115
116struct captured_main_args
117 {
118 int argc;
119 char **argv;
120 };
121
122static int
123captured_main (void *data)
124{
125 struct captured_main_args *context = data;
126 int argc = context->argc;
127 char **argv = context->argv;
c906108c
SS
128 int count;
129 static int quiet = 0;
130 static int batch = 0;
131
132 /* Pointers to various arguments from command line. */
133 char *symarg = NULL;
134 char *execarg = NULL;
135 char *corearg = NULL;
136 char *cdarg = NULL;
137 char *ttyarg = NULL;
138
139 /* These are static so that we can take their address in an initializer. */
140 static int print_help;
141 static int print_version;
142
143 /* Pointers to all arguments of --command option. */
144 char **cmdarg;
145 /* Allocated size of cmdarg. */
146 int cmdsize;
147 /* Number of elements of cmdarg used. */
148 int ncmd;
149
150 /* Indices of all arguments of --directory option. */
151 char **dirarg;
152 /* Allocated size. */
153 int dirsize;
154 /* Number of elements used. */
155 int ndir;
c5aa993b 156
c906108c
SS
157 struct stat homebuf, cwdbuf;
158 char *homedir, *homeinit;
159
160 register int i;
161
162 long time_at_startup = get_run_time ();
163
c906108c
SS
164 START_PROGRESS (argv[0], 0);
165
166#ifdef MPW
167 /* Do all Mac-specific setup. */
168 mac_init ();
169#endif /* MPW */
170
171 /* This needs to happen before the first use of malloc. */
172 init_malloc ((PTR) NULL);
173
174#if defined (ALIGN_STACK_ON_STARTUP)
175 i = (int) &count & 0x3;
176 if (i != 0)
177 alloca (4 - i);
178#endif
179
c906108c
SS
180 cmdsize = 1;
181 cmdarg = (char **) xmalloc (cmdsize * sizeof (*cmdarg));
182 ncmd = 0;
183 dirsize = 1;
184 dirarg = (char **) xmalloc (dirsize * sizeof (*dirarg));
185 ndir = 0;
186
187 quit_flag = 0;
188 line = (char *) xmalloc (linesize);
189 line[0] = '\0'; /* Terminate saved (now empty) cmd line */
190 instream = stdin;
191
192 getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
193 current_directory = gdb_dirbuf;
194
da59e081
JM
195#if defined (TUI) || defined (GDBTK)
196 /* Older code uses the tui_file and fputs_unfiltered_hook(). It
d9fcf2fb 197 should be using a customized UI_FILE object and re-initializing
da59e081 198 within its own _initialize function. */
ac9a91a7
JM
199 gdb_stdout = tui_fileopen (stdout);
200 gdb_stderr = tui_fileopen (stderr);
c5aa993b
JM
201 gdb_stdlog = gdb_stdout; /* for moment */
202 gdb_stdtarg = gdb_stderr; /* for moment */
da59e081
JM
203#else
204 gdb_stdout = stdio_fileopen (stdout);
205 gdb_stderr = stdio_fileopen (stderr);
206 gdb_stdlog = gdb_stderr; /* for moment */
207 gdb_stdtarg = gdb_stderr; /* for moment */
ac9a91a7 208#endif
c906108c 209
2acceee2
JM
210 /* initialize error() */
211 error_init ();
212
c906108c
SS
213 /* Parse arguments and options. */
214 {
215 int c;
216 /* When var field is 0, use flag field to record the equivalent
217 short option (or arbitrary numbers starting at 10 for those
218 with no equivalent). */
219 static struct option long_options[] =
c5aa993b 220 {
6426a772
JM
221 {"async", no_argument, &event_loop_p, 1},
222 {"noasync", no_argument, &event_loop_p, 0},
c906108c 223#if defined(TUI)
c5aa993b 224 {"tui", no_argument, &tui_version, 1},
c906108c 225#endif
c5aa993b
JM
226 {"xdb", no_argument, &xdb_commands, 1},
227 {"dbx", no_argument, &dbx_commands, 1},
228 {"readnow", no_argument, &readnow_symbol_files, 1},
229 {"r", no_argument, &readnow_symbol_files, 1},
230 {"mapped", no_argument, &mapped_symbol_files, 1},
231 {"m", no_argument, &mapped_symbol_files, 1},
232 {"quiet", no_argument, &quiet, 1},
233 {"q", no_argument, &quiet, 1},
234 {"silent", no_argument, &quiet, 1},
235 {"nx", no_argument, &inhibit_gdbinit, 1},
236 {"n", no_argument, &inhibit_gdbinit, 1},
237 {"batch", no_argument, &batch, 1},
238 {"epoch", no_argument, &epoch_interface, 1},
239
240 /* This is a synonym for "--annotate=1". --annotate is now preferred,
241 but keep this here for a long time because people will be running
242 emacses which use --fullname. */
243 {"fullname", no_argument, 0, 'f'},
244 {"f", no_argument, 0, 'f'},
245
246 {"annotate", required_argument, 0, 12},
247 {"help", no_argument, &print_help, 1},
248 {"se", required_argument, 0, 10},
249 {"symbols", required_argument, 0, 's'},
250 {"s", required_argument, 0, 's'},
251 {"exec", required_argument, 0, 'e'},
252 {"e", required_argument, 0, 'e'},
253 {"core", required_argument, 0, 'c'},
254 {"c", required_argument, 0, 'c'},
255 {"command", required_argument, 0, 'x'},
256 {"version", no_argument, &print_version, 1},
257 {"x", required_argument, 0, 'x'},
8b93c638
JM
258 {"ui", required_argument, 0, 'i'},
259 {"interpreter", required_argument, 0, 'i'},
260 {"i", required_argument, 0, 'i'},
c5aa993b 261 {"directory", required_argument, 0, 'd'},
c4093a6a 262 {"d", required_argument, 0, 'd'},
c5aa993b
JM
263 {"cd", required_argument, 0, 11},
264 {"tty", required_argument, 0, 't'},
265 {"baud", required_argument, 0, 'b'},
266 {"b", required_argument, 0, 'b'},
267 {"nw", no_argument, &use_windows, 0},
268 {"nowindows", no_argument, &use_windows, 0},
269 {"w", no_argument, &use_windows, 1},
270 {"windows", no_argument, &use_windows, 1},
271 {"statistics", no_argument, 0, 13},
272 {"write", no_argument, &write_files, 1},
c906108c
SS
273/* Allow machine descriptions to add more options... */
274#ifdef ADDITIONAL_OPTIONS
c5aa993b 275 ADDITIONAL_OPTIONS
c906108c 276#endif
c5aa993b
JM
277 {0, no_argument, 0, 0}
278 };
c906108c
SS
279
280 while (1)
281 {
282 int option_index;
283
284 c = getopt_long_only (argc, argv, "",
285 long_options, &option_index);
286 if (c == EOF)
287 break;
288
289 /* Long option that takes an argument. */
290 if (c == 0 && long_options[option_index].flag == 0)
291 c = long_options[option_index].val;
292
293 switch (c)
294 {
295 case 0:
296 /* Long option that just sets a flag. */
297 break;
298 case 10:
299 symarg = optarg;
300 execarg = optarg;
301 break;
302 case 11:
303 cdarg = optarg;
304 break;
305 case 12:
306 /* FIXME: what if the syntax is wrong (e.g. not digits)? */
307 annotation_level = atoi (optarg);
308 break;
309 case 13:
310 /* Enable the display of both time and space usage. */
311 display_time = 1;
312 display_space = 1;
313 break;
314 case 'f':
315 annotation_level = 1;
316/* We have probably been invoked from emacs. Disable window interface. */
317 use_windows = 0;
318 break;
319 case 's':
320 symarg = optarg;
321 break;
322 case 'e':
323 execarg = optarg;
324 break;
325 case 'c':
326 corearg = optarg;
327 break;
328 case 'x':
329 cmdarg[ncmd++] = optarg;
330 if (ncmd >= cmdsize)
331 {
332 cmdsize *= 2;
c5aa993b 333 cmdarg = (char **) xrealloc ((char *) cmdarg,
c906108c
SS
334 cmdsize * sizeof (*cmdarg));
335 }
336 break;
337 case 'd':
338 dirarg[ndir++] = optarg;
339 if (ndir >= dirsize)
340 {
341 dirsize *= 2;
c5aa993b 342 dirarg = (char **) xrealloc ((char *) dirarg,
c906108c
SS
343 dirsize * sizeof (*dirarg));
344 }
345 break;
346 case 't':
347 ttyarg = optarg;
348 break;
349 case 'q':
350 quiet = 1;
351 break;
352 case 'b':
353 {
354 int i;
355 char *p;
356
357 i = strtol (optarg, &p, 0);
358 if (i == 0 && p == optarg)
359
360 /* Don't use *_filtered or warning() (which relies on
c5aa993b 361 current_target) until after initialize_all_files(). */
c906108c
SS
362
363 fprintf_unfiltered
364 (gdb_stderr,
365 "warning: could not set baud rate to `%s'.\n", optarg);
366 else
367 baud_rate = i;
368 }
369 case 'l':
370 {
371 int i;
372 char *p;
373
374 i = strtol (optarg, &p, 0);
375 if (i == 0 && p == optarg)
376
377 /* Don't use *_filtered or warning() (which relies on
c5aa993b 378 current_target) until after initialize_all_files(). */
c906108c
SS
379
380 fprintf_unfiltered
381 (gdb_stderr,
c5aa993b 382 "warning: could not set timeout limit to `%s'.\n", optarg);
c906108c
SS
383 else
384 remote_timeout = i;
385 }
386 break;
387
388#ifdef ADDITIONAL_OPTION_CASES
c5aa993b 389 ADDITIONAL_OPTION_CASES
c906108c
SS
390#endif
391 case '?':
392 fprintf_unfiltered (gdb_stderr,
c5aa993b
JM
393 "Use `%s --help' for a complete list of options.\n",
394 argv[0]);
c906108c
SS
395 exit (1);
396 }
397 }
398
399 /* If --help or --version, disable window interface. */
400 if (print_help || print_version)
401 {
402 use_windows = 0;
403#ifdef TUI
404 /* Disable the TUI as well. */
405 tui_version = 0;
406#endif
407 }
408
409#ifdef TUI
410 /* An explicit --tui flag overrides the default UI, which is the
411 window system. */
412 if (tui_version)
413 use_windows = 0;
c5aa993b 414#endif
c906108c
SS
415
416 /* OK, that's all the options. The other arguments are filenames. */
417 count = 0;
418 for (; optind < argc; optind++)
419 switch (++count)
420 {
421 case 1:
422 symarg = argv[optind];
423 execarg = argv[optind];
424 break;
425 case 2:
426 corearg = argv[optind];
427 break;
428 case 3:
429 fprintf_unfiltered (gdb_stderr,
c5aa993b
JM
430 "Excess command line arguments ignored. (%s%s)\n",
431 argv[optind], (optind == argc - 1) ? "" : " ...");
c906108c
SS
432 break;
433 }
434 if (batch)
435 quiet = 1;
436 }
437
438#if defined(TUI)
0f71a2f6 439 /* Should this be moved to tui-top.c:_initialize_tui()? */
c906108c
SS
440 if (tui_version)
441 init_ui_hook = tuiInit;
442#endif
0f71a2f6
JM
443
444 /* Initialize all files. Give the interpreter a chance to take
445 control of the console via the init_ui_hook()) */
c906108c
SS
446 gdb_init (argv[0]);
447
448 /* Do these (and anything which might call wrap_here or *_filtered)
449 after initialize_all_files. */
450 if (print_version)
451 {
452 print_gdb_version (gdb_stdout);
453 wrap_here ("");
454 printf_filtered ("\n");
455 exit (0);
456 }
457
458 if (print_help)
459 {
460 print_gdb_help (gdb_stdout);
461 fputs_unfiltered ("\n", gdb_stdout);
462 exit (0);
463 }
464
465 if (!quiet)
466 {
467 /* Print all the junk at the top, with trailing "..." if we are about
c5aa993b 468 to read a symbol file (possibly slowly). */
c906108c
SS
469 print_gdb_version (gdb_stdout);
470 if (symarg)
471 printf_filtered ("..");
c5aa993b
JM
472 wrap_here ("");
473 gdb_flush (gdb_stdout); /* Force to screen during slow operations */
c906108c
SS
474 }
475
476 error_pre_print = "\n\n";
477 quit_pre_print = error_pre_print;
478
479 /* We may get more than one warning, don't double space all of them... */
480 warning_pre_print = "\nwarning: ";
481
482 /* Read and execute $HOME/.gdbinit file, if it exists. This is done
483 *before* all the command line arguments are processed; it sets
484 global parameters, which are independent of what file you are
485 debugging or what directory you are in. */
486#ifdef __CYGWIN32__
487 {
c5aa993b
JM
488 char *tmp = getenv ("HOME");
489
c906108c
SS
490 if (tmp != NULL)
491 {
c5aa993b
JM
492 homedir = (char *) alloca (MAX_PATH + 1);
493 cygwin32_conv_to_posix_path (tmp, homedir);
c906108c
SS
494 }
495 else
496 homedir = NULL;
497 }
498#else
c5aa993b 499 homedir = getenv ("HOME");
c906108c
SS
500#endif
501 if (homedir)
502 {
503 homeinit = (char *) alloca (strlen (homedir) +
504 strlen (gdbinit) + 10);
505 strcpy (homeinit, homedir);
506 strcat (homeinit, "/");
507 strcat (homeinit, gdbinit);
508
509 if (!inhibit_gdbinit)
510 {
11cf8741 511 catch_command_errors (source_command, homeinit, 0, RETURN_MASK_ALL);
c906108c 512 }
c906108c
SS
513
514 /* Do stats; no need to do them elsewhere since we'll only
c5aa993b
JM
515 need them if homedir is set. Make sure that they are
516 zero in case one of them fails (this guarantees that they
517 won't match if either exists). */
518
c906108c
SS
519 memset (&homebuf, 0, sizeof (struct stat));
520 memset (&cwdbuf, 0, sizeof (struct stat));
c5aa993b 521
c906108c 522 stat (homeinit, &homebuf);
c5aa993b
JM
523 stat (gdbinit, &cwdbuf); /* We'll only need this if
524 homedir was set. */
c906108c
SS
525 }
526
527 /* Now perform all the actions indicated by the arguments. */
528 if (cdarg != NULL)
529 {
11cf8741 530 catch_command_errors (cd_command, cdarg, 0, RETURN_MASK_ALL);
c906108c 531 }
c906108c
SS
532
533 for (i = 0; i < ndir; i++)
11cf8741 534 catch_command_errors (directory_command, dirarg[i], 0, RETURN_MASK_ALL);
c5aa993b 535 free ((PTR) dirarg);
c906108c
SS
536
537 if (execarg != NULL
538 && symarg != NULL
539 && STREQ (execarg, symarg))
540 {
11cf8741
JM
541 /* The exec file and the symbol-file are the same. If we can't
542 open it, better only print one error message.
543 catch_command_errors returns non-zero on success! */
544 if (catch_command_errors (exec_file_command, execarg, !batch, RETURN_MASK_ALL))
545 catch_command_errors (symbol_file_command, symarg, 0, RETURN_MASK_ALL);
c906108c
SS
546 }
547 else
548 {
549 if (execarg != NULL)
11cf8741 550 catch_command_errors (exec_file_command, execarg, !batch, RETURN_MASK_ALL);
c906108c 551 if (symarg != NULL)
11cf8741 552 catch_command_errors (symbol_file_command, symarg, 0, RETURN_MASK_ALL);
c906108c 553 }
c906108c
SS
554
555 /* After the symbol file has been read, print a newline to get us
556 beyond the copyright line... But errors should still set off
557 the error message with a (single) blank line. */
558 if (!quiet)
559 printf_filtered ("\n");
560 error_pre_print = "\n";
561 quit_pre_print = error_pre_print;
562 warning_pre_print = "\nwarning: ";
563
564 if (corearg != NULL)
565 {
11cf8741
JM
566 if (catch_command_errors (core_file_command, corearg, !batch, RETURN_MASK_ALL) == 0)
567 {
568 /* See if the core file is really a PID. */
569 if (isdigit (corearg[0]))
570 catch_command_errors (attach_command, corearg, !batch, RETURN_MASK_ALL);
571 }
c906108c 572 }
c906108c
SS
573
574 if (ttyarg != NULL)
11cf8741 575 catch_command_errors (tty_command, ttyarg, !batch, RETURN_MASK_ALL);
c906108c
SS
576
577#ifdef ADDITIONAL_OPTION_HANDLER
578 ADDITIONAL_OPTION_HANDLER;
579#endif
580
581 /* Error messages should no longer be distinguished with extra output. */
582 error_pre_print = NULL;
583 quit_pre_print = NULL;
584 warning_pre_print = "warning: ";
585
586 /* Read the .gdbinit file in the current directory, *if* it isn't
587 the same as the $HOME/.gdbinit file (it should exist, also). */
c5aa993b 588
c906108c
SS
589 if (!homedir
590 || memcmp ((char *) &homebuf, (char *) &cwdbuf, sizeof (struct stat)))
591 if (!inhibit_gdbinit)
592 {
11cf8741 593 catch_command_errors (source_command, gdbinit, 0, RETURN_MASK_ALL);
c906108c 594 }
c906108c
SS
595
596 for (i = 0; i < ncmd; i++)
597 {
11cf8741
JM
598#if 0
599 /* NOTE: cagney/1999-11-03: SET_TOP_LEVEL() was a macro that
600 expanded into a call to setjmp(). */
601 if (!SET_TOP_LEVEL ()) /* NB: This is #if 0'd out */
c906108c 602 {
b83266a0
SS
603 /* NOTE: I am commenting this out, because it is not clear
604 where this feature is used. It is very old and
c5aa993b 605 undocumented. ezannoni: 1999-05-04 */
b83266a0 606#if 0
c906108c
SS
607 if (cmdarg[i][0] == '-' && cmdarg[i][1] == '\0')
608 read_command_file (stdin);
609 else
b83266a0 610#endif
c906108c
SS
611 source_command (cmdarg[i], !batch);
612 do_cleanups (ALL_CLEANUPS);
613 }
11cf8741
JM
614#endif
615 catch_command_errors (source_command, cmdarg[i], !batch, RETURN_MASK_ALL);
c906108c 616 }
c5aa993b 617 free ((PTR) cmdarg);
c906108c
SS
618
619 /* Read in the old history after all the command files have been read. */
c5aa993b 620 init_history ();
c906108c
SS
621
622 if (batch)
623 {
624 /* We have hit the end of the batch file. */
625 exit (0);
626 }
627
628 /* Do any host- or target-specific hacks. This is used for i960 targets
629 to force the user to set a nindy target and spec its parameters. */
630
631#ifdef BEFORE_MAIN_LOOP_HOOK
632 BEFORE_MAIN_LOOP_HOOK;
633#endif
634
635 END_PROGRESS (argv[0]);
636
637 /* Show time and/or space usage. */
638
639 if (display_time)
640 {
641 long init_time = get_run_time () - time_at_startup;
642
643 printf_unfiltered ("Startup time: %ld.%06ld\n",
644 init_time / 1000000, init_time % 1000000);
645 }
646
647 if (display_space)
648 {
649#ifdef HAVE_SBRK
650 extern char **environ;
651 char *lim = (char *) sbrk (0);
652
653 printf_unfiltered ("Startup size: data size %ld\n",
654 (long) (lim - (char *) &environ));
655#endif
656 }
657
658 /* The default command loop.
659 The WIN32 Gui calls this main to set up gdb's state, and
660 has its own command loop. */
661#if !defined _WIN32 || defined __GNUC__
11cf8741
JM
662 /* GUIs generally have their own command loop, mainloop, or
663 whatever. This is a good place to gain control because many
664 error conditions will end up here via longjmp(). */
665#if 0
666 /* FIXME: cagney/1999-11-06: The original main loop was like: */
c906108c
SS
667 while (1)
668 {
669 if (!SET_TOP_LEVEL ())
670 {
c5aa993b 671 do_cleanups (ALL_CLEANUPS); /* Do complete cleanup */
c906108c
SS
672 /* GUIs generally have their own command loop, mainloop, or whatever.
673 This is a good place to gain control because many error
674 conditions will end up here via longjmp(). */
675 if (command_loop_hook)
676 command_loop_hook ();
677 else
678 command_loop ();
c5aa993b 679 quit_command ((char *) 0, instream == stdin);
c906108c
SS
680 }
681 }
11cf8741
JM
682 /* NOTE: If the command_loop() returned normally, the loop would
683 attempt to exit by calling the function quit_command(). That
684 function would either call exit() or throw an error returning
685 control to SET_TOP_LEVEL. */
686 /* NOTE: The function do_cleanups() was called once each time round
687 the loop. The usefulness of the call isn't clear. If an error
688 was thrown, everything would have already been cleaned up. If
689 command_loop() returned normally and quit_command() was called,
690 either exit() or error() (again cleaning up) would be called. */
691#endif
692 /* NOTE: cagney/1999-11-07: There is probably no reason for not
693 moving this loop and the code found in captured_command_loop()
694 into the command_loop() proper. The main thing holding back that
695 change - SET_TOP_LEVEL() - has been eliminated. */
696 while (1)
697 {
698 catch_errors (captured_command_loop, 0, "", RETURN_MASK_ALL);
699 }
c906108c 700#endif
11cf8741
JM
701 /* No exit -- exit is through quit_command. */
702}
c906108c 703
11cf8741
JM
704int
705main (int argc, char **argv)
706{
11cf8741
JM
707 struct captured_main_args args;
708 args.argc = argc;
709 args.argv = argv;
710 catch_errors (captured_main, &args, "", RETURN_MASK_ALL);
711 return 0;
c906108c
SS
712}
713
11cf8741 714
c906108c
SS
715/* Don't use *_filtered for printing help. We don't want to prompt
716 for continue no matter how small the screen or how much we're going
717 to print. */
718
719static void
d9fcf2fb 720print_gdb_help (struct ui_file *stream)
c906108c 721{
c5aa993b 722 fputs_unfiltered ("\
c906108c
SS
723This is the GNU debugger. Usage:\n\n\
724 gdb [options] [executable-file [core-file or process-id]]\n\n\
725Options:\n\n\
0f71a2f6 726", stream);
c5aa993b 727 fputs_unfiltered ("\
0f71a2f6 728 --[no]async Enable (disable) asynchronous version of CLI\n\
c906108c 729", stream);
c5aa993b 730 fputs_unfiltered ("\
c906108c
SS
731 -b BAUDRATE Set serial port baud rate used for remote debugging.\n\
732 --batch Exit after processing options.\n\
733 --cd=DIR Change current directory to DIR.\n\
734 --command=FILE Execute GDB commands from FILE.\n\
735 --core=COREFILE Analyze the core dump COREFILE.\n\
736", stream);
c5aa993b 737 fputs_unfiltered ("\
c906108c
SS
738 --dbx DBX compatibility mode.\n\
739 --directory=DIR Search for source files in DIR.\n\
740 --epoch Output information used by epoch emacs-GDB interface.\n\
741 --exec=EXECFILE Use EXECFILE as the executable.\n\
742 --fullname Output information used by emacs-GDB interface.\n\
743 --help Print this message.\n\
8b93c638
JM
744", stream);
745 fputs_unfiltered ("\
746 --interpreter=INTERP\n\
747 Select a specific interpreter / user interface\n\
c906108c 748", stream);
c5aa993b 749 fputs_unfiltered ("\
c906108c
SS
750 --mapped Use mapped symbol files if supported on this system.\n\
751 --nw Do not use a window interface.\n\
96baa820
JM
752 --nx Do not read ", stream);
753 fputs_unfiltered (gdbinit, stream);
754 fputs_unfiltered (" file.\n\
c906108c
SS
755 --quiet Do not print version number on startup.\n\
756 --readnow Fully read symbol files on first access.\n\
757", stream);
c5aa993b 758 fputs_unfiltered ("\
c906108c
SS
759 --se=FILE Use FILE as symbol file and executable file.\n\
760 --symbols=SYMFILE Read symbols from SYMFILE.\n\
761 --tty=TTY Use TTY for input/output by the program being debugged.\n\
762", stream);
763#if defined(TUI)
c5aa993b 764 fputs_unfiltered ("\
c906108c
SS
765 --tui Use a terminal user interface.\n\
766", stream);
767#endif
c5aa993b 768 fputs_unfiltered ("\
c906108c
SS
769 --version Print version information and then exit.\n\
770 -w Use a window interface.\n\
771 --write Set writing into executable and core files.\n\
772 --xdb XDB compatibility mode.\n\
773", stream);
774#ifdef ADDITIONAL_OPTION_HELP
c5aa993b 775 fputs_unfiltered (ADDITIONAL_OPTION_HELP, stream);
c906108c 776#endif
c5aa993b 777 fputs_unfiltered ("\n\
c906108c
SS
778For more information, type \"help\" from within GDB, or consult the\n\
779GDB manual (available as on-line info or a printed manual).\n\
2df3850c 780Report bugs to \"bug-gdb@gnu.org\".\
c906108c
SS
781", stream);
782}
This page took 0.069178 seconds and 4 git commands to generate.