#include "charset.h"
#include "annotate.h"
#include "filenames.h"
+#include "symfile.h"
#include "inferior.h" /* for signed_pointer_to_address */
return make_my_cleanup (&cleanup_chain, do_ui_file_delete, arg);
}
+static void
+do_free_section_addr_info (void *arg)
+{
+ free_section_addr_info (arg);
+}
+
+struct cleanup *
+make_cleanup_free_section_addr_info (struct section_addr_info *addrs)
+{
+ return make_my_cleanup (&cleanup_chain, do_free_section_addr_info, addrs);
+}
+
+
struct cleanup *
make_my_cleanup (struct cleanup **pmy_chain, make_cleanup_ftype *function,
void *arg)
so that the user knows that they are living on the edge. */
{
char *msg;
- xvasprintf (&msg, fmt, ap);
- xasprintf (&reason, "\
+ msg = xstrvprintf (fmt, ap);
+ reason = xstrprintf ("\
%s:%d: %s: %s\n\
A problem internal to GDB has been detected,\n\
further debugging may prove unreliable.", file, line, problem->name, msg);
}
static struct internal_problem internal_warning_problem = {
- "internal-error", AUTO_BOOLEAN_AUTO, AUTO_BOOLEAN_AUTO
+ "internal-warning", AUTO_BOOLEAN_AUTO, AUTO_BOOLEAN_AUTO
};
void
request_quit (int signo)
{
quit_flag = 1;
- /* Restore the signal handler. Harmless with BSD-style signals, needed
- for System V-style signals. So just always do it, rather than worrying
- about USG defines and stuff like that. */
+ /* Restore the signal handler. Harmless with BSD-style signals,
+ needed for System V-style signals. */
signal (signo, request_quit);
if (immediate_quit)
quit ();
}
\f
-/* Memory management stuff (malloc friends). */
-
-static void *
-mmalloc (void *md, size_t size)
-{
- return malloc (size); /* NOTE: GDB's only call to malloc() */
-}
-
-static void *
-mrealloc (void *md, void *ptr, size_t size)
-{
- if (ptr == 0) /* Guard against old realloc's */
- return mmalloc (md, size);
- else
- return realloc (ptr, size); /* NOTE: GDB's only call to ralloc() */
-}
-
-static void *
-mcalloc (void *md, size_t number, size_t size)
-{
- return calloc (number, size); /* NOTE: GDB's only call to calloc() */
-}
-
-static void
-mfree (void *md, void *ptr)
-{
- free (ptr); /* NOTE: GDB's only call to free() */
-}
-
-/* This used to do something interesting with USE_MMALLOC.
- * It can be retired any time. -- chastain 2004-01-19. */
-void
-init_malloc (void *md)
-{
-}
-
/* Called when a memory allocation fails, with the number of bytes of
memory requested in SIZE. */
}
}
-/* The xmmalloc() family of memory management routines.
+/* The xmalloc() (libiberty.h) family of memory management routines.
- These are are like the mmalloc() family except that they implement
+ These are like the ISO-C malloc() family except that they implement
consistent semantics and guard against typical memory management
- problems: if a malloc fails, an internal error is thrown; if
- free(NULL) is called, it is ignored; if *alloc(0) is called, NULL
- is returned.
+ problems. */
- All these routines are implemented using the mmalloc() family. */
+/* NOTE: These are declared using PTR to ensure consistency with
+ "libiberty.h". xfree() is GDB local. */
-void *
-xmmalloc (void *md, size_t size)
+PTR /* OK: PTR */
+xmalloc (size_t size)
{
void *val;
if (size == 0)
size = 1;
- val = mmalloc (md, size);
+ val = malloc (size); /* OK: malloc */
if (val == NULL)
nomem (size);
return (val);
}
-void *
-xmrealloc (void *md, void *ptr, size_t size)
+PTR /* OK: PTR */
+xrealloc (PTR ptr, size_t size) /* OK: PTR */
{
void *val;
size = 1;
if (ptr != NULL)
- val = mrealloc (md, ptr, size);
+ val = realloc (ptr, size); /* OK: realloc */
else
- val = mmalloc (md, size);
+ val = malloc (size); /* OK: malloc */
if (val == NULL)
nomem (size);
return (val);
}
-void *
-xmcalloc (void *md, size_t number, size_t size)
+PTR /* OK: PTR */
+xcalloc (size_t number, size_t size)
{
void *mem;
size = 1;
}
- mem = mcalloc (md, number, size);
+ mem = calloc (number, size); /* OK: xcalloc */
if (mem == NULL)
nomem (number * size);
return mem;
}
-void
-xmfree (void *md, void *ptr)
-{
- if (ptr != NULL)
- mfree (md, ptr);
-}
-
-/* The xmalloc() (libiberty.h) family of memory management routines.
-
- These are like the ISO-C malloc() family except that they implement
- consistent semantics and guard against typical memory management
- problems. See xmmalloc() above for further information.
-
- All these routines are wrappers to the xmmalloc() family. */
-
-/* NOTE: These are declared using PTR to ensure consistency with
- "libiberty.h". xfree() is GDB local. */
-
-PTR /* OK: PTR */
-xmalloc (size_t size)
-{
- return xmmalloc (NULL, size);
-}
-
-PTR /* OK: PTR */
-xrealloc (PTR ptr, size_t size) /* OK: PTR */
-{
- return xmrealloc (NULL, ptr, size);
-}
-
-PTR /* OK: PTR */
-xcalloc (size_t number, size_t size)
-{
- return xmcalloc (NULL, number, size);
-}
-
void
xfree (void *ptr)
{
- xmfree (NULL, ptr);
+ if (ptr != NULL)
+ free (ptr); /* OK: free */
}
\f
char *ret;
va_list args;
va_start (args, format);
- xvasprintf (&ret, format, args);
+ ret = xstrvprintf (format, args);
va_end (args);
return ret;
}
{
va_list args;
va_start (args, format);
- xvasprintf (ret, format, args);
+ (*ret) = xstrvprintf (format, args);
va_end (args);
}
void
xvasprintf (char **ret, const char *format, va_list ap)
{
- int status = vasprintf (ret, format, ap);
- /* NULL could be returned due to a memory allocation problem; a
- badly format string; or something else. */
- if ((*ret) == NULL)
- internal_error (__FILE__, __LINE__,
- "vasprintf returned NULL buffer (errno %d)", errno);
- /* A negative status with a non-NULL buffer shouldn't never
- happen. But to be sure. */
+ (*ret) = xstrvprintf (format, ap);
+}
+
+char *
+xstrvprintf (const char *format, va_list ap)
+{
+ char *ret = NULL;
+ int status = vasprintf (&ret, format, ap);
+ /* NULL is returned when there was a memory allocation problem. */
+ if (ret == NULL)
+ nomem (0);
+ /* A negative status (the printed length) with a non-NULL buffer
+ should never happen, but just to be sure. */
if (status < 0)
internal_error (__FILE__, __LINE__,
"vasprintf call failed (errno %d)", errno);
+ return ret;
}
-
/* My replacement for the read system call.
Used like `read' but keeps going if `read' returns too soon. */
char *
msavestring (void *md, const char *ptr, size_t size)
{
- char *p = (char *) xmmalloc (md, size + 1);
+ char *p = (char *) xmalloc (size + 1);
memcpy (p, ptr, size);
p[size] = 0;
return p;
char *linebuffer;
struct cleanup *old_cleanups;
- xvasprintf (&linebuffer, format, args);
+ linebuffer = xstrvprintf (format, args);
old_cleanups = make_cleanup (xfree, linebuffer);
fputs_maybe_filtered (linebuffer, stream, filter);
do_cleanups (old_cleanups);
char *linebuffer;
struct cleanup *old_cleanups;
- xvasprintf (&linebuffer, format, args);
+ linebuffer = xstrvprintf (format, args);
old_cleanups = make_cleanup (xfree, linebuffer);
fputs_unfiltered (linebuffer, stream);
do_cleanups (old_cleanups);
c = add_set_cmd ("width", class_support, var_uinteger, &chars_per_line,
"Set number of characters gdb thinks are in a line.",
&setlist);
- add_show_from_set (c, &showlist);
+ deprecated_add_show_from_set (c, &showlist);
set_cmd_sfunc (c, set_width_command);
c = add_set_cmd ("height", class_support, var_uinteger, &lines_per_page,
"Set number of lines gdb thinks are in a page.", &setlist);
- add_show_from_set (c, &showlist);
+ deprecated_add_show_from_set (c, &showlist);
set_cmd_sfunc (c, set_height_command);
init_page_info ();
- add_show_from_set
+ deprecated_add_show_from_set
(add_set_cmd ("demangle", class_support, var_boolean,
(char *) &demangle,
"Set demangling of encoded C++/ObjC names when displaying symbols.",
&setprintlist), &showprintlist);
- add_show_from_set
+ deprecated_add_show_from_set
(add_set_cmd ("pagination", class_support,
var_boolean, (char *) &pagination_enabled,
"Set state of pagination.", &setlist), &showlist);
"Disable pagination");
}
- add_show_from_set
+ deprecated_add_show_from_set
(add_set_cmd ("sevenbit-strings", class_support, var_boolean,
(char *) &sevenbit_strings,
"Set printing of 8-bit characters in strings as \\nnn.",
&setprintlist), &showprintlist);
- add_show_from_set
+ deprecated_add_show_from_set
(add_set_cmd ("asm-demangle", class_support, var_boolean,
(char *) &asm_demangle,
"Set demangling of C++/ObjC names in disassembly listings.",