diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index ca5e92c..5057ade 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -21906,7 +21906,7 @@ value of @code{"all"}. Otherwise, the value of the @var{stopped} field will be a list of thread identifiers. Presently, this list will always include a single thread, but frontend should be prepared to see several threads in the list. The @var{core} field reports the -processor core on which the stop event has happened. This field may be absent +processor core on which the stop event has happened. This field may be absent if such information is not available. @item =thread-group-created,id="@var{id}" diff --git a/gdb/remote.c b/gdb/remote.c index 9d343b2..ffd4ad3 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -318,12 +318,6 @@ free_private_thread_info (struct private_thread_info *info) xfree (info); } -/* The core number that was last seen by process_stop_reply. */ -static int last_core = -1; - -/* The thread that corresponds to last_core. */ -static ptid_t thread_of_last_core; - /* Returns true if the multi-process extensions are in effect. */ static int remote_multi_process_p (struct remote_state *rs) @@ -1381,6 +1375,24 @@ remote_notice_new_inferior (ptid_t currthread, int running) } } +/* Return the private thread data, creating it if necessary. */ + +struct private_thread_info * +demand_private_info (ptid_t ptid) +{ + struct thread_info *info = find_thread_ptid (ptid); + + gdb_assert (info); + + if (!info->private) + { + info->private = xmalloc (sizeof (*(info->private))); + info->private_dtor = free_private_thread_info; + } + + return info->private; +} + /* Call this function as a result of 1) A halt indication (T packet) containing a thread id 2) A direct query of currthread @@ -1391,12 +1403,6 @@ static void record_currthread (ptid_t currthread) { general_thread = currthread; - - if (ptid_equal (currthread, minus_one_ptid)) - /* We're just invalidating the local thread mirror. */ - return; - - remote_notice_new_inferior (currthread, 0); } static char *last_pass_packet; @@ -2445,7 +2451,7 @@ remote_threads_info (struct target_ops *ops) { if (!ptid_equal (item->ptid, null_ptid)) { - struct thread_info *info; + struct private_thread_info *info; /* In non-stop mode, we assume new found threads are running until proven otherwise with a stop reply. In all-stop, we can only get @@ -2454,19 +2460,10 @@ remote_threads_info (struct target_ops *ops) remote_notice_new_inferior (item->ptid, running); - info = find_thread_ptid (item->ptid); - if (info) - { - if (!info->private) { - info->private = (struct private_thread_info *) - xmalloc (sizeof (struct private_thread_info)); - info->private_dtor = free_private_thread_info; - } - - info->private->extra = item->extra; - item->extra = 0; - info->private->core = item->core; - } + info = demand_private_info (item->ptid); + info->core = item->core; + info->extra = item->extra; + item->extra = 0; } xfree (item->extra); } @@ -4918,20 +4915,8 @@ process_stop_reply (struct stop_reply *stop_reply, remote_stopped_by_watchpoint_p = stop_reply->stopped_by_watchpoint_p; remote_watch_data_address = stop_reply->watch_data_address; - /* Update the core associated with a thread when we process stop - event in that thread. */ - info = find_thread_ptid (ptid); - if (info && info->private) - { - info->private->core = stop_reply->core; - } - else - { - last_core = stop_reply->core; - thread_of_last_core = ptid; - } - remote_notice_new_inferior (ptid, 0); + demand_private_info (ptid)->core = stop_reply->core; } stop_reply_xfree (stop_reply); @@ -9101,8 +9086,6 @@ remote_core_of_thread (struct target_ops *ops, ptid_t ptid) struct thread_info *info = find_thread_ptid (ptid); if (info && info->private) return info->private->core; - else if (ptid_equal (ptid, thread_of_last_core)) - return last_core; return -1; } diff --git a/gdb/target.h b/gdb/target.h index a4fe06a..a4a0b18 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -599,11 +599,11 @@ struct target_ops struct address_space *(*to_thread_address_space) (struct target_ops *, ptid_t); - /* Return the core that thread PTID is on. For a stopped thread, should - return the core the thread was last running on. For a running thread, + /* Return the core that thread PTID is on. For a stopped thread, should + return the core the thread was last running on. For a running thread, should return one of the cores that the thread was running between the call to this function and return -- and if it was running on - several cores, any other may be returned. + several cores, any other may be returned. If the core cannot be determined -- either for the specified thread, or right now, or in this debug session, or for this target -- return -1. */ int (*to_core_of_thread) (struct target_ops *, ptid_t ptid); diff --git a/gdb/thread.c b/gdb/thread.c index 9613393..16a207c 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -114,8 +114,6 @@ free_thread (struct thread_info *tp) { clear_thread_inferior_resources (tp); - /* FIXME: do I ever need to call the back-end to give it a - chance at this private data before deleting the thread? */ if (tp->private) { if (tp->private_dtor)