mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-20 09:58:19 +08:00
Rewrite nbsd_nat_target::pid_to_exec_file to sysctl(3)
procfs on NetBSD is optional and not recommended. * nbsd-nat.c: Include <sys/types.h>, <sys/ptrace.h> and <sys/sysctl.h>. * nbsd-nat.c (nbsd_nat_target::pid_to_exec_file): Rewrite.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2020-03-17 Kamil Rytarowski <n54@gmx.com>
|
||||||
|
|
||||||
|
* nbsd-nat.c: Include <sys/types.h>, <sys/ptrace.h> and
|
||||||
|
<sys/sysctl.h>.
|
||||||
|
* nbsd-nat.c (nbsd_nat_target::pid_to_exec_file): Rewrite.
|
||||||
|
|
||||||
2020-03-17 Tom de Vries <tdevries@suse.de>
|
2020-03-17 Tom de Vries <tdevries@suse.de>
|
||||||
|
|
||||||
PR gdb/23710
|
PR gdb/23710
|
||||||
|
@ -21,23 +21,21 @@
|
|||||||
|
|
||||||
#include "nbsd-nat.h"
|
#include "nbsd-nat.h"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/ptrace.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
/* Return the name of a 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. */
|
the child process identified by PID. */
|
||||||
|
|
||||||
char *
|
char *
|
||||||
nbsd_nat_target::pid_to_exec_file (int pid)
|
nbsd_nat_target::pid_to_exec_file (int pid)
|
||||||
{
|
{
|
||||||
ssize_t len;
|
|
||||||
static char buf[PATH_MAX];
|
static char buf[PATH_MAX];
|
||||||
char name[PATH_MAX];
|
size_t buflen;
|
||||||
|
int mib[4] = {CTL_KERN, KERN_PROC_ARGS, pid, KERN_PROC_PATHNAME};
|
||||||
xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid);
|
buflen = sizeof (buf);
|
||||||
len = readlink (name, buf, PATH_MAX - 1);
|
if (sysctl (mib, ARRAY_SIZE (mib), buf, &buflen, NULL, 0))
|
||||||
if (len != -1)
|
|
||||||
{
|
|
||||||
buf[len] = '\0';
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
return buf;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user