gdb/gdbserver/utils.c - gdb
Functions defined
Macros defined
Source code
- #include "server.h"
- #ifdef IN_PROCESS_AGENT
- # define PREFIX "ipa: "
- # define TOOLNAME "GDBserver in-process agent"
- #else
- # define PREFIX "gdbserver: "
- # define TOOLNAME "GDBserver"
- #endif
- void
- malloc_failure (long size)
- {
- fprintf (stderr,
- PREFIX "ran out of memory while trying to allocate %lu bytes\n",
- (unsigned long) size);
- exit (1);
- }
- char *
- xstrdup (const char *s)
- {
- char *ret = strdup (s);
- if (ret == NULL)
- malloc_failure (strlen (s) + 1);
- return ret;
- }
- void
- perror_with_name (const char *string)
- {
- const char *err;
- char *combined;
- err = strerror (errno);
- if (err == NULL)
- err = "unknown error";
- combined = (char *) alloca (strlen (err) + strlen (string) + 3);
- strcpy (combined, string);
- strcat (combined, ": ");
- strcat (combined, err);
- error ("%s.", combined);
- }
- void
- verror (const char *string, va_list args)
- {
- #ifdef IN_PROCESS_AGENT
- fflush (stdout);
- vfprintf (stderr, string, args);
- fprintf (stderr, "\n");
- exit (1);
- #else
- throw_verror (GENERIC_ERROR, string, args);
- #endif
- }
- void
- vwarning (const char *string, va_list args)
- {
- fprintf (stderr, PREFIX);
- vfprintf (stderr, string, args);
- fprintf (stderr, "\n");
- }
- void
- internal_verror (const char *file, int line, const char *fmt, va_list args)
- {
- fprintf (stderr, "\
- %s:%d: A problem internal to " TOOLNAME " has been detected.\n", file, line);
- vfprintf (stderr, fmt, args);
- fprintf (stderr, "\n");
- exit (1);
- }
- void
- internal_vwarning (const char *file, int line, const char *fmt, va_list args)
- {
- fprintf (stderr, "\
- %s:%d: A problem internal to " TOOLNAME " has been detected.\n", file, line);
- vfprintf (stderr, fmt, args);
- fprintf (stderr, "\n");
- }
- char *
- paddress (CORE_ADDR addr)
- {
- return phex_nz (addr, sizeof (CORE_ADDR));
- }
- char *
- pfildes (gdb_fildes_t fd)
- {
- #if USE_WIN32API
- return phex_nz (fd, sizeof (gdb_fildes_t));
- #else
- return plongest (fd);
- #endif
- }
- void
- prepare_to_throw_exception (void)
- {
-
- }