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> Cc: Sourabh Jain <sourabhjain@xxxxxxxxxxxxx> Cc: Hari Bathini <hbathini@xxxxxxxxxxxxx> Cc: Mahesh J Salgaonkar <mahesh@xxxxxxxxxxxxx> Cc: Naveen N. Rao <naveen.n.rao@xxxxxxxxxxxxxxxxxx> Cc: Lianbo Jiang <lijiang@xxxxxxxxxx> Cc: HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab@xxxxxxx> Cc: Tao Liu <ltao@xxxxxxxxxx> Cc: Alexey Makhalov <alexey.makhalov@xxxxxxxxxxxx> 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 6ee12d2..1080976 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 (void); +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 697a692..b91acb2 100644 --- a/task.c +++ b/task.c @@ -120,6 +120,7 @@ static int has_sched_policy(ulong, ulong); static ulong task_policy(ulong); static ulong sched_policy_bit_from_str(const char *); static ulong make_sched_policy(const char *); +void crash_get_current_task_info(unsigned long *, char **); static struct sched_policy_info { ulong value; @@ -11292,3 +11293,11 @@ check_stack_end_magic: if (!total) fprintf(fp, "No stack overflows detected\n"); } + +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