[Crash-utility] [Crash-Utility][PATCH v1 05/12] Print task pid/command instead of CPU index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch is a preparation of gdb stack unwinding support. "info threads"
will output useful info for current task, such as pid, command, stack frame.

Before the patch:
crash> info threads
  Id   Target Id         Frame
* 1    CPU 0             crash_setup_regs (oldregs=0x0, newregs=0xffffbd1040c57c70) ...

After the patch:
crash> info threads
  Id   Target Id         Frame
* 1    1231 bash         crash_setup_regs (oldregs=0x0, newregs=0xffffbd1040c57c70) ...

Co-developed-by: Aditya Gupta <adityag@xxxxxxxxxxxxx>
Co-developed-by: Alexey Makhalov <alexey.makhalov@xxxxxxxxxxxx>
Co-developed-by: Tao Liu <ltao@xxxxxxxxxx>
Signed-off-by: Tao Liu <ltao@xxxxxxxxxx>
---
 crash_target.c | 8 +++++++-
 task.c         | 9 +++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/crash_target.c b/crash_target.c
index 52966f7..3b0efbf 100644
--- a/crash_target.c
+++ b/crash_target.c
@@ -29,6 +29,7 @@ extern "C" int gdb_readmem_callback(unsigned long, void *, int, int);
 extern "C" int crash_get_current_task_reg (int regno, const char *regname,
                                   int regsize, void *val);
 extern "C" int gdb_change_thread_context ();
+extern "C" void crash_get_current_task_info(unsigned long *pid, char **comm);
 
 /* The crash target.  */
 
@@ -59,7 +60,12 @@ public:
   bool has_registers () override { return true; }
   bool thread_alive (ptid_t ptid) override { return true; }
   std::string pid_to_str (ptid_t ptid) override
-  { return string_printf ("CPU %ld", ptid.tid ()); }
+  {
+    unsigned long pid;
+    char *comm;
+    crash_get_current_task_info(&pid, &comm);
+    return string_printf ("%ld %s", pid, comm);
+  }
 
 };
 
diff --git a/task.c b/task.c
index d47d268..8c00837 100644
--- a/task.c
+++ b/task.c
@@ -11285,3 +11285,12 @@ check_stack_end_magic:
 	if (!total)
 		fprintf(fp, "No stack overflows detected\n");
 }
+
+void crash_get_current_task_info(unsigned long *pid, char **comm);
+void crash_get_current_task_info(unsigned long *pid, char **comm)
+{
+	struct task_context *tc = CURRENT_CONTEXT();
+
+	*pid = tc->pid;
+	*comm = tc->comm;
+}
-- 
2.40.1
--
Crash-utility mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxxxxxx
https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
Contribution Guidelines: https://github.com/crash-utility/crash/wiki




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux