* source.c (find_source_lines): Always use code that was #ifdef

BROKEN_LARGE_ALLOCA.  Do the cleanup before returning, rather than
	leaving it on the chain.  Reindent much of this function.
	* config/sparc/{xm-sun4sol2.h,xm-sun4os4.h},
	config/i386/{xm-sun386.h,xm-i386m3.h,xm-i386mach.h},
	config/m68k/{sun3os4.h,xm-news.h,xm-hp300hpux.h},
	config/ns32k/xm-ns32km3.h: Remove all references to
	BROKEN_LARGE_ALLOCA; with the above change it is no longer needed.
	* main.c, fork-child.c, many config files: Remove all
	SET_STACK_LIMIT_HUGE code; with the above changes it should no
	longer be needed.

	* symtab.c (lookup_partial_symbol): Use if and abort, not assert.
	This avoids __eprintf troubles.

	* main.c (main): Surround in #ifndef MAIN_OVERRIDE.  Move
	initialization code which needs to be called even if we bypass the
	command line stuff into gdb_init.
	* utils.c (fputs_unfiltered): Surround in #ifndef
	FPUTS_UNFILTERED_OVERRIDE.
	* Makefile.in (libgdb.a): New target.

	* utils.c: Rearrange I/O stuff a bit so that all output goes
	through fputs_unfiltered.  Use vasprintf; removes arbitrary limit
	which made %s not work with arbitrarily large strings.
	* printcmd.c (printf_command): Use printf_filtered, not
	printf_unfiltered and printf, now that arbitrary limit is gone.
This commit is contained in:
Jim Kingdon 1994-05-14 19:37:57 +00:00
parent cb9461ffc2
commit d8fc877318
33 changed files with 106 additions and 257 deletions

View File

@ -1,5 +1,35 @@
Sat May 14 09:11:44 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
* source.c (find_source_lines): Always use code that was #ifdef
BROKEN_LARGE_ALLOCA. Do the cleanup before returning, rather than
leaving it on the chain. Reindent much of this function.
* config/sparc/{xm-sun4sol2.h,xm-sun4os4.h},
config/i386/{xm-sun386.h,xm-i386m3.h,xm-i386mach.h},
config/m68k/{sun3os4.h,xm-news.h,xm-hp300hpux.h},
config/ns32k/xm-ns32km3.h: Remove all references to
BROKEN_LARGE_ALLOCA; with the above change it is no longer needed.
* main.c, fork-child.c, many config files: Remove all
SET_STACK_LIMIT_HUGE code; with the above changes it should no
longer be needed.
* symtab.c (lookup_partial_symbol): Use if and abort, not assert.
This avoids __eprintf troubles.
Fri May 13 08:10:21 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
* main.c (main): Surround in #ifndef MAIN_OVERRIDE. Move
initialization code which needs to be called even if we bypass the
command line stuff into gdb_init.
* utils.c (fputs_unfiltered): Surround in #ifndef
FPUTS_UNFILTERED_OVERRIDE.
* Makefile.in (libgdb.a): New target.
* utils.c: Rearrange I/O stuff a bit so that all output goes
through fputs_unfiltered. Use vasprintf; removes arbitrary limit
which made %s not work with arbitrarily large strings.
* printcmd.c (printf_command): Use printf_filtered, not
printf_unfiltered and printf, now that arbitrary limit is gone.
gcc -Wall lint:
* breakpoint.c (watchpoint_check): Remove unused variable b.
* stack.c (print_frame_info): Move sp and buf inside #if.

View File

