Since we only leave one gdb thread, or 1 cpu thread, and can use cmd "set" to switch task context by reusing the thread. So the word "get_cpu_reg", which stands for "fetch registers' value for cpu thread x", is no longer appropriate, better using "get_current_task_reg", which stands for "fetch registers' value for the current task", and makes more sense. Note: the x86_64_get_cpu_reg() function modification was originally in the x86_64 stack unwinding support part later, put it here due to not introducing compiling issues. 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> Cc: Aditya Gupta <adityag@xxxxxxxxxxxxx> Signed-off-by: Tao Liu <ltao@xxxxxxxxxx> --- crash_target.c | 5 ++--- defs.h | 2 +- gdb_interface.c | 14 +++++++------- x86_64.c | 22 +++++++++++++++------- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/crash_target.c b/crash_target.c index 41f0f3a..6ee12d2 100644 --- a/crash_target.c +++ b/crash_target.c @@ -26,7 +26,7 @@ void crash_target_init (void); extern "C" int gdb_readmem_callback(unsigned long, void *, int, int); -extern "C" int crash_get_cpu_reg (int cpu, int regno, const char *regname, +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); @@ -66,7 +66,6 @@ public: static void supply_registers(struct regcache *regcache, int regno) { gdb_byte regval[16]; - int cpu = inferior_ptid.tid(); struct gdbarch *arch = regcache->arch (); const char *regname = gdbarch_register_name(arch, regno); int regsize = register_size(arch, regno); @@ -74,7 +73,7 @@ static void supply_registers(struct regcache *regcache, int regno) if (regsize > sizeof (regval)) error (_("fatal error: buffer size is not enough to fit register value")); - if (crash_get_cpu_reg (cpu, regno, regname, regsize, (void *)®val)) + if (crash_get_current_task_reg (regno, regname, regsize, (void *)®val)) regcache->raw_supply (regno, regval); else regcache->raw_supply (regno, NULL); diff --git a/defs.h b/defs.h index 695c32d..0d16721 100644 --- a/defs.h +++ b/defs.h @@ -1080,7 +1080,7 @@ struct machdep_table { void (*get_irq_affinity)(int); void (*show_interrupts)(int, ulong *); int (*is_page_ptr)(ulong, physaddr_t *); - int (*get_cpu_reg)(int, int, const char *, int, void *); + int (*get_current_task_reg)(int, const char *, int, void *); int (*is_cpu_prstatus_valid)(int cpu); }; diff --git a/gdb_interface.c b/gdb_interface.c index 8e95e9e..ab4ebd3 100644 --- a/gdb_interface.c +++ b/gdb_interface.c @@ -1067,13 +1067,13 @@ unsigned long crash_get_kaslr_offset(void) } /* Callbacks for crash_target */ -int crash_get_cpu_reg (int cpu, int regno, const char *regname, - int regsize, void *val); -int crash_get_cpu_reg (int cpu, int regno, const char *regname, - int regsize, void *value) +int crash_get_current_task_reg (int regno, const char *regname, + int regsize, void *value); +int crash_get_current_task_reg (int regno, const char *regname, + int regsize, void *value) { - if (!machdep->get_cpu_reg) - return FALSE; - return machdep->get_cpu_reg(cpu, regno, regname, regsize, value); + if (!machdep->get_current_task_reg) + return FALSE; + return machdep->get_current_task_reg(regno, regname, regsize, value); } diff --git a/x86_64.c b/x86_64.c index b18f622..655b4a9 100644 --- a/x86_64.c +++ b/x86_64.c @@ -126,7 +126,7 @@ static int x86_64_get_framesize(struct bt_info *, ulong, ulong, char *); static void x86_64_framesize_debug(struct bt_info *); static void x86_64_get_active_set(void); static int x86_64_get_kvaddr_ranges(struct vaddr_range *); -static int x86_64_get_cpu_reg(int, int, const char *, int, void *); +static int x86_64_get_cpu_reg(int, const char *, int, void *); static int x86_64_verify_paddr(uint64_t); static void GART_init(void); static void x86_64_exception_stacks_init(void); @@ -195,7 +195,7 @@ x86_64_init(int when) machdep->machspec->irq_eframe_link = UNINITIALIZED; machdep->machspec->irq_stack_gap = UNINITIALIZED; machdep->get_kvaddr_ranges = x86_64_get_kvaddr_ranges; - machdep->get_cpu_reg = x86_64_get_cpu_reg; + machdep->get_current_task_reg = x86_64_get_cpu_reg; if (machdep->cmdline_args[0]) parse_cmdline_args(); if ((string = pc->read_vmcoreinfo("relocate"))) { @@ -9076,14 +9076,22 @@ x86_64_get_kvaddr_ranges(struct vaddr_range *vrp) } static int -x86_64_get_cpu_reg(int cpu, int regno, const char *name, +x86_64_get_cpu_reg(int regno, const char *name, int size, void *value) { - if (regno >= LAST_REGNUM) - return FALSE; + struct task_context *tc; - if (VMSS_DUMPFILE()) - return vmware_vmss_get_cpu_reg(cpu, regno, name, size, value); + tc = CURRENT_CONTEXT(); + if (!tc) + return FALSE; + + if (regno >= LAST_REGNUM) + return FALSE; + /* + * Task is active, grab CPU's registers + */ + if (is_task_active(tc->task) && VMSS_DUMPFILE()) + return vmware_vmss_get_cpu_reg(tc->processor, regno, name, size, value); return FALSE; } -- 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