/* General utility routines for GDB, the GNU debugger.
- Copyright 1986, 89, 90, 91, 92, 95, 96, 1998 Free Software Foundation, Inc.
+ Copyright 1986, 1989, 1990-1992, 1995, 1996, 1998, 2000
+ Free Software Foundation, Inc.
This file is part of GDB.
#include <term.h>
#endif
+#ifdef __GO32__
+#include <pc.h>
+#endif
+
/* SunOS's curses.h has a '#define reg register' in it. Thank you Sun. */
#ifdef reg
#undef reg
/* Holds the last error message issued by gdb */
-static GDB_FILE *gdb_lasterr;
+static struct ui_file *gdb_lasterr;
/* Prototypes for local functions */
-static void vfprintf_maybe_filtered PARAMS ((GDB_FILE *, const char *,
- va_list, int));
+static void vfprintf_maybe_filtered (struct ui_file *, const char *,
+ va_list, int);
-static void fputs_maybe_filtered PARAMS ((const char *, GDB_FILE *, int));
+static void fputs_maybe_filtered (const char *, struct ui_file *, int);
#if defined (USE_MMALLOC) && !defined (NO_MMCHECK)
static void malloc_botch PARAMS ((void));
static void
set_width PARAMS ((void));
-#ifndef GDB_FILE_ISATTY
-#define GDB_FILE_ISATTY(GDB_FILE_PTR) (gdb_file_isatty(GDB_FILE_PTR))
-#endif
-
/* Chain of cleanup actions established with make_cleanup,
to be executed if an error happens. */
Args are FUNCTION to clean up with, and ARG to pass to it. */
struct cleanup *
-make_cleanup (function, arg)
- void (*function) PARAMS ((PTR));
- PTR arg;
+make_cleanup (make_cleanup_ftype *function, void *arg)
{
return make_my_cleanup (&cleanup_chain, function, arg);
}
struct cleanup *
-make_final_cleanup (function, arg)
- void (*function) PARAMS ((PTR));
- PTR arg;
+make_final_cleanup (make_cleanup_ftype *function, void *arg)
{
return make_my_cleanup (&final_cleanup_chain, function, arg);
}
struct cleanup *
-make_run_cleanup (function, arg)
- void (*function) PARAMS ((PTR));
- PTR arg;
+make_run_cleanup (make_cleanup_ftype *function, void *arg)
{
return make_my_cleanup (&run_cleanup_chain, function, arg);
}
struct cleanup *
-make_exec_cleanup (function, arg)
- void (*function) PARAMS ((PTR));
- PTR arg;
+make_exec_cleanup (make_cleanup_ftype *function, void *arg)
{
return make_my_cleanup (&exec_cleanup_chain, function, arg);
}
struct cleanup *
-make_exec_error_cleanup (function, arg)
- void (*function) PARAMS ((PTR));
- PTR arg;
+make_exec_error_cleanup (make_cleanup_ftype *function, void *arg)
{
return make_my_cleanup (&exec_error_cleanup_chain, function, arg);
}
}
static void
-do_gdb_file_delete (void *arg)
+do_bfd_close_cleanup (void *arg)
{
- gdb_file_delete (arg);
+ bfd_close (arg);
}
struct cleanup *
-make_cleanup_gdb_file_delete (struct gdb_file *arg)
+make_cleanup_bfd_close (bfd *abfd)
{
- return make_my_cleanup (&cleanup_chain, do_gdb_file_delete, arg);
+ return make_cleanup (do_bfd_close_cleanup, abfd);
+}
+
+static void
+do_ui_file_delete (void *arg)
+{
+ ui_file_delete (arg);
}
struct cleanup *
-make_my_cleanup (pmy_chain, function, arg)
- struct cleanup **pmy_chain;
- void (*function) PARAMS ((PTR));
- PTR arg;
+make_cleanup_ui_file_delete (struct ui_file *arg)
+{
+ return make_my_cleanup (&cleanup_chain, do_ui_file_delete, arg);
+}
+
+struct cleanup *
+make_my_cleanup (struct cleanup **pmy_chain, make_cleanup_ftype *function,
+ void *arg)
{
register struct cleanup *new
= (struct cleanup *) xmalloc (sizeof (struct cleanup));
while ((ptr = *pmy_chain) != old_chain)
{
*pmy_chain = ptr->next;
- free ((PTR) ptr);
+ free (ptr);
}
}
to arrange to free the object thus allocated. */
void
-free_current_contents (location)
- char **location;
+free_current_contents (void *ptr)
{
- free (*location);
+ void **location = ptr;
+ if (location == NULL)
+ internal_error ("free_current_contents: NULL pointer");
+ if (*location != NULL)
+ {
+ free (*location);
+ *location = NULL;
+ }
}
/* Provide a known function that does nothing, to use as a base for
/* ARGSUSED */
void
-null_cleanup (arg)
- PTR arg;
+null_cleanup (void *arg)
{
}
}
}
-/* Add a continuation to the continuation list, the gloabl list
+/* Add a continuation to the continuation list, the global list
intermediate_continuation. The new continuation will be added at the front.*/
void
add_intermediate_continuation (continuation_hook, arg_list)
va_list twice which works on some platforms and fails miserably on
others. */
/* Save it as the last error */
- gdb_file_rewind (gdb_lasterr);
+ ui_file_rewind (gdb_lasterr);
vfprintf_filtered (gdb_lasterr, string, args);
/* Retrieve the last error and print it to gdb_stderr */
err_string = error_last_message ();
}
NORETURN void
-error_stream (GDB_FILE *stream)
+error_stream (struct ui_file *stream)
{
long size;
- char *msg = gdb_file_xstrdup (stream, &size);
+ char *msg = ui_file_xstrdup (stream, &size);
make_cleanup (free, msg);
error ("%s", msg);
}
error_last_message (void)
{
long len;
- return gdb_file_xstrdup (gdb_lasterr, &len);
+ return ui_file_xstrdup (gdb_lasterr, &len);
}
/* This is to be called by main() at the very beginning */
}
/* Try to get the message out */
+ target_terminal_ours ();
fputs_unfiltered ("gdb-internal-error: ", gdb_stderr);
vfprintf_unfiltered (gdb_stderr, fmt, ap);
fputs_unfiltered ("\n", gdb_stderr);
{
va_list ap;
va_start (ap, string);
+
internal_verror (string, ap);
va_end (ap);
}
#if !defined (USE_MMALLOC)
-void *
-mcalloc (void *md, size_t number, size_t size)
+PTR
+mcalloc (PTR md, size_t number, size_t size)
{
return calloc (number, size);
}
#if !defined (USE_MMALLOC) || defined (NO_MMCHECK)
void
-init_malloc (md)
- PTR md;
+init_malloc (void *md)
{
}
#endif
void
-init_malloc (md)
- PTR md;
+init_malloc (void *md)
{
if (!mmcheckf (md, malloc_botch, MMCHECK_FORCE))
{
}
char *
-msavestring (md, ptr, size)
- PTR md;
- const char *ptr;
- int size;
+msavestring (void *md, const char *ptr, int size)
{
register char *p = (char *) xmmalloc (md, size + 1);
memcpy (p, ptr, size);
}
char *
-mstrsave (md, ptr)
- PTR md;
- const char *ptr;
+mstrsave (void *md, const char *ptr)
{
return (msavestring (md, ptr, strlen (ptr)));
}
void
print_spaces (n, file)
register int n;
- register GDB_FILE *file;
+ register struct ui_file *file;
{
fputs_unfiltered (n_spaces (n), file);
}
/* Print a host address. */
void
-gdb_print_host_address (void *addr, struct gdb_file *stream)
+gdb_print_host_address (void *addr, struct ui_file *stream)
{
/* We could use the %p conversion specifier to fprintf if we had any
be call for printing things which are independent of the language
of the program being debugged. */
-static void printchar PARAMS ((int c, void (*do_fputs) (const char *, GDB_FILE*), void (*do_fprintf) (GDB_FILE*, const char *, ...), GDB_FILE *stream, int quoter));
+static void printchar (int c, void (*do_fputs) (const char *, struct ui_file*), void (*do_fprintf) (struct ui_file*, const char *, ...), struct ui_file *stream, int quoter);
static void
printchar (c, do_fputs, do_fprintf, stream, quoter)
int c;
- void (*do_fputs) PARAMS ((const char *, GDB_FILE*));
- void (*do_fprintf) PARAMS ((GDB_FILE*, const char *, ...));
- GDB_FILE *stream;
+ void (*do_fputs) PARAMS ((const char *, struct ui_file*));
+ void (*do_fprintf) PARAMS ((struct ui_file*, const char *, ...));
+ struct ui_file *stream;
int quoter;
{
fputstr_filtered (str, quoter, stream)
const char *str;
int quoter;
- GDB_FILE *stream;
+ struct ui_file *stream;
{
while (*str)
printchar (*str++, fputs_filtered, fprintf_filtered, stream, quoter);
fputstr_unfiltered (str, quoter, stream)
const char *str;
int quoter;
- GDB_FILE *stream;
+ struct ui_file *stream;
{
while (*str)
printchar (*str++, fputs_unfiltered, fprintf_unfiltered, stream, quoter);
const char *str;
int n;
int quoter;
- GDB_FILE *stream;
+ struct ui_file *stream;
{
int i;
for (i = 0; i < n; i++)
#endif
#endif
/* If the output is not a terminal, don't paginate it. */
- if (!GDB_FILE_ISATTY (gdb_stdout))
+ if (!ui_file_isatty (gdb_stdout))
lines_per_page = UINT_MAX;
} /* the command_line_version */
set_width ();
static void
fputs_maybe_filtered (linebuffer, stream, filter)
const char *linebuffer;
- GDB_FILE *stream;
+ struct ui_file *stream;
int filter;
{
const char *lineptr;
void
fputs_filtered (linebuffer, stream)
const char *linebuffer;
- GDB_FILE *stream;
+ struct ui_file *stream;
{
fputs_maybe_filtered (linebuffer, stream, 1);
}
int c;
{
char buf = c;
- gdb_file_write (gdb_stdout, &buf, 1);
+ ui_file_write (gdb_stdout, &buf, 1);
return c;
}
int
fputc_unfiltered (c, stream)
int c;
- GDB_FILE *stream;
+ struct ui_file *stream;
{
char buf = c;
- gdb_file_write (stream, &buf, 1);
+ ui_file_write (stream, &buf, 1);
return c;
}
int
fputc_filtered (c, stream)
int c;
- GDB_FILE *stream;
+ struct ui_file *stream;
{
char buf[2];
static void
vfprintf_maybe_filtered (stream, format, args, filter)
- GDB_FILE *stream;
+ struct ui_file *stream;
const char *format;
va_list args;
int filter;
void
vfprintf_filtered (stream, format, args)
- GDB_FILE *stream;
+ struct ui_file *stream;
const char *format;
va_list args;
{
void
vfprintf_unfiltered (stream, format, args)
- GDB_FILE *stream;
+ struct ui_file *stream;
const char *format;
va_list args;
{
}
void
-fprintf_filtered (GDB_FILE * stream, const char *format,...)
+fprintf_filtered (struct ui_file * stream, const char *format,...)
{
va_list args;
va_start (args, format);
}
void
-fprintf_unfiltered (GDB_FILE * stream, const char *format,...)
+fprintf_unfiltered (struct ui_file * stream, const char *format,...)
{
va_list args;
va_start (args, format);
Called as fprintfi_filtered (spaces, stream, format, ...); */
void
-fprintfi_filtered (int spaces, GDB_FILE * stream, const char *format,...)
+fprintfi_filtered (int spaces, struct ui_file * stream, const char *format,...)
{
va_list args;
va_start (args, format);
void
print_spaces_filtered (n, stream)
int n;
- GDB_FILE *stream;
+ struct ui_file *stream;
{
fputs_filtered (n_spaces (n), stream);
}
void
fprintf_symbol_filtered (stream, name, lang, arg_mode)
- GDB_FILE *stream;
+ struct ui_file *stream;
char *name;
enum language lang;
int arg_mode;
init_page_info ();
/* If the output is not a terminal, don't paginate it. */
- if (!GDB_FILE_ISATTY (gdb_stdout))
+ if (!ui_file_isatty (gdb_stdout))
lines_per_page = UINT_MAX;
set_width_command ((char *) NULL, 0, c);
var_boolean, (char *) &pagination_enabled,
"Set state of pagination.", &setlist),
&showlist);
+
if (xdb_commands)
{
add_com ("am", class_support, pagination_on_command,
unsigned char *uto = (unsigned char *) to;
memcpy (&dfrom, from, sizeof (dfrom));
- memset (uto, 0, fmt->totalsize / FLOATFORMAT_CHAR_BIT);
+ memset (uto, 0, (fmt->totalsize + FLOATFORMAT_CHAR_BIT - 1)
+ / FLOATFORMAT_CHAR_BIT);
if (dfrom == 0)
return; /* Result is zero */
if (dfrom != dfrom) /* Result is NaN */
mant_bits = mant_bits_left < 32 ? mant_bits_left : 32;
mant *= 4294967296.0;
- mant_long = (unsigned long) mant;
+ mant_long = ((unsigned long) mant) & 0xffffffffL;
mant -= mant_long;
/* If the integer bit is implicit, then we need to discard it.
&& fmt->intbit == floatformat_intbit_no)
{
mant_long <<= 1;
+ mant_long &= 0xffffffffL;
mant_bits -= 1;
}
}
return preg_str;
}
-
-/* Helper functions for INNER_THAN */
-int
-core_addr_lessthan (lhs, rhs)
- CORE_ADDR lhs;
- CORE_ADDR rhs;
-{
- return (lhs < rhs);
-}
-
-int
-core_addr_greaterthan (lhs, rhs)
- CORE_ADDR lhs;
- CORE_ADDR rhs;
-{
- return (lhs > rhs);
-}