crash-stack: print executable file path 11/104911/1
authorŁukasz Stelmach <l.stelmach@samsung.com>
Wed, 14 Dec 2016 15:26:54 +0000 (16:26 +0100)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Wed, 14 Dec 2016 16:18:00 +0000 (17:18 +0100)
Change-Id: Ib5946bcfb5bbad8af7b7bbfc7c8568a3cb3ab207

src/crash-stack/crash-stack.c

index a377306..2507055 100644 (file)
@@ -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))