remote_target::start_remote_1 () calls set_continue_thread (minus_one_ptid)
with the intent to
/* Let the stub know that we want it to return the thread. */
set_continue_thread (minus_one_ptid);
I interpret it such that it expects a later get_current_thread () to
return the thread selected by the target:
/* We have thread information; select the thread the target
says should be current. If we're reconnecting to a
multi-threaded program, this will ideally be the thread
that last reported an event before GDB disconnected. */
ptid_t curr_thread = get_current_thread (wait_status);
This results in the packet sequence Hc-1, qC.
Hc simply sets cont_thread:
else if (cs.own_buf[1] == 'c')
cs.cont_thread = thread_id;
write_ok (cs.own_buf);
and qC returns the general thread. This doesn't match.
It also has some special treatment for null_ptid and minus_one_ptid:
if (cs.general_thread != null_ptid && cs.general_thread != minus_one_ptid)
ptid = cs.general_thread;
else
{
init_thread_iter ();
ptid = thread_iter->id;
}
Similarly, Hg has some special treatment for null_ptid:
if (cs.own_buf[1] == 'g')
{
if (thread_id == null_ptid)
{
/* GDB is telling us to choose any thread. Check if
the currently selected thread is still valid. If
it is not, select the first available. */
thread_info *thread = find_thread_ptid (cs.general_thread);
if (thread == NULL)
thread = get_first_thread ();
thread_id = thread->id;
}
cs.general_thread = thread_id;
The comment at Hg matches the intent of GDB for sending Hc-1.
Change the set_thread () call in remote_target::start_remote_1 () to
set_general_thread (any_thread_ptid);
This results in GDB sending Hg0 and gdbserver preserving the currently
selected thread that is later returned in response to qC.
CC: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Approved-By: Tom Tromey <tom@tromey.com>
target_update_thread_list ();
/* Let the stub know that we want it to return the thread. */
- set_continue_thread (minus_one_ptid);
+ set_general_thread (any_thread_ptid);
if (thread_count (this) == 0)
{