2010-09-01 Joel Brobecker <brobecker@adacore.com>
+ * utils.c (xsnprintf): Make non-static.
+ * server.h: Add xsnprintf declaration.
+ * linux-low.c, nto-low.c, target.c, thread-db.c, tracepoint.c:
+ replace calls to snprintf by calls to xsnprintf throughout.
+
+2010-09-01 Joel Brobecker <brobecker@adacore.com>
+
* configure.ac: Add configure check for alloca.
* configure, config.in: Regenerate.
* server.h: Include alloca.h if it exists.
int fd, n;
int pid = lwpid_of (get_thread_lwp (current_inferior));
- snprintf (filename, sizeof filename, "/proc/%d/auxv", pid);
+ xsnprintf (filename, sizeof filename, "/proc/%d/auxv", pid);
fd = open (filename, O_RDONLY);
if (fd < 0)
close (nto_inferior.ctl_fd);
init_nto_inferior (&nto_inferior);
}
- snprintf (nto_inferior.nto_procfs_path, PATH_MAX - 1, "/proc/%d/as", pid);
+ xsnprintf (nto_inferior.nto_procfs_path, PATH_MAX - 1, "/proc/%d/as", pid);
nto_inferior.ctl_fd = open (nto_inferior.nto_procfs_path, O_RDWR);
if (nto_inferior.ctl_fd == -1)
{
void *xrealloc (void *, size_t);
void *xcalloc (size_t, size_t) ATTR_MALLOC;
char *xstrdup (const char *) ATTR_MALLOC;
+int xsnprintf (char *str, size_t size, const char *format, ...)
+ ATTR_FORMAT (printf, 3, 4);;
void freeargv (char **argv);
void perror_with_name (const char *string);
void error (const char *string,...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2);
static char buf[80];
if (ptid_equal (ptid, minus_one_ptid))
- snprintf (buf, sizeof (buf), "<all threads>");
+ xsnprintf (buf, sizeof (buf), "<all threads>");
else if (ptid_equal (ptid, null_ptid))
- snprintf (buf, sizeof (buf), "<null thread>");
+ xsnprintf (buf, sizeof (buf), "<null thread>");
else if (ptid_get_tid (ptid) != 0)
- snprintf (buf, sizeof (buf), "Thread %d.0x%lx",
- ptid_get_pid (ptid), ptid_get_tid (ptid));
+ xsnprintf (buf, sizeof (buf), "Thread %d.0x%lx",
+ ptid_get_pid (ptid), ptid_get_tid (ptid));
else if (ptid_get_lwp (ptid) != 0)
- snprintf (buf, sizeof (buf), "LWP %d.%ld",
- ptid_get_pid (ptid), ptid_get_lwp (ptid));
+ xsnprintf (buf, sizeof (buf), "LWP %d.%ld",
+ ptid_get_pid (ptid), ptid_get_lwp (ptid));
else
- snprintf (buf, sizeof (buf), "Process %d",
- ptid_get_pid (ptid));
+ xsnprintf (buf, sizeof (buf), "Process %d",
+ ptid_get_pid (ptid));
return buf;
}
return "version mismatch between libthread_db and libpthread";
#endif
default:
- snprintf (buf, sizeof (buf), "unknown thread_db error '%d'", err);
+ xsnprintf (buf, sizeof (buf), "unknown thread_db error '%d'", err);
return buf;
}
}
case TD_THR_STOPPED_ASLEEP:
return "stopped by debugger AND blocked";
default:
- snprintf (buf, sizeof (buf), "unknown thread_db state %d", state);
+ xsnprintf (buf, sizeof (buf), "unknown thread_db state %d", state);
return buf;
}
}
int res, fd;
char path[UNIX_PATH_MAX];
- res = snprintf (path, UNIX_PATH_MAX, "%s/gdb_ust%d", SOCK_DIR, pid);
+ res = xsnprintf (path, UNIX_PATH_MAX, "%s/gdb_ust%d", SOCK_DIR, pid);
if (res >= UNIX_PATH_MAX)
{
trace_debug ("string overflow allocating socket name");
addr.sun_family = AF_UNIX;
- res = snprintf (addr.sun_path, UNIX_PATH_MAX, "%s", path);
+ res = xsnprintf (addr.sun_path, UNIX_PATH_MAX, "%s", path);
if (res >= UNIX_PATH_MAX)
{
warning ("string overflow allocating socket name\n");
int result, fd;
char name[UNIX_PATH_MAX];
- result = snprintf (name, UNIX_PATH_MAX, "%s/gdb_ust%d",
- SOCK_DIR, getpid ());
+ result = xsnprintf (name, UNIX_PATH_MAX, "%s/gdb_ust%d",
+ SOCK_DIR, getpid ());
if (result >= UNIX_PATH_MAX)
{
trace_debug ("string overflow allocating socket name");
/* Stdarg wrapper around vsnprintf.
SIZE is the size of the buffer pointed to by STR. */
-static int
+int
xsnprintf (char *str, size_t size, const char *format, ...)
{
va_list args;