* utils.c, defs.h (warning_begin): Renamed from warning_setup, for

consistency with error_begin.  Also print warning_pre_print.
	Document it better.
	* utils.c (warning): Use it.
	* utils.c (error_begin): Doc fix.
	* rs6000-nat.c (vmap_ldinfo): If symfile_objfile is not part of
	any vmap, nuke it.
This commit is contained in:
Jim Kingdon 1995-04-11 22:26:14 +00:00
parent af125b1638
commit 8989d4fc4b
4 changed files with 63 additions and 38 deletions

View File

@ -1,3 +1,13 @@
Tue Apr 11 13:46:25 1995 Jim Kingdon <kingdon@deneb.cygnus.com>
* utils.c, defs.h (warning_begin): Renamed from warning_setup, for
consistency with error_begin. Also print warning_pre_print.
Document it better.
* utils.c (warning): Use it.
* utils.c (error_begin): Doc fix.
* rs6000-nat.c (vmap_ldinfo): If symfile_objfile is not part of
any vmap, nuke it.
Tue Apr 11 09:35:20 1995 Jim Kingdon (kingdon@lioth.cygnus.com) Tue Apr 11 09:35:20 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
* printcmd.c (print_address_numeric): Pass use_local to * printcmd.c (print_address_numeric): Pass use_local to

View File

@ -211,11 +211,9 @@ extern void fputs_filtered PARAMS ((const char *, GDB_FILE *));
extern void fputs_unfiltered PARAMS ((const char *, GDB_FILE *)); extern void fputs_unfiltered PARAMS ((const char *, GDB_FILE *));
extern void fputc_unfiltered PARAMS ((int, GDB_FILE *)); extern int fputc_unfiltered PARAMS ((int c, GDB_FILE *));
extern void putc_unfiltered PARAMS ((int)); extern int putchar_unfiltered PARAMS ((int c));
#define putchar_unfiltered(C) putc_unfiltered(C)
extern void puts_filtered PARAMS ((char *)); extern void puts_filtered PARAMS ((char *));
@ -541,6 +539,10 @@ extern char *reg_names[];
extern char *error_pre_print; extern char *error_pre_print;
/* Message to be printed before the error message, when an error occurs. */
extern char *quit_pre_print;
/* Message to be printed before the warning message, when a warning occurs. */ /* Message to be printed before the warning message, when a warning occurs. */
extern char *warning_pre_print; extern char *warning_pre_print;
@ -573,7 +575,7 @@ return_to_top_level PARAMS ((enum return_reason)) ATTR_NORETURN;
extern int extern int
catch_errors PARAMS ((int (*) (char *), void *, char *, return_mask)); catch_errors PARAMS ((int (*) (char *), void *, char *, return_mask));
extern void warning_setup PARAMS ((void)); extern void warning_begin PARAMS ((void));
extern void warning (); extern void warning ();
@ -596,7 +598,9 @@ extern void psignal PARAMS ((unsigned, const char *));
extern int fclose (); extern int fclose ();
#ifndef atof
extern double atof (); extern double atof ();
#endif
#ifndef MALLOC_INCOMPATIBLE #ifndef MALLOC_INCOMPATIBLE
@ -740,25 +744,6 @@ extern void set_endian_from_file PARAMS ((bfd *));
#endif /* defined (TARGET_BYTE_ORDER_SELECTABLE) */ #endif /* defined (TARGET_BYTE_ORDER_SELECTABLE) */
#endif /* BITS_BIG_ENDIAN not defined. */ #endif /* BITS_BIG_ENDIAN not defined. */
/* Swap LEN bytes at BUFFER between target and host byte-order. */
#define SWAP_TARGET_AND_HOST(buffer,len) \
do \
{ \
if (TARGET_BYTE_ORDER != HOST_BYTE_ORDER) \
{ \
char tmp; \
char *p = (char *)(buffer); \
char *q = ((char *)(buffer)) + len - 1; \
for (; p < q; p++, q--) \
{ \
tmp = *q; \
*q = *p; \
*p = tmp; \
} \
} \
} \
while (0)
/* In findvar.c. */ /* In findvar.c. */
extern LONGEST extract_signed_integer PARAMS ((void *, int)); extern LONGEST extract_signed_integer PARAMS ((void *, int));

