While developing a PR for multiprocess support and testing it with the armv4t_multithreaded example project, I found that every time I switched to thread 2 (the coprocessor thread) and stepped, the client would switch back to thread 1 (the cpu thread). Re-checking out dev/0.8 and I confirmed it still exists.
With set debug remote on in the GDB client, here's the most relevant excerpt that shows stepping thread 2 (while continuing the other processes):
[remote] Sending packet: $vCont;s:p1.2;c:p1.-1#f8
[remote] wait: enter
[remote] wait: exit
[remote] wait: enter
[remote] Packet received: S05
[remote] select_thread_for_ambiguous_stop_reply: enter
[remote] select_thread_for_ambiguous_stop_reply: process_wide_stop = 0
[remote] select_thread_for_ambiguous_stop_reply: first resumed thread is Thread 1.1
[remote] select_thread_for_ambiguous_stop_reply: is this guess ambiguous? = 1
warning: multi-threaded target stopped without sending a thread-id, using first non-exited thread
[remote] select_thread_for_ambiguous_stop_reply: exit
Granted, this was sent with scheduler-locking mode off (with scheduler-locking mode on, thread 2 remains the active thread), which means that the scheduler could schedule anything, and so I'm not complaining about the fact that the thread switches in this case, for armv4t_multithreaded.
However, stubs might be able to provide more information to the GDB client (and this also happens when I step with gdb and gdbserver locally): the stub might be able to say that the step concluded and also say that the thread that was requested to be stepped actually was. This should make the GDB client user's experience a little better, since the likeliest case of a step is that the step concluded before any other thread could stop, and the user wouldn't have to keep switching back to the thread they're actually trying to work with.
It seems like giving DoneStep an Option<Tid> (or adding a DoneStepWithThread, like with Signal) would give stubs the ability to do this. If we're already breaking the API in v0.8 for multiprocess support, this might be another quick+simple to migrate breakage we could sneak in too. A current workaround exists of issuing a SwBreak or a HwBreak instead of a DoneStep, but this isn't intuitive and seems like it would be easier for Target implementations to misuse.
While developing a PR for multiprocess support and testing it with the
armv4t_multithreadedexample project, I found that every time I switched to thread 2 (the coprocessor thread) and stepped, the client would switch back to thread 1 (the cpu thread). Re-checking outdev/0.8and I confirmed it still exists.With
set debug remote onin the GDB client, here's the most relevant excerpt that shows stepping thread 2 (while continuing the other processes):Granted, this was sent with
scheduler-locking mode off(withscheduler-locking mode on, thread 2 remains the active thread), which means that the scheduler could schedule anything, and so I'm not complaining about the fact that the thread switches in this case, forarmv4t_multithreaded.However, stubs might be able to provide more information to the GDB client (and this also happens when I step with
gdbandgdbserverlocally): the stub might be able to say that the step concluded and also say that the thread that was requested to be stepped actually was. This should make the GDB client user's experience a little better, since the likeliest case of a step is that the step concluded before any other thread could stop, and the user wouldn't have to keep switching back to the thread they're actually trying to work with.It seems like giving
DoneStepanOption<Tid>(or adding aDoneStepWithThread, like withSignal) would give stubs the ability to do this. If we're already breaking the API in v0.8 for multiprocess support, this might be another quick+simple to migrate breakage we could sneak in too. A current workaround exists of issuing aSwBreakor aHwBreakinstead of aDoneStep, but this isn't intuitive and seems like it would be easier forTargetimplementations to misuse.