Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / nbsd-nat.c
blob0151699d782fc022d61aed6a1aa01285ad0d5bf4
1 /* NetBSD-specific methods for using the /proc file system.
2 Copyright 2006 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 #include <sys/param.h>
23 #include "defs.h"
24 #include "nbsd-nat.h"
26 char *
27 nbsd_pid_to_exec_file (int pid)
29 size_t len = MAXPATHLEN;
30 char *buf = xcalloc (len, sizeof (char));
31 char *path;
33 path = xstrprintf ("/proc/%d/exe", pid);
34 if (readlink (path, buf, MAXPATHLEN) == -1)
36 xfree (buf);
37 buf = NULL;
40 xfree (path);
41 return buf;