X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fnbsd-nat.c;h=9205b2f9bc5ee5aa7e50958ddfbc7b8c00019665;hb=4da3eb35ef0545aac35dbd09070e5bf925f947d3;hp=50ba3c5a7239143a04fb30e8c16e2780a2178e30;hpb=766062f62f6362cdee0cdd33170002adea365fb2;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/nbsd-nat.c b/gdb/nbsd-nat.c index 50ba3c5a72..9205b2f9bc 100644 --- a/gdb/nbsd-nat.c +++ b/gdb/nbsd-nat.c @@ -1,7 +1,6 @@ /* Native-dependent code for NetBSD. - Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 - Free Software Foundation, Inc. + Copyright (C) 2006-2017 Free Software Foundation, Inc. This file is part of GDB. @@ -20,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_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; }