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