aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorAleksandar Ristovski <aristovski@qnx.com>2015-10-20 13:11:53 -0400
committerAleksandar Ristovski <aristovski@qnx.com>2015-10-20 13:11:53 -0400
commite5343fde2046fbc19b9ac91326d5829d40066872 (patch)
tree302c0e85d30f920a4a2fe8bb5e986b7e53bf5cbc /gdb
parent8a6c0ccdd27188047da2be9c2a49544c27dcade3 (diff)
downloadgdb-e5343fde2046fbc19b9ac91326d5829d40066872.zip
gdb-e5343fde2046fbc19b9ac91326d5829d40066872.tar.gz
gdb-e5343fde2046fbc19b9ac91326d5829d40066872.tar.bz2
[nto] Implement procfs_pid_to_exec_file.
gdb/ChangeLog: * gdb/nto-procfs.c (procfs_pid_to_exec_file): New function. (init_procfs_targets): Wire new function.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/nto-procfs.c28
2 files changed, 33 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 919f81d..b934297 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2015-10-20 Aleksandar Ristovski <aristovski@qnx.com>
+ * gdb/nto-procfs.c (procfs_pid_to_exec_file): New function.
+ (init_procfs_targets): Wire new function.
+
+2015-10-20 Aleksandar Ristovski <aristovski@qnx.com>
+
* nto-procfs.c (sys/auxv.h): Include.
(procfs_xfer_partial): Implement TARGET_OBJECT_AUXV.
* nto-tdep.c (nto_read_auxv_from_initial_stack): New function.
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index eb0f7be..82b428c 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -617,6 +617,33 @@ procfs_files_info (struct target_ops *ignore)
(nodestr != NULL) ? nodestr : "local node");
}
+/* Target to_pid_to_exec_file implementation. */
+
+static char *
+procfs_pid_to_exec_file (struct target_ops *ops, const int pid)
+{
+ int proc_fd;
+ static char proc_path[PATH_MAX];
+ ssize_t rd;
+
+ /* Read exe file name. */
+ snprintf (proc_path, sizeof (proc_path), "%s/proc/%d/exefile",
+ (nodestr != NULL) ? nodestr : "", pid);
+ proc_fd = open (proc_path, O_RDONLY);
+ if (proc_fd == -1)
+ return NULL;
+
+ rd = read (proc_fd, proc_path, sizeof (proc_path) - 1);
+ close (proc_fd);
+ if (rd <= 0)
+ {
+ proc_path[0] = '\0';
+ return NULL;
+ }
+ proc_path[rd] = '\0';
+ return proc_path;
+}
+
/* Attach to process PID, then initialize for debugging it. */
static void
procfs_attach (struct target_ops *ops, const char *args, int from_tty)
@@ -1491,6 +1518,7 @@ init_procfs_targets (void)
t->to_interrupt = procfs_interrupt;
t->to_have_continuable_watchpoint = 1;
t->to_extra_thread_info = nto_extra_thread_info;
+ t->to_pid_to_exec_file = procfs_pid_to_exec_file;
nto_native_ops = t;