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 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)
* printcmd.c (print_address_numeric): Pass use_local to
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));
-
-#define putchar_unfiltered(C) putc_unfiltered(C)
+extern int putchar_unfiltered PARAMS ((int c));
extern void puts_filtered PARAMS ((char *));
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. */
extern char *warning_pre_print;
extern int
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 int fclose ();
+#ifndef atof
extern double atof ();
+#endif
#ifndef MALLOC_INCOMPATIBLE
#endif /* defined (TARGET_BYTE_ORDER_SELECTABLE) */
#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. */
extern LONGEST extract_signed_integer PARAMS ((void *, int));
} while (ldi->ldinfo_next
&& (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;
+ }
}
\f
/* As well as symbol tables, exec_sections need relocation. After
}
\f
-/* Provide a hook for modules wishing to print their own warning messages
- to set up the terminal state in a compatible way, without them having
- to import all the target_<...> macros. */
+/* Print a warning message. Way to use this is to call warning_begin,
+ output the warning message (use unfiltered output to gdb_stderr),
+ 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
-warning_setup ()
+warning_begin ()
{
target_terminal_ours ();
wrap_here(""); /* Force out any buffered output */
gdb_flush (gdb_stdout);
+ if (warning_pre_print)
+ fprintf_unfiltered (gdb_stderr, warning_pre_print);
}
/* Print a warning message.
The first argument STRING is the warning message, used as a fprintf string,
and the remaining args are passed as arguments to it.
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 */
void
char *string;
va_start (args);
- target_terminal_ours ();
- wrap_here(""); /* Force out any buffered output */
- gdb_flush (gdb_stdout);
- if (warning_pre_print)
- fprintf_unfiltered (gdb_stderr, warning_pre_print);
+ warning_begin ();
string = va_arg (args, char *);
vfprintf_unfiltered (gdb_stderr, string, args);
fprintf_unfiltered (gdb_stderr, "\n");
}
/* 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
- return_to_top_level (RETURN_ERROR). 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. */
+ this, output the error message (use filtered output to gdb_stderr
+ (FIXME: Some callers, like memory_error, use gdb_stdout)), ending
+ in a newline, and then call return_to_top_level (RETURN_ERROR).
+ 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
error_begin ()
{