diff options
-rw-r--r-- | src/crash-stack/crash-stack.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/crash-stack/crash-stack.c b/src/crash-stack/crash-stack.c index a377306..2507055 100644 --- a/src/crash-stack/crash-stack.c +++ b/src/crash-stack/crash-stack.c @@ -793,9 +793,24 @@ void callstack_destructor(Callstack *callstack) } /** + * @brief Print full path of executable file + */ +static void __crash_stack_print_exe(FILE* outputfile, pid_t pid) +{ + char file_path[PATH_MAX]; + char link_path[PATH_MAX]; + + snprintf(link_path, PATH_MAX, "/proc/%d/exe", pid); + if (readlink(link_path, file_path, PATH_MAX) == -1) { + return; + } + fprintf(outputfile, "Executable File Path: %s\n", file_path); +} + +/** * @brief Print thread information * - * @param outputfile File handle for printing report. + * @param outputfile File handle for printing report * @param pid PID of the inspected process * @param tid TID of the inspected thread */ @@ -927,6 +942,9 @@ int main(int argc, char **argv) dwfl_getmodules(dwfl, __module_callback, &mappings, 0); Elf_Data *notes = 0; + /* Executable File Path */ + __crash_stack_print_exe(outputfile, pid); + /* Now, get registers */ if (pid > 1) { if (-1 == __get_signal_ptrace(pid)) |