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(a)linux.ibm.com>
Co-developed-by: Alexey Makhalov <alexey.makhalov(a)broadcom.com>
Co-developed-by: Tao Liu <ltao(a)redhat.com>
Cc: Sourabh Jain <sourabhjain(a)linux.ibm.com>
Cc: Hari Bathini <hbathini(a)linux.ibm.com>
Cc: Mahesh J Salgaonkar <mahesh(a)linux.ibm.com>
Cc: Naveen N. Rao <naveen.n.rao(a)linux.vnet.ibm.com>
Cc: Lianbo Jiang <lijiang(a)redhat.com>
Cc: HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab(a)nec.com>
Cc: Tao Liu <ltao(a)redhat.com>
Cc: Alexey Makhalov <alexey.makhalov(a)broadcom.com>
Cc: Aditya Gupta <adityag(a)linux.ibm.com>
Signed-off-by: Tao Liu <ltao(a)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 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 37ac250..c131cc3 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;
@@ -11296,3 +11297,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