View File

@ -546,6 +546,31 @@ vmap_ldinfo (ldi)
} while (ldi->ldinfo_next } while (ldi->ldinfo_next
&& (ldi = (void *) (ldi->ldinfo_next + (char *) ldi))); && (ldi = (void *) (ldi->ldinfo_next + (char *) ldi)));
/* If we don't find the symfile_objfile anywhere in the ldinfo, it
is unlikely that the symbol file is relocated to the proper
address. And we might have attached to a process which is
running a different copy of the same executable. */
for (got_one = 0, vp = vmap; vp != NULL; vp = vp->nxt)
{
if (symfile_objfile == vp->objfile)
{
got_one = 1;
break;
}
}
if (symfile_objfile != NULL && !got_one)
{
warning_begin ();
fputs_unfiltered ("Symbol file ", gdb_stderr);
fputs_unfiltered (symfile_objfile->name, gdb_stderr);
fputs_unfiltered ("\nis not mapped; discarding it.\n\
If in fact that file has symbols which the mapped files listed by\n\
\"info files\" lack, you can load symbols with the \"symbol-file\" or\n\
\"add-symbol-file\" commands (note that you must take care of relocating\n\
symbols to the proper address).\n", gdb_stderr);
free_objfile (symfile_objfile);
symfile_objfile = NULL;
}
} }
/* As well as symbol tables, exec_sections need relocation. After /* As well as symbol tables, exec_sections need relocation. After

View File

@ -223,23 +223,30 @@ null_cleanup (arg)
} }
/* Provide a hook for modules wishing to print their own warning messages /* Print a warning message. Way to use this is to call warning_begin,
to set up the terminal state in a compatible way, without them having output the warning message (use unfiltered output to gdb_stderr),
to import all the target_<...> macros. */ ending in a newline. There is not currently a warning_end that you
call afterwards, but such a thing might be added if it is useful
for a GUI to separate warning messages from other output.
FIXME: Why do warnings use unfiltered output and errors filtered?
Is this anything other than a historical accident? */
void void
warning_setup () warning_begin ()
{ {
target_terminal_ours (); target_terminal_ours ();
wrap_here(""); /* Force out any buffered output */ wrap_here(""); /* Force out any buffered output */
gdb_flush (gdb_stdout); gdb_flush (gdb_stdout);
if (warning_pre_print)
fprintf_unfiltered (gdb_stderr, warning_pre_print);
} }
/* Print a warning message. /* Print a warning message.
The first argument STRING is the warning message, used as a fprintf string, The first argument STRING is the warning message, used as a fprintf string,
and the remaining args are passed as arguments to it. and the remaining args are passed as arguments to it.
The primary difference between warnings and errors is that a warning The primary difference between warnings and errors is that a warning
does not force the return to command level. */ does not force the return to command level. */
/* VARARGS */ /* VARARGS */
void void
@ -250,11 +257,7 @@ warning (va_alist)
char *string; char *string;
va_start (args); va_start (args);
target_terminal_ours (); warning_begin ();
wrap_here(""); /* Force out any buffered output */
gdb_flush (gdb_stdout);
if (warning_pre_print)
fprintf_unfiltered (gdb_stderr, warning_pre_print);
string = va_arg (args, char *); string = va_arg (args, char *);
vfprintf_unfiltered (gdb_stderr, string, args); vfprintf_unfiltered (gdb_stderr, string, args);
fprintf_unfiltered (gdb_stderr, "\n"); fprintf_unfiltered (gdb_stderr, "\n");
@ -262,10 +265,12 @@ warning (va_alist)
} }
/* Start the printing of an error message. Way to use this is to call /* Start the printing of an error message. Way to use this is to call
this, output the error message (use filtered output), and then call this, output the error message (use filtered output to gdb_stderr
return_to_top_level (RETURN_ERROR). error() provides a convenient way to (FIXME: Some callers, like memory_error, use gdb_stdout)), ending
do this for the special case that the error message can be formatted with in a newline, and then call return_to_top_level (RETURN_ERROR).
a single printf call, but this is more general. */ error() provides a convenient way to do this for the special case
that the error message can be formatted with a single printf call,
but this is more general. */
void void
error_begin () error_begin ()
{ {