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 <adit...@linux.ibm.com> Co-developed-by: Alexey Makhalov <alexey.makha...@broadcom.com> Co-developed-by: Tao Liu <l...@redhat.com> Signed-off-by: Tao Liu <l...@redhat.com> --- 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@lists.crash-utility.osci.io To unsubscribe send an email to devel-le...@lists.crash-utility.osci.io https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/ Contribution Guidelines: https://github.com/crash-utility/crash/wiki