Re: [PATCH 06/31] Avoid duplicate QThreadEvents packets

Andrew Burgess via Gdb-patches
2023-05-26T15:53:26Z

Pedro Alves <pedro@palves.net> writes:

> Similarly to QProgramSignals and QPassSignals, avoid sending duplicate
> QThreadEvents packets.

LGTM.

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew

>
> Change-Id: Iaf5babb0b64e1527ba4db31aac8674d82b17e8b4
> ---
> gdb/remote.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/gdb/remote.c b/gdb/remote.c
> index a7430eb79dd..41348a65dc4 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -314,6 +314,10 @@ class remote_state
> the target know about program signals list changes. */
> char *last_program_signals_packet = nullptr;
>
> + /* Similarly, the last QThreadEvents state we sent to the
> + target. */
> + bool last_thread_events = false;
> +
> gdb_signal last_sent_signal = GDB_SIGNAL_0;
>
> bool last_sent_step = false;
> @@ -14507,6 +14511,9 @@ remote_target::thread_events (int enable)
> if (packet_support (PACKET_QThreadEvents) == PACKET_DISABLE)
> return;
>
> + if (rs->last_thread_events == enable)
> + return;
> +
> xsnprintf (rs->buf.data (), size, "QThreadEvents:%x", enable ? 1 : 0);
> putpkt (rs->buf);
> getpkt (&rs->buf, 0);
> @@ -14517,6 +14524,7 @@ remote_target::thread_events (int enable)
> case PACKET_OK:
> if (strcmp (rs->buf.data (), "OK") != 0)
> error (_("Remote refused setting thread events: %s"), rs->buf.data ());
> + rs->last_thread_events = enable;
> break;
> case PACKET_ERROR:
> warning (_("Remote failure reply: %s"), rs->buf.data ());
> --
> 2.36.0