@ -436,10 +436,10 @@ TARFILES = $(SFILES) $(HFILES_NO_SRCDIR) $(HFILES_WITH_SRCDIR) \
$(ALLPARAM) $(INFOFILES) $(POSSLIBS) $(REMOTE_EXAMPLES)
OBS = version.o main.o blockframe.o breakpoint.o findvar.o stack.o thread.o \
COMMON_OBS = version.o blockframe.o breakpoint.o findvar.o stack.o thread.o \
source.o values.o eval.o valops.o valarith.o valprint.o printcmd.o \
symtab.o symfile.o symmisc.o infcmd.o infrun.o command.o \
utils.o expprint.o environ.o gdbtypes.o copying.o $(DEPFILES) \
expprint.o environ.o gdbtypes.o copying.o $(DEPFILES) \
mem-break.o target.o parse.o language.o $(YYOBJ) buildsym.o \
objfiles.o minsyms.o maint.o demangle.o dbxread.o coffread.o elfread.o \
dwarfread.o mipsread.o stabsread.o core.o c-lang.o ch-lang.o m2-lang.o \
@ -447,6 +447,10 @@ OBS = version.o main.o blockframe.o breakpoint.o findvar.o stack.o thread.o \
c-valprint.o cp-valprint.o ch-valprint.o m2-valprint.o nlmread.o \
serial.o mdebugread.o os9kread.o annotate.o
OBS = $(COMMON_OBS) main.o utils.o
LIBGDB_OBS = $(COMMON_OBS) libmain.o libutils.o
TSOBS = inflow.o
NTSOBS = standalone.o
@ -553,6 +557,19 @@ gdb: $(OBS) $(TSOBS) $(ADD_DEPS) $(CDEPS) init.o
$(CC-LD) $(INTERNAL_LDFLAGS) -o gdb \
init.o $(OBS) $(TSOBS) $(ADD_FILES) $(CLIBS) $(LOADLIBES)
libgdb.a: $(LIBGDB_OBS) $(TSOBS) $(ADD_DEPS) $(CDEPS) init.o
rm -f libgdb.a
$(AR) $(AR_FLAGS) libgdb.a $(LIBGDB_OBS) $(TSOBS) $(ADD_FILES) init.o
$(RANLIB) libgdb.a
libmain.o: main.c
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/main.c -DMAIN_OVERRIDE \
-o libmain.o
libutils.o: utils.c
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/utils.c -o libutils.o \
-DFPUTS_UNFILTERED_OVERRIDE
saber_gdb: $(SFILES) $(DEPFILES) copying.c version.c
#setopt load_flags $(CFLAGS) $(BFD_CFLAGS) -DHOST_SYS=SUN4_SYS
#load ./init.c $(SFILES)

View File

@ -45,10 +45,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
# define F_OK 0
#endif
/* Get rid of any system-imposed stack limit if possible */
#define SET_STACK_LIMIT_HUGE
/* System doesn't provide siginterrupt(). */
#define NO_SIGINTERRUPT

View File

@ -21,9 +21,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define HOST_BYTE_ORDER LITTLE_ENDIAN
#endif
/* Get rid of any system-imposed stack limit if possible. */
#define SET_STACK_LIMIT_HUGE
/* The alpha has no siginterrupt routine. */
#define NO_SIGINTERRUPT

View File

@ -19,10 +19,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define HOST_BYTE_ORDER LITTLE_ENDIAN
/* Get rid of any system-imposed stack limit if possible. */
#define SET_STACK_LIMIT_HUGE
/* This is the amount to subtract from u.u_ar0
to get the offset in the core file of the register values. */

View File

@ -25,7 +25,3 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* psignal() is in <signal.h>. */
#define PSIGNAL_IN_SIGNAL_H
/* Get rid of any system-imposed stack limit if possible. */
#define SET_STACK_LIMIT_HUGE

View File

@ -24,12 +24,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#undef INT_MIN
#define INT_MIN 0x80000000
/* Get rid of any system-imposed stack limit if possible. */
#define SET_STACK_LIMIT_HUGE
#define BROKEN_LARGE_ALLOCA
/* Do implement the attach and detach commands. */
#define ATTACH_DETACH 1

View File

@ -24,17 +24,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#undef INT_MIN
#define INT_MIN 0x80000000
/* Get rid of any system-imposed stack limit if possible. */
#define SET_STACK_LIMIT_HUGE
/* This is the amount to subtract from u.u_ar0
to get the offset in the core file of the register values. */
#define KERNEL_U_ADDR (0x80000000 - (UPAGES * NBPG))
#define BROKEN_LARGE_ALLOCA
#define PREPARE_TO_STORE() read_register_bytes (0, NULL, REGISTER_BYTES)
/* <errno.h> only defines this if __STDC__!!! */

View File

