GNU Binutils with patches for OS216
Revision | e5343fde2046fbc19b9ac91326d5829d40066872 (tree) |
---|---|
Time | 2015-10-21 02:11:53 |
Author | Aleksandar Ristovski <aristovski@qnx....> |
Commiter | Aleksandar Ristovski |
[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.
@@ -1,5 +1,10 @@ | ||
1 | 1 | 2015-10-20 Aleksandar Ristovski <aristovski@qnx.com> |
2 | 2 | |
3 | + * gdb/nto-procfs.c (procfs_pid_to_exec_file): New function. | |
4 | + (init_procfs_targets): Wire new function. | |
5 | + | |
6 | +2015-10-20 Aleksandar Ristovski <aristovski@qnx.com> | |
7 | + | |
3 | 8 | * nto-procfs.c (sys/auxv.h): Include. |
4 | 9 | (procfs_xfer_partial): Implement TARGET_OBJECT_AUXV. |
5 | 10 | * nto-tdep.c (nto_read_auxv_from_initial_stack): New function. |
@@ -617,6 +617,33 @@ procfs_files_info (struct target_ops *ignore) | ||
617 | 617 | (nodestr != NULL) ? nodestr : "local node"); |
618 | 618 | } |
619 | 619 | |
620 | +/* Target to_pid_to_exec_file implementation. */ | |
621 | + | |
622 | +static char * | |
623 | +procfs_pid_to_exec_file (struct target_ops *ops, const int pid) | |
624 | +{ | |
625 | + int proc_fd; | |
626 | + static char proc_path[PATH_MAX]; | |
627 | + ssize_t rd; | |
628 | + | |
629 | + /* Read exe file name. */ | |
630 | + snprintf (proc_path, sizeof (proc_path), "%s/proc/%d/exefile", | |
631 | + (nodestr != NULL) ? nodestr : "", pid); | |
632 | + proc_fd = open (proc_path, O_RDONLY); | |
633 | + if (proc_fd == -1) | |
634 | + return NULL; | |
635 | + | |
636 | + rd = read (proc_fd, proc_path, sizeof (proc_path) - 1); | |
637 | + close (proc_fd); | |
638 | + if (rd <= 0) | |
639 | + { | |
640 | + proc_path[0] = '\0'; | |
641 | + return NULL; | |
642 | + } | |
643 | + proc_path[rd] = '\0'; | |
644 | + return proc_path; | |
645 | +} | |
646 | + | |
620 | 647 | /* Attach to process PID, then initialize for debugging it. */ |
621 | 648 | static void |
622 | 649 | procfs_attach (struct target_ops *ops, const char *args, int from_tty) |
@@ -1491,6 +1518,7 @@ init_procfs_targets (void) | ||
1491 | 1518 | t->to_interrupt = procfs_interrupt; |
1492 | 1519 | t->to_have_continuable_watchpoint = 1; |
1493 | 1520 | t->to_extra_thread_info = nto_extra_thread_info; |
1521 | + t->to_pid_to_exec_file = procfs_pid_to_exec_file; | |
1494 | 1522 | |
1495 | 1523 | nto_native_ops = t; |
1496 | 1524 |