Hi, Tao
Thank you for the update.

On Mon, Jul 29, 2024 at 6:53 PM <devel-request@lists.crash-utility.osci.io> wrote:
Date: Mon, 29 Jul 2024 22:44:26 +1200
From: Tao Liu <ltao@redhat.com>
Subject: [Crash-utility] [PATCH v5 04/14] Rename get_cpu_reg to
        get_current_task_reg
To: devel@lists.crash-utility.osci.io
Cc: Alexey Makhalov <alexey.makhalov@broadcom.com>, Mahesh J
        Salgaonkar <mahesh@linux.ibm.com>, "Naveen N . Rao"
        <naveen.n.rao@linux.vnet.ibm.com>, Lianbo Jiang <lijiang@redhat.com>
Message-ID: <20240729104436.67685-5-ltao@redhat.com>
Content-Type: text/plain; charset=UTF-8

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 function signature was changed by this patch, and there is one
usage in x86_64.c:machdep->get_current_task_reg = x86_64_get_cpu_reg,
which doesn't matter because it will be updated later in patch
"x86_64: Add gdb stack unwinding support".

The current compilation error will break the bisecting in the future.

As we discussed, we need to make sure it doesn't have any compilation failures, and try our best to not introduce new regression issues.
 

Co-developed-by: Aditya Gupta <adityag@linux.ibm.com>
Co-developed-by: Alexey Makhalov <alexey.makhalov@broadcom.com>
Co-developed-by: Tao Liu <ltao@redhat.com>
Cc: Sourabh Jain <sourabhjain@linux.ibm.com>
Cc: Hari Bathini <hbathini@linux.ibm.com>
Cc: Mahesh J Salgaonkar <mahesh@linux.ibm.com>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Lianbo Jiang <lijiang@redhat.com>
Cc: HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab@nec.com>
Cc: Tao Liu <ltao@redhat.com>
Cc: Alexey Makhalov <alexey.makhalov@broadcom.com>
Signed-off-by: Tao Liu <ltao@redhat.com>
---
 crash_target.c  |  5 ++---
 defs.h          |  2 +-
 gdb_interface.c | 10 +++++-----
 x86_64.c        |  2 +-
 4 files changed, 9 insertions(+), 10 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 *)&regval))
+  if (crash_get_current_task_reg (regno, regname, regsize, (void *)&regval))
     regcache->raw_supply (regno, regval);
   else
     regcache->raw_supply (regno, NULL);
diff --git a/defs.h b/defs.h
index 9ffe7c9..82c2af8 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..7399fd0 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 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)
+        if (!machdep->get_current_task_reg)
                 return FALSE;
-        return machdep->get_cpu_reg(cpu, regno, regname, regsize, value);
+        return machdep->get_current_task_reg(regno, regname, regsize, value);
 }

diff --git a/x86_64.c b/x86_64.c
index 469d26b..24a7040 100644
--- a/x86_64.c
+++ b/x86_64.c
@@ -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;

Still getting an error again, not fix it in this patch:

cc -c -g -DX86_64 -DLZO -DGDB_10_2  x86_64.c  
x86_64.c: In function ‘x86_64_init’:
x86_64.c:198:47: error: assignment to ‘int (*)(int,  const char *, int,  void *)’ from incompatible pointer type ‘int (*)(int,  int,  const char *, int,  void *)’ [-Wincompatible-pointer-types]
  198 |                 machdep->get_current_task_reg = x86_64_get_cpu_reg;
      |                                               ^
make[4]: *** [Makefile:432: x86_64.o] Error 1
make[3]: *** [Makefile:1877: gdb] Error 2
make[2]: *** [Makefile:278: rebuild] Error 2
make[1]: *** [Makefile:266: gdb_merge] Error 2
make: *** [Makefile:258: all] Error 2

please refer to the same error(see the link):
https://www.mail-archive.com/devel@lists.crash-utility.osci.io/msg00812.html


Thanks 
Lianbo

                 if (machdep->cmdline_args[0])
                         parse_cmdline_args();
                if ((string = pc->read_vmcoreinfo("relocate"))) {
--
2.40.1