X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fnbsd-nat.c;h=e7f91bebb0df670955c20016ee518e5a601f3748;hb=f6044a4be7f6f04e96f145ba045608e75e1e852b;hp=7f5df6611abaea6eb6719f218369796ada9739c9;hpb=0270a750ba588a8ad521e68be851772bac9c44f1;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/nbsd-nat.c b/gdb/nbsd-nat.c index 7f5df6611a..e7f91bebb0 100644 --- a/gdb/nbsd-nat.c +++ b/gdb/nbsd-nat.c @@ -1,6 +1,6 @@ /* Native-dependent code for NetBSD. - Copyright (C) 2006-2012 Free Software Foundation, Inc. + Copyright (C) 2006-2020 Free Software Foundation, Inc. This file is part of GDB. @@ -19,27 +19,25 @@ #include "defs.h" -#include - #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. */ char * -nbsd_pid_to_exec_file (int pid) +nbsd_nat_target::pid_to_exec_file (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) == -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; }