From 3caf13b459b8f13c3bd3c60f33d3b1ed96801c1e Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Fri, 7 May 2010 15:24:16 +0000 Subject: [PATCH] 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. --- gdb/ChangeLog | 7 +++++++ gdb/sol-thread.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d5a9fb61d3e..8b70893c1bd 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -30,6 +30,13 @@ * fbsd-nat.c (fbsd_make_corefile_notes): Add cast to NULL used as sentinel. +2010-05-07 Joel Brobecker + + 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 * remote.c (remote_query_supported_append): Use reconcat. diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index 3e7183f8ce4..d18ae44ca3c 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; } -- 2.30.2