X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fnbsd-nat.c;h=92a6955ad8cfe630c5b21b56d2ced15c596cdfa6;hb=2b2798cc9716f45f752ea03411b6f9c9afc17cc6;hp=1f6a1854a52922a6cdb41784139b9cf7761fcd68;hpb=9b254dd1ce46c19dde1dde5b8d1e22e862dfacce;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/nbsd-nat.c b/gdb/nbsd-nat.c index 1f6a1854a5..92a6955ad8 100644 --- a/gdb/nbsd-nat.c +++ b/gdb/nbsd-nat.c @@ -1,6 +1,6 @@ /* Native-dependent code for NetBSD. - Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 2006-2016 Free Software Foundation, Inc. This file is part of GDB. @@ -19,27 +19,25 @@ #include "defs.h" -#include - #include "nbsd-nat.h" -/* Return a the name of file that can be opened to get the symbols for +/* Return the name of a file that can be opened to get the symbols for the child process identified by PID. */ char * -nbsd_pid_to_exec_file (int pid) +nbsd_pid_to_exec_file (struct target_ops *self, int pid) { - size_t len = MAXPATHLEN; - char *buf = xcalloc (len, sizeof (char)); - char *path; + ssize_t len; + static char buf[PATH_MAX]; + char name[PATH_MAX]; - path = xstrprintf ("/proc/%d/exe", pid); - if (readlink (path, buf, MAXPATHLEN) == -1) + xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid); + len = readlink (name, buf, PATH_MAX - 1); + if (len != -1) { - xfree (buf); - buf = NULL; + buf[len] = '\0'; + return buf; } - xfree (path); - return buf; + return NULL; }