diff options
author | Michael Snyder <msnyder@specifix.com> | 2002-01-09 02:21:25 +0000 |
---|---|---|
committer | Michael Snyder <msnyder@specifix.com> | 2002-01-09 02:21:25 +0000 |
commit | 25a8a418a5617446daf1fe7d41de902ac1bc8f16 (patch) | |
tree | da5e449364a61b844b5de8672dc9c33d7aa0299e /gdb/linux-proc.c | |
parent | 2dce247909758ba1de2a3e8d817534c196082525 (diff) | |
download | gdb-25a8a418a5617446daf1fe7d41de902ac1bc8f16.tar.gz |
2002-01-08 Michael Snyder <msnyder@redhat.com>
* linux-proc.c (child_pid_to_exec_file): Use readlink to get the
real name of the executable, rather than the /proc name.
Diffstat (limited to 'gdb/linux-proc.c')
-rw-r--r-- | gdb/linux-proc.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gdb/linux-proc.c b/gdb/linux-proc.c index 4d48b8d16ea..3ccab9ced94 100644 --- a/gdb/linux-proc.c +++ b/gdb/linux-proc.c @@ -37,11 +37,19 @@ char * child_pid_to_exec_file (int pid) { - static char fname[MAXPATHLEN]; + char *name1, *name2; - sprintf (fname, "/proc/%d/exe", pid); - /* FIXME use readlink to get the real name. */ - return fname; + name1 = xmalloc (MAXPATHLEN); + name2 = xmalloc (MAXPATHLEN); + make_cleanup (xfree, name1); + make_cleanup (xfree, name2); + memset (name2, 0, MAXPATHLEN); + + sprintf (name1, "/proc/%d/exe", pid); + if (readlink (name1, name2, MAXPATHLEN) > 0) + return name2; + else + return name1; } /* Function: linux_find_memory_regions |