[RFC PATCH v2 4/4] make cpu context change transparent to crash/gdb

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

 



Currently the gdb passthrough get back to `crash_target::fetch_registers`
to get register values, which depends on the current context in crash.

So even though `thread` command run in gdb mode or as a passthrough,
it did not change the cpu in crash, hence no context change in crash,
thereby getting register values with respect to wrong thread/cpu

Even if in gdb mode, `thread <thread_num>` command is run, it does not
change the cpu in the crash context.

Modify the current cpu in crash, when 'thread <thread_num' is run in gdb
mode or as gdb passthrough.

Signed-off-by: Aditya Gupta <adityag@xxxxxxxxxxxxx>
---
 gdb-10.2.patch | 28 ++++++++++++++++++++++++++++
 ppc64.c        |  3 ---
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/gdb-10.2.patch b/gdb-10.2.patch
index 16228b1dbf73..89826e5fc7e0 100644
--- a/gdb-10.2.patch
+++ b/gdb-10.2.patch
@@ -10,6 +10,7 @@
 
 tar xvzmf gdb-10.2.tar.gz \
 	gdb-10.2/gdb/symtab.c \
+	gdb-10.2/gdb/thread.c \
 	gdb-10.2/gdb/printcmd.c \
 	gdb-10.2/gdb/symfile.c \
 	gdb-10.2/gdb/Makefile.in \
@@ -483,7 +484,34 @@ exit 0
 +#endif
  	  return best_pst;
        }
+--- gdb-10.2/gdb/thread.c.orig
++++ gdb-10.2/gdb/thread.c
+@@ -58,6 +58,11 @@ static int highest_thread_num;
+ /* The current/selected thread.  */
+ static thread_info *current_thread_;
 
++#ifdef CRASH_MERGE
++/* Function to set cpu, defined by crash-utility */
++extern "C" void set_cpu (int);
++#endif
++
+ /* RAII type used to increase / decrease the refcount of each thread
+    in a given list of threads.  */
+
+@@ -1896,7 +1901,12 @@ thread_command (const char *tidstr, int from_tty)
+     {
+       ptid_t previous_ptid = inferior_ptid;
+
+-      thread_select (tidstr, parse_thread_id (tidstr, NULL));
++      struct thread_info* thread_id = parse_thread_id (tidstr, NULL);
++      thread_select (tidstr, thread_id);
++
++#ifdef CRASH_MERGE
++      set_cpu(thread_id->ptid.tid());
++#endif
+
+       /* Print if the thread has not changed, otherwise an event will
+         be sent.  */
 --- gdb-10.2/gdb/symfile.c.orig
 +++ gdb-10.2/gdb/symfile.c
 @@ -652,7 +652,26 @@ default_symfile_offsets (struct objfile *objfile,
diff --git a/ppc64.c b/ppc64.c
index 61ff47c2c8d9..51b2a1ace422 100644
--- a/ppc64.c
+++ b/ppc64.c
@@ -2518,9 +2518,6 @@ ppc64_get_cpu_reg(int cpu, int regno, const char *name, int size,
 		return FALSE;
 	}
 
-	/* FIXME: Always setting the context to CURRENT_CONTEXT irrespective of whicher
-	 * thread we switched to, in gdb
-	 */
 	tc = CURRENT_CONTEXT();
 	BZERO(&bt_setup, sizeof(struct bt_info));
 	clone_bt_info(&bt_setup, &bt_info, tc);
-- 
2.41.0

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/crash-utility
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