@ -21,12 +21,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Get rid of any system-imposed stack limit if possible. */
/* If I do this on SunOS 4.0.1, I get SIGSEGV's on (some) instructions which
try to access the stack. */
/* #define SET_STACK_LIMIT_HUGE */
#define BROKEN_LARGE_ALLOCA
/* Enable use of alternate code for Sun's format of core dump file. */
#define NEW_SUN_CORE

View File

@ -25,10 +25,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define HAVE_WAIT_STRUCT
/* Get rid of any system-imposed stack limit if possible. */
#define SET_STACK_LIMIT_HUGE
#define HOST_BYTE_ORDER LITTLE_ENDIAN
/* We must fetch all the regs before storing, since we store all at once. */

View File

@ -28,10 +28,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Avoid "INT_MIN redefined" preprocessor warnings by defining them here. */
#include <sys/param.h>
/* Get rid of any system-imposed stack limit if possible. */
#define SET_STACK_LIMIT_HUGE
/* Kernel is a bit tenacious about sharing text segments, disallowing bpts. */
#define ONE_PROCESS_WRITETEXT

View File

@ -52,12 +52,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define HAVE_TERMIOS
/* Get rid of any system-imposed stack limit if possible. */
/* The hp9k320.h doesn't seem to have this feature. */
/* #define SET_STACK_LIMIT_HUGE */
/* So we'll just have to avoid big alloca's. */
#define BROKEN_LARGE_ALLOCA
#define REGISTER_ADDR(u_ar0, regno) \
(unsigned int) \
(((regno) < PS_REGNUM) \

View File

@ -25,10 +25,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define HAVE_WAIT_STRUCT
/* Get rid of any system-imposed stack limit if possible. */
#define SET_STACK_LIMIT_HUGE
/* We can't use "isatty" or "fileno" on this machine. This isn't good,
but it will have to do. */
#define ISATTY(FP) ((FP) == stdin || (FP) == stdout)
@ -48,9 +44,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
addr = blockend + 4 * offsets[regno]; \
}
/* NewsOS 3 apparently dies on large alloca's -- roland@ai.mit.edu. */
#define BROKEN_LARGE_ALLOCA
/* NewsOS 3.3 does not define errno in <errno.h>. */
extern int errno;

View File

@ -19,10 +19,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define HOST_BYTE_ORDER BIG_ENDIAN
/* Get rid of any system-imposed stack limit if possible. */
#define SET_STACK_LIMIT_HUGE
/* Enable use of alternate code for Sun's format of core dump file. */
#define NEW_SUN_CORE

View File

@ -20,13 +20,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "m68k/xm-sun3.h"
#define FPU
/* Large alloca's fail because the attempt to increase the stack limit in
main() fails because shared libraries are allocated just below the initial
stack limit. The SunOS kernel will not allow the stack to grow into
the area occupied by the shared libraries. Sun knows about this bug
but has no obvious fix for it. */
#define BROKEN_LARGE_ALLOCA
/* SunOS 4.x has memory mapped files. */
#define HAVE_MMAP

View File

@ -52,10 +52,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define NBPG NBPC
#define UPAGES USIZE
/* Get rid of any system-imposed stack limit if possible. */
#define SET_STACK_LIMIT_HUGE
/* This is the amount to subtract from u.u_ar0
to get the offset in the core file of the register values. */

View File

@ -20,10 +20,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define HAVE_TERMIO
/* Get rid of any system-imposed stack limit if possible */
#define SET_STACK_LIMIT_HUGE
#define HOST_BYTE_ORDER BIG_ENDIAN
/* memcpy and memset return void *, not char *. */

View File

@ -23,10 +23,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define HOST_BYTE_ORDER LITTLE_ENDIAN
#endif
/* Get rid of any system-imposed stack limit if possible */
#define SET_STACK_LIMIT_HUGE
#ifdef ultrix
/* Needed for DECstation core files. */
#include <machine/param.h>

View File

@ -23,10 +23,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define HOST_BYTE_ORDER LITTLE_ENDIAN
#endif
/* Get rid of any system-imposed stack limit if possible */
#define SET_STACK_LIMIT_HUGE
#define KERNEL_U_ADDR 0 /* Not needed. */
/* Only used for core files on DECstations. */

View File

@ -23,10 +23,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define HOST_BYTE_ORDER BIG_ENDIAN
#endif
/* Get rid of any system-imposed stack limit if possible */
#define SET_STACK_LIMIT_HUGE
#define MEM_FNS_DECLARED
/* Mips hosts need aligned va_list arguments. */

View File

@ -24,12 +24,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#undef INT_MIN
#define INT_MIN 0x80000000
/* Get rid of any system-imposed stack limit if possible. */
#define SET_STACK_LIMIT_HUGE
#define BROKEN_LARGE_ALLOCA
/* Do implement the attach and detach commands. */
#define ATTACH_DETACH 1

View File

@ -36,5 +36,3 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
# define SEEK_CUR 1 /* Set file pointer to current plus "offset" */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif /* SEEK_SET */
#define SET_STACK_LIMIT_HUGE

View File

@ -54,10 +54,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define USE_O_NOCTTY
/* Get rid of any system-imposed stack limit if possible. */
#define SET_STACK_LIMIT_HUGE
/* Brain death inherited from PC's pervades. */
#undef NULL
#define NULL 0

View File

@ -20,10 +20,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define HOST_BYTE_ORDER BIG_ENDIAN
/* Get rid of any system-imposed stack limit if possible. */
#define SET_STACK_LIMIT_HUGE
/* Enable use of alternate code for Sun's format of core dump file. */
#define NEW_SUN_CORE

View File

@ -20,13 +20,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "sparc/xm-sparc.h"
#define FPU
/* Large alloca's fail because the attempt to increase the stack limit in
main() fails because shared libraries are allocated just below the initial
stack limit. The SunOS kernel will not allow the stack to grow into
the area occupied by the shared libraries. Sun knows about this bug
but has no obvious fix for it. */
#define BROKEN_LARGE_ALLOCA
/* SunOS 4.x has memory mapped files. */
#define HAVE_MMAP

View File

@ -39,13 +39,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
# define NORETURN /**/
#endif
/* Large alloca's fail because the attempt to increase the stack limit in
main() fails because shared libraries are allocated just below the initial
stack limit. The SunOS kernel will not allow the stack to grow into
the area occupied by the shared libraries. Sun knows about this bug
but has no obvious fix for it. */
#define BROKEN_LARGE_ALLOCA
/* If you expect to use the mmalloc package to obtain mapped symbol files,
for now you have to specify some parameters that determine how gdb places
the mappings in it's address space. See the comments in map_to_address()

View File

@ -19,10 +19,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define HOST_BYTE_ORDER LITTLE_ENDIAN
/* Get rid of any system-imposed stack limit if possible. */
#define SET_STACK_LIMIT_HUGE
/* This is the amount to subtract from u.u_ar0
to get the offset in the core file of the register values. */

View File

@ -25,8 +25,4 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define PSIGNAL_IN_SIGNAL_H
/* Get rid of any system-imposed stack limit if possible. */
#define SET_STACK_LIMIT_HUGE
#define MEM_FNS_DECLARED

View File

@ -31,10 +31,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define USG
/* Get rid of any system-imposed stack limit if possible. */
/* #define SET_STACK_LIMIT_HUGE */
/* Use setpgid(0,0) to run inferior in a separate process group */
#define NEED_POSIX_SETPGID

View File

@ -30,13 +30,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <signal.h>
#ifdef SET_STACK_LIMIT_HUGE
#include <sys/time.h>
#include <sys/resource.h>
extern int original_stack_limit;
#endif /* SET_STACK_LIMIT_HUGE */
extern char **environ;
#ifndef SHELL_FILE
@ -200,17 +193,6 @@ fork_inferior (exec_file, allargs, env, traceme_fun, init_trace_fun,
if (debug_setpgrp == -1)
perror("setpgrp failed in child");
#ifdef SET_STACK_LIMIT_HUGE
/* Reset the stack limit back to what it was. */
{
struct rlimit rlim;
getrlimit (RLIMIT_STACK, &rlim);
rlim.rlim_cur = original_stack_limit;
setrlimit (RLIMIT_STACK, &rlim);
}
#endif /* SET_STACK_LIMIT_HUGE */
/* Ask the tty subsystem to switch to the one we specified earlier
(or to share the current terminal, if none was specified). */

View File

@ -56,13 +56,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <sys/stat.h>
#include <ctype.h>
#ifdef SET_STACK_LIMIT_HUGE
#include <sys/time.h>
#include <sys/resource.h>
int original_stack_limit;
#endif
/* Prototypes for local functions */
static char *
@ -525,6 +518,24 @@ read_command_file (stream)
do_cleanups (cleanups);
}
void
gdb_init ()
{
/* Run the init function of each source file */
init_cmd_lists (); /* This needs to be done first */
initialize_all_files ();
init_main (); /* But that omits this file! Do it now */
init_signals ();
/* We need a default language for parsing expressions, so simple things like
"set width 0" won't fail if no language is explicitly set in a config file
or implicitly set by reading an executable during startup. */
set_language (language_c);
expected_language = current_language; /* don't warn about the change. */
}
#ifndef MAIN_OVERRIDE
int
main (argc, argv)
int argc;
@ -603,19 +614,6 @@ main (argc, argv)
getcwd (dirbuf, sizeof (dirbuf));
current_directory = dirbuf;
#ifdef SET_STACK_LIMIT_HUGE
{
struct rlimit rlim;
/* Set the stack limit huge so that alloca (particularly stringtab
* in dbxread.c) does not fail. */
getrlimit (RLIMIT_STACK, &rlim);
original_stack_limit = rlim.rlim_cur;
rlim.rlim_cur = rlim.rlim_max;
setrlimit (RLIMIT_STACK, &rlim);
}
#endif /* SET_STACK_LIMIT_HUGE */
/* Parse arguments and options. */
{
int c;
@ -783,12 +781,7 @@ main (argc, argv)
quiet = 1;
}
/* Run the init function of each source file */
init_cmd_lists (); /* This needs to be done first */
initialize_all_files ();
init_main (); /* But that omits this file! Do it now */
init_signals ();
gdb_init ();
/* Do these (and anything which might call wrap_here or *_filtered)
after initialize_all_files. */
@ -869,12 +862,6 @@ GDB manual (available as on-line info or a printed manual).\n", gdb_stdout);
/* We may get more than one warning, don't double space all of them... */
warning_pre_print = "\nwarning: ";
/* We need a default language for parsing expressions, so simple things like
"set width 0" won't fail if no language is explicitly set in a config file
or implicitly set by reading an executable during startup. */
set_language (language_c);
expected_language = current_language; /* don't warn about the change. */
/* Read and execute $HOME/.gdbinit file, if it exists. This is done
*before* all the command line arguments are processed; it sets
global parameters, which are independent of what file you are
@ -1039,6 +1026,7 @@ GDB manual (available as on-line info or a printed manual).\n", gdb_stdout);
}
/* No exit -- exit is through quit_command. */
}
#endif /* MAIN_OVERRIDE */
void
execute_user_command (c, args)

View File

@ -1852,8 +1852,8 @@ printf_command (arg, from_tty)
{
/* Now scan the string for %-specs and see what kinds of args they want.
argclass[I] classifies the %-specs so we can give vprintf_unfiltered something
of the right size. */
argclass[I] classifies the %-specs so we can give printf_filtered
something of the right size. */
enum argclass {no_arg, int_arg, string_arg, double_arg, long_long_arg};
enum argclass *argclass;
@ -1949,16 +1949,6 @@ printf_command (arg, from_tty)
if (nargs != nargs_wanted)
error ("Wrong number of arguments for specified format-string");
/* FIXME: We should be using vprintf_filtered, but as long as it
has an arbitrary limit that is unacceptable. Correct fix is
for vprintf_filtered to scan down the format string so it knows
how big a buffer it needs (perhaps by putting a vasprintf (see
GNU C library) in libiberty).
But for now, just force out any pending output, so at least the output
appears in the correct order. */
wrap_here ((char *)NULL);
/* Now actually print them. */
current_substring = substrings;
for (i = 0; i < nargs; i++)
@ -1987,23 +1977,20 @@ printf_command (arg, from_tty)
read_memory (tem, str, j);
str[j] = 0;
/* Don't use printf_filtered because of arbitrary limit. */
printf_unfiltered (current_substring, str);
printf_filtered (current_substring, str);
}
break;
case double_arg:
{
double val = value_as_double (val_args[i]);
/* Don't use printf_filtered because of arbitrary limit. */
printf_unfiltered (current_substring, val);
printf_filtered (current_substring, val);
break;
}
case long_long_arg:
#if defined (CC_HAS_LONG_LONG) && defined (PRINTF_HAS_LONG_LONG)
{
long long val = value_as_long (val_args[i]);
/* Don't use printf_filtered because of arbitrary limit. */
printf_unfiltered (current_substring, val);
printf_filtered (current_substring, val);
break;
}
#else
@ -2013,8 +2000,7 @@ printf_command (arg, from_tty)
{
/* FIXME: there should be separate int_arg and long_arg. */
long val = value_as_long (val_args[i]);
/* Don't use printf_filtered because of arbitrary limit. */
printf_unfiltered (current_substring, val);
printf_filtered (current_substring, val);
break;
}
default:
@ -2024,8 +2010,7 @@ printf_command (arg, from_tty)
current_substring += strlen (current_substring) + 1;
}
/* Print the portion of the format string after the last argument. */
/* It would be OK to use printf_filtered here. */
printf (last_arg);
printf_filtered (last_arg);
}
do_cleanups (old_cleanups);
}

View File

@ -1148,7 +1148,7 @@ wrap_here(indent)
if (wrap_buffer[0])
{
*wrap_pointer = '\0';
fputs (wrap_buffer, gdb_stdout);
fputs_unfiltered (wrap_buffer, gdb_stdout);
}
wrap_pointer = wrap_buffer;
wrap_buffer[0] = '\0';
@ -1231,7 +1231,7 @@ fputs_maybe_filtered (linebuffer, stream, filter)
if (stream != gdb_stdout
|| (lines_per_page == UINT_MAX && chars_per_line == UINT_MAX))
{
fputs (linebuffer, stream);
fputs_unfiltered (linebuffer, stream);
return;
}
@ -1255,7 +1255,7 @@ fputs_maybe_filtered (linebuffer, stream, filter)
if (wrap_column)
*wrap_pointer++ = '\t';
else
putc ('\t', stream);
fputc_unfiltered ('\t', stream);
/* Shifting right by 3 produces the number of tab stops
we have already passed, and then adding one and
shifting left 3 advances to the next tab stop. */
@ -1267,7 +1267,7 @@ fputs_maybe_filtered (linebuffer, stream, filter)
if (wrap_column)
*wrap_pointer++ = *lineptr;
else
putc (*lineptr, stream);
fputc_unfiltered (*lineptr, stream);
chars_printed++;
lineptr++;
}
@ -1282,7 +1282,7 @@ fputs_maybe_filtered (linebuffer, stream, filter)
if chars_per_line is right, we probably just overflowed
anyway; if it's wrong, let us keep going. */
if (wrap_column)
putc ('\n', stream);
fputc_unfiltered ('\n', stream);
/* Possible new page. */
if (lines_printed >= lines_per_page - 1)
@ -1291,9 +1291,9 @@ fputs_maybe_filtered (linebuffer, stream, filter)
/* Now output indentation and wrapped string */
if (wrap_column)
{
fputs (wrap_indent, stream);
*wrap_pointer = '\0'; /* Null-terminate saved stuff */
fputs (wrap_buffer, stream); /* and eject it */
fputs_unfiltered (wrap_indent, stream);
*wrap_pointer = '\0'; /* Null-terminate saved stuff */
fputs_unfiltered (wrap_buffer, stream); /* and eject it */
/* FIXME, this strlen is what prevents wrap_indent from
containing tabs. However, if we recurse to print it
and count its chars, we risk trouble if wrap_indent is
@ -1314,7 +1314,7 @@ fputs_maybe_filtered (linebuffer, stream, filter)
chars_printed = 0;
wrap_here ((char *)0); /* Spit out chars, cancel further wraps */
lines_printed++;
putc ('\n', stream);
fputc_unfiltered ('\n', stream);
lineptr++;
}
}
@ -1328,24 +1328,15 @@ fputs_filtered (linebuffer, stream)
fputs_maybe_filtered (linebuffer, stream, 1);
}
#ifndef FPUTS_UNFILTERED_OVERRIDE
void
fputs_unfiltered (linebuffer, stream)
const char *linebuffer;
FILE *stream;
{
#if 0
/* This gets the wrap_buffer buffering wrong when called from
gdb_readline (GDB was sometimes failing to print the prompt
before reading input). Even at other times, it seems kind of
misguided, especially now that printf_unfiltered doesn't use
printf_maybe_filtered. */
fputs_maybe_filtered (linebuffer, stream, 0);
#else
fputs (linebuffer, stream);
#endif
}
#endif /* FPUTS_UNFILTERED_OVERRIDE */
void
putc_unfiltered (c)
@ -1372,28 +1363,17 @@ fputc_unfiltered (c, stream)
/* Print a variable number of ARGS using format FORMAT. If this
information is going to put the amount written (since the last call
to REINITIALIZE_MORE_FILTER or the last page break) over the page size,
print out a pause message and do a gdb_readline to get the users
permision to continue.
call prompt_for_continue to get the users permision to continue.
Unlike fprintf, this function does not return a value.
We implement three variants, vfprintf (takes a vararg list and stream),
fprintf (takes a stream to write on), and printf (the usual).
Note that this routine has a restriction that the length of the
final output line must be less than 255 characters *or* it must be
less than twice the size of the format string. This is a very
arbitrary restriction, but it is an internal restriction, so I'll
put it in. This means that the %s format specifier is almost
useless; unless the caller can GUARANTEE that the string is short
enough, fputs_filtered should be used instead.
Note also that a longjmp to top level may occur in this routine
(since prompt_for_continue may do so) so this routine should not be
called when cleanups are not in place. */
#define MIN_LINEBUF 255
static void
vfprintf_maybe_filtered (stream, format, args, filter)
FILE *stream;
@ -1401,23 +1381,15 @@ vfprintf_maybe_filtered (stream, format, args, filter)
va_list args;
int filter;
{
char line_buf[MIN_LINEBUF+10];
char *linebuffer = line_buf;
int format_length;
format_length = strlen (format);
/* Reallocate buffer to a larger size if this is necessary. */
if (format_length * 2 > MIN_LINEBUF)
{
linebuffer = alloca (10 + format_length * 2);
}
/* This won't blow up if the restrictions described above are
followed. */
vsprintf (linebuffer, format, args);
char *linebuffer;
struct cleanup *old_cleanups;
vasprintf (&linebuffer, format, args);
if (linebuffer == NULL)
fatal ("virtual memory exhausted.");
old_cleanups = make_cleanup (free, linebuffer);
fputs_maybe_filtered (linebuffer, stream, filter);
do_cleanups (old_cleanups);
}
@ -1436,7 +1408,15 @@ vfprintf_unfiltered (stream, format, args)
char *format;
va_list args;
{
vfprintf (stream, format, args);
char *linebuffer;
struct cleanup *old_cleanups;
vasprintf (&linebuffer, format, args);
if (linebuffer == NULL)
fatal ("virtual memory exhausted.");
old_cleanups = make_cleanup (free, linebuffer);
fputs_unfiltered (linebuffer, stream);
do_cleanups (old_cleanups);
}
void
@ -1452,7 +1432,7 @@ vprintf_unfiltered (format, args)
char *format;
va_list args;
{
vfprintf (gdb_stdout, format, args);
vfprintf_unfiltered (gdb_stdout, format, args);
}
/* VARARGS */
@ -1468,8 +1448,6 @@ fprintf_filtered (va_alist)
stream = va_arg (args, FILE *);
format = va_arg (args, char *);
/* This won't blow up if the restrictions described above are
followed. */
vfprintf_filtered (stream, format, args);
va_end (args);
}
@ -1487,13 +1465,11 @@ fprintf_unfiltered (va_alist)
stream = va_arg (args, FILE *);
format = va_arg (args, char *);
/* This won't blow up if the restrictions described above are
followed. */
vfprintf_unfiltered (stream, format, args);
va_end (args);
}
/* Like fprintf_filtered, but prints it's result indent.
/* Like fprintf_filtered, but prints its result indented.
Called as fprintfi_filtered (spaces, stream, format, ...); */
/* VARARGS */
@ -1512,8 +1488,6 @@ fprintfi_filtered (va_alist)
format = va_arg (args, char *);
print_spaces_filtered (spaces, stream);
/* This won't blow up if the restrictions described above are
followed. */
vfprintf_filtered (stream, format, args);
va_end (args);
}