This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] Implement task switching on solaris targets.
- From: Joel Brobecker <brobecker at adacore dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 7 May 2010 08:29:26 -0700
- Subject: [commit] Implement task switching on solaris targets.
Hello,
I just noticed that task switching isn't working on Solaris. For instance,
on sparc-solaris, we get:
(gdb) task 1
[new-thread notifications]
Unable to compute thread ID for task 1.
Cannot switch to this task.
But the first clue that things aren't working is the lack of '*' marking
the current task in the "info tasks" output:
(gdb) info tasks
ID TID P-ID Pri State Name
1 79c10 0 15 Runnable main_task
2 7a878 1 15 Accept or Select Term my_callee
3 7df00 1 15 Runnable my_caller
This is because the default task-info-to-ptid conversion routine does
not work for Solaris. Fixed with the attached patch.
Now, we get:
(gdb) info tasks
ID TID P-ID Pri State Name
1 79c10 0 15 Runnable main_task
2 7a878 1 15 Accept or Select Term my_callee
* 3 7df00 1 15 Runnable my_caller
(gdb) task 2
[Switching to task 2]
#5 0x0002beb0 in task_switch.callee (<_task>=0x7a4b8) at task_switch.adb:29
29 accept Finito do
(gdb) task 1
[Switching to task 1]
#1 0x0002ba98 in task_switch () at task_switch.adb:55
55 end Task_Switch;
gdb/ChangeLog:
* sol-thread.c (thread_db_find_thread_from_tid)
(sol_get_ada_task_ptid): New functions.
(init_sol_thread_ops): Set sol_thread_ops.to_get_ada_task_ptid.
Tested manually, but it can only affect Ada tasking. We've also had
this patch in our tree for a loooong time, now...
---
gdb/ChangeLog | 7 +++++++
gdb/sol-thread.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 582cc15..216d137 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2010-05-07 Joel Brobecker <brobecker@adacore.com>
+
+ Implement task switching on solaris targets.
+ * sol-thread.c (thread_db_find_thread_from_tid)
+ (sol_get_ada_task_ptid): New functions.
+ (init_sol_thread_ops): Set sol_thread_ops.to_get_ada_task_ptid.
+
2010-05-07 Pedro Alves <pedro@codesourcery.com>
* remote.c (remote_query_supported_append): Use reconcat.
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index 3e7183f..d18ae44 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -1288,6 +1288,40 @@ info_solthreads (char *args, int from_tty)
TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS);
}
+/* Callback routine used to find a thread based on the TID part of
+ its PTID. */
+
+static int
+thread_db_find_thread_from_tid (struct thread_info *thread, void *data)
+{
+ long *tid = (long *) data;
+
+ if (ptid_get_tid (thread->ptid) == *tid)
+ return 1;
+
+ return 0;
+}
+
+static ptid_t
+sol_get_ada_task_ptid (long lwp, long thread)
+{
+ struct thread_info *thread_info =
+ iterate_over_threads (thread_db_find_thread_from_tid, &thread);
+
+ if (thread_info == NULL)
+ {
+ /* The list of threads is probably not up to date. Find any
+ thread that is missing from the list, and try again. */
+ sol_find_new_threads (¤t_target);
+ thread_info = iterate_over_threads (thread_db_find_thread_from_tid,
+ &thread);
+ }
+
+ gdb_assert (thread_info != NULL);
+
+ return (thread_info->ptid);
+}
+
static void
init_sol_thread_ops (void)
{
@@ -1305,6 +1339,7 @@ init_sol_thread_ops (void)
sol_thread_ops.to_pid_to_str = solaris_pid_to_str;
sol_thread_ops.to_find_new_threads = sol_find_new_threads;
sol_thread_ops.to_stratum = thread_stratum;
+ sol_thread_ops.to_get_ada_task_ptid = sol_get_ada_task_ptid;
sol_thread_ops.to_magic = OPS_MAGIC;
}
--
1.6.3.3