| Index: gdb/gdb_obstack.c
|
| diff --git a/gdb/nbsd-nat.c b/gdb/gdb_obstack.c
|
| similarity index 53%
|
| copy from gdb/nbsd-nat.c
|
| copy to gdb/gdb_obstack.c
|
| index 14b562f140f84166ac06030427b1f9f08208feae..df34968f3fc5e6006149716a1d630fb96cb0dd5f 100644
|
| --- a/gdb/nbsd-nat.c
|
| +++ b/gdb/gdb_obstack.c
|
| @@ -1,6 +1,6 @@
|
| -/* Native-dependent code for NetBSD.
|
| +/* Obstack wrapper for GDB.
|
|
|
| - Copyright (C) 2006-2012 Free Software Foundation, Inc.
|
| + Copyright (C) 2013 Free Software Foundation, Inc.
|
|
|
| This file is part of GDB.
|
|
|
| @@ -18,28 +18,30 @@
|
| along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
| #include "defs.h"
|
| +#include "gdb_obstack.h"
|
|
|
| -#include <sys/param.h>
|
| -
|
| -#include "nbsd-nat.h"
|
| -
|
| -/* Return the name of a file that can be opened to get the symbols for
|
| - the child process identified by PID. */
|
| +/* Concatenate NULL terminated variable argument list of `const char *'
|
| + strings; return the new string. Space is found in the OBSTACKP.
|
| + Argument list must be terminated by a sentinel expression `(char *)
|
| + NULL'. */
|
|
|
| char *
|
| -nbsd_pid_to_exec_file (int pid)
|
| +obconcat (struct obstack *obstackp, ...)
|
| {
|
| - size_t len = MAXPATHLEN;
|
| - char *buf = xcalloc (len, sizeof (char));
|
| - char *path;
|
| + va_list ap;
|
|
|
| - path = xstrprintf ("/proc/%d/exe", pid);
|
| - if (readlink (path, buf, MAXPATHLEN) == -1)
|
| + va_start (ap, obstackp);
|
| + for (;;)
|
| {
|
| - xfree (buf);
|
| - buf = NULL;
|
| + const char *s = va_arg (ap, const char *);
|
| +
|
| + if (s == NULL)
|
| + break;
|
| +
|
| + obstack_grow_str (obstackp, s);
|
| }
|
| + va_end (ap);
|
| + obstack_1grow (obstackp, 0);
|
|
|
| - xfree (path);
|
| - return buf;
|
| + return obstack_finish (obstackp);
|
| }
|
|
|