OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [main.c] - Blame information for rev 578

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.