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