aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@vmware.com>2002-01-09 02:21:25 +0000
committerMichael Snyder <msnyder@vmware.com>2002-01-09 02:21:25 +0000
commit145fdc6e9f092290bd97b5868a4a925fe51a919f (patch)
tree15f08bbdcbe40a615a320a41b7595b65915b7bc0 /gdb
parenta911c3606d956a008cb681d2f1d35dd0cee668dc (diff)
downloadgdb-145fdc6e9f092290bd97b5868a4a925fe51a919f.zip
gdb-145fdc6e9f092290bd97b5868a4a925fe51a919f.tar.gz
gdb-145fdc6e9f092290bd97b5868a4a925fe51a919f.tar.bz2
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')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/linux-proc.c16
2 files changed, 17 insertions, 4 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 49eac08..e061622 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+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.
+
2002-01-03 Michael Snyder <msnyder@redhat.com>
Implement a "generate-core-file" command in gdb, save target state.
diff --git a/gdb/linux-proc.c b/gdb/linux-proc.c
index 4d48b8d..3ccab9c 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