mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-25 16:57:52 +00:00
Introduce linux_proc_pid_to_exec_file
This commit introduces a new function linux_proc_pid_to_exec_file that shared Linux code can use to discover the filename of the executable that was run to create a process on the system. gdb/ChangeLog: * nat/linux-procfs.h (linux_proc_pid_to_exec_file): New declaration. * nat/linux-procfs.c (linux_proc_pid_to_exec_file): New function, factored out from... * linux-nat.c (linux_child_pid_to_exec_file): ...here.
This commit is contained in:
@@ -4106,15 +4106,7 @@ linux_nat_thread_name (struct target_ops *self, struct thread_info *thr)
|
||||
static char *
|
||||
linux_child_pid_to_exec_file (struct target_ops *self, int pid)
|
||||
{
|
||||
static char buf[PATH_MAX];
|
||||
char name[PATH_MAX];
|
||||
|
||||
xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid);
|
||||
memset (buf, 0, PATH_MAX);
|
||||
if (readlink (name, buf, PATH_MAX - 1) <= 0)
|
||||
strcpy (buf, name);
|
||||
|
||||
return buf;
|
||||
return linux_proc_pid_to_exec_file (pid);
|
||||
}
|
||||
|
||||
/* Implement the to_xfer_partial interface for memory reads using the /proc
|
||||
|
||||
Reference in New Issue
Block a user