monitor: report all stopped threads on '?' command

Fixes #5120
This commit is contained in:
Christian Prochaska 2024-02-19 09:09:29 +01:00 committed by Christian Helmuth
parent 12df9bf450
commit aa6f99b0a4

View File

@ -558,21 +558,24 @@ struct ask : Command_without_separator
state.gdb_connected = true; state.gdb_connected = true;
bool handled = false; bool stop_reply_sent = false;
state.inferiors.for_each<Inferior_pd const &>([&] (Inferior_pd const &inferior) { state.inferiors.for_each<Inferior_pd const &>([&] (Inferior_pd const &inferior) {
inferior.for_each_thread([&] (Monitored_thread &thread) { inferior.for_each_thread([&] (Monitored_thread &thread) {
if (handled)
return;
using Stop_state = Monitored_thread::Stop_state; using Stop_state = Monitored_thread::Stop_state;
using Stop_reply_signal = Monitored_thread::Stop_reply_signal; using Stop_reply_signal = Monitored_thread::Stop_reply_signal;
if (thread.stop_state == Stop_state::RUNNING) if (thread.stop_state == Stop_state::RUNNING)
return; return;
thread.stop_state = Stop_state::STOPPED_REPLY_SENT; /* found a stopped thread */
if (!stop_reply_sent) {
/* send a stop reply for one stopped thread */
state.notification_in_progress = true;
long unsigned int pid = inferior.id(); long unsigned int pid = inferior.id();
long unsigned int tid = thread.id(); long unsigned int tid = thread.id();
@ -584,13 +587,25 @@ struct ask : Command_without_separator
print(out, "swbreak:;"); print(out, "swbreak:;");
}); });
handled = true; thread.stop_state = Stop_state::STOPPED_REPLY_SENT;
stop_reply_sent = true;
} else {
/* report other stopped threads on 'vStopped' */
thread.stop_state = Stop_state::STOPPED_REPLY_PENDING;
}
}); });
}); });
if (!handled) if (!stop_reply_sent) {
/* all threads are running */
state.notification_in_progress = false;
gdb_ok(out); gdb_ok(out);
} }
}
}; };