[Crash-utility] [PATCH v6 02/14] Leave only one gdb thread for crash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch is a preparation of gdb stack unwinding support.
There are 3 designs for supporting arbitrary tasks stack unwinding:

1) One gdb thread represent a task[1][2].
2) One gdb thread represent a cpu[3].
3) Leaving only one gdb thread[4].

1 & 2 have a flaw that, when there are lots of tasks/cpus, it will slow
the startup of crash, introduce complexity of the registers context
synchronization between crash and gdb, hard to cover live debug mode
etc. So here we used the 3rd design.

To switch task, or view arbitrary tasks stack unwinding, we will reuse
the current gdb thread, and load the target task's regcache to the
thread(see the next patch). This will simplify many code.

[1]: https://www.mail-archive.com/devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx/msg00524.html
[2]: https://www.mail-archive.com/devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx/msg00529.html
[3]: https://www.mail-archive.com/devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx/msg00471.html
[4]: https://www.mail-archive.com/devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx/msg00541.html

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  | 14 +++++---------
 gdb_interface.c | 17 -----------------
 2 files changed, 5 insertions(+), 26 deletions(-)

diff --git a/crash_target.c b/crash_target.c
index 4554806..1f62bf6 100644
--- a/crash_target.c
+++ b/crash_target.c
@@ -26,7 +26,6 @@
 void crash_target_init (void);
 
 extern "C" int gdb_readmem_callback(unsigned long, void *, int, int);
-extern "C" int crash_get_nr_cpus(void);
 extern "C" int crash_get_cpu_reg (int cpu, int regno, const char *regname,
                                   int regsize, void *val);
 
@@ -110,7 +109,6 @@ crash_target::xfer_partial (enum target_object object, const char *annex,
 void
 crash_target_init (void)
 {
-  int nr_cpus = crash_get_nr_cpus();
   crash_target *target = new crash_target ();
 
   /* Own the target until it is successfully pushed.  */
@@ -119,13 +117,11 @@ crash_target_init (void)
   push_target (std::move (target_holder));
 
   inferior_appeared (current_inferior (), CRASH_INFERIOR_PID);
-  for (int i = 0; i < nr_cpus; i++)
-    {
-      thread_info *thread = add_thread_silent (target,
-                                        ptid_t(CRASH_INFERIOR_PID, 0, i));
-      if (!i)
-        switch_to_thread (thread);
-    }
+
+  /*Only create 1 gdb threads to view tasks' stack unwinding*/
+  thread_info *thread = add_thread_silent (target,
+                                ptid_t(CRASH_INFERIOR_PID, 0, 0));
+  switch_to_thread (thread);
 
   /* Fetch all registers from core file.  */
   target_fetch_registers (get_current_regcache (), -1);
diff --git a/gdb_interface.c b/gdb_interface.c
index 8f99a0d..8e95e9e 100644
--- a/gdb_interface.c
+++ b/gdb_interface.c
@@ -1067,25 +1067,8 @@ unsigned long crash_get_kaslr_offset(void)
 }
 
 /* Callbacks for crash_target */
-int crash_get_nr_cpus(void);
 int crash_get_cpu_reg (int cpu, int regno, const char *regname,
                        int regsize, void *val);
-
-int crash_get_nr_cpus(void)
-{
-        if (SADUMP_DUMPFILE())
-                return sadump_get_nr_cpus();
-        else if (DISKDUMP_DUMPFILE())
-                return diskdump_get_nr_cpus();
-        else if (KDUMP_DUMPFILE())
-                return kdump_get_nr_cpus();
-        else if (VMSS_DUMPFILE())
-                return vmware_vmss_get_nr_cpus();
-
-        /* Just CPU #0 */
-        return 1;
-}
-
 int crash_get_cpu_reg (int cpu, int regno, const char *regname,
                        int regsize, void *value)
 {
-- 
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




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux