From: Markus Metzger <markus.t.metzger@intel.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/5] gdb, btrace: fix btrace remote configuration
Date: Fri, 30 Oct 2026 14:57:42 +0100 [thread overview]
Message-ID: <20261030135744.921562-4-markus.t.metzger@intel.com> (raw)
In-Reply-To: <20261030135744.921562-1-markus.t.metzger@intel.com>
GDB currently only updates those parts of the remote btrace configuration
that it believes are different than on the remote target. Since it does
not read the target configuration initially, this can only be a guess.
There currently is no packet to read the global btrace configuration. The
existing
qXfer:btrace-conf:read
packet requires a thread and fails with
E.Must select a single thread.
if the general thread is null_ptid.
The packet could be extended to provide the global configuration in that
case, but older gdbserver would still reply with an error, requiring GDB
to write its configuration at least once.
The overhead of writing all aspects of the configuration is tiny compared
to reading the trace from the target, so this patch simply writes all
parts whenever tracing is enabled for a thread.
Also fix a few overlong lines in this area.
---
gdb/remote.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index 6e3a2089b9e..e0e508bd0ce 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -15455,8 +15455,8 @@ remote_target::btrace_sync_conf (const btrace_config *conf)
buf = rs->buf.data ();
endbuf = buf + get_remote_packet_size ();
- if (m_features.packet_support (PACKET_Qbtrace_conf_bts_size) == PACKET_ENABLE
- && conf->bts.size != rs->btrace_config.bts.size)
+ if (m_features.packet_support (PACKET_Qbtrace_conf_bts_size)
+ == PACKET_ENABLE)
{
pos = buf;
pos += xsnprintf (pos, endbuf - pos, "%s=0x%x",
@@ -15466,15 +15466,17 @@ remote_target::btrace_sync_conf (const btrace_config *conf)
putpkt (buf);
getpkt (&rs->buf);
- packet_result result = m_features.packet_ok (buf, PACKET_Qbtrace_conf_bts_size);
+ packet_result result
+ = m_features.packet_ok (buf, PACKET_Qbtrace_conf_bts_size);
if (result.status () == PACKET_ERROR)
- error (_("Failed to configure the BTS buffer size: %s"), result.err_msg ());
+ error (_("Failed to configure the BTS buffer size: %s"),
+ result.err_msg ());
rs->btrace_config.bts.size = conf->bts.size;
}
- if (m_features.packet_support (PACKET_Qbtrace_conf_pt_size) == PACKET_ENABLE
- && conf->pt.size != rs->btrace_config.pt.size)
+ if (m_features.packet_support (PACKET_Qbtrace_conf_pt_size)
+ == PACKET_ENABLE)
{
pos = buf;
pos += xsnprintf (pos, endbuf - pos, "%s=0x%x",
@@ -15484,16 +15486,17 @@ remote_target::btrace_sync_conf (const btrace_config *conf)
putpkt (buf);
getpkt (&rs->buf);
- packet_result result = m_features.packet_ok (buf, PACKET_Qbtrace_conf_pt_size);
+ packet_result result
+ = m_features.packet_ok (buf, PACKET_Qbtrace_conf_pt_size);
if (result.status () == PACKET_ERROR)
- error (_("Failed to configure the trace buffer size: %s"), result.err_msg ());
+ error (_("Failed to configure the trace buffer size: %s"),
+ result.err_msg ());
rs->btrace_config.pt.size = conf->pt.size;
}
- if ((m_features.packet_support (PACKET_Qbtrace_conf_pt_ptwrite)
- == PACKET_ENABLE)
- && conf->pt.ptwrite != rs->btrace_config.pt.ptwrite)
+ if (m_features.packet_support (PACKET_Qbtrace_conf_pt_ptwrite)
+ == PACKET_ENABLE)
{
pos = buf;
const char *ptw = conf->pt.ptwrite ? "yes" : "no";
@@ -15524,9 +15527,8 @@ remote_target::btrace_sync_conf (const btrace_config *conf)
&& conf->pt.event_tracing)
warning (_("Target does not support event-tracing."));
- if ((m_features.packet_support (PACKET_Qbtrace_conf_pt_event_tracing)
- == PACKET_ENABLE)
- && conf->pt.event_tracing != rs->btrace_config.pt.event_tracing)
+ if (m_features.packet_support (PACKET_Qbtrace_conf_pt_event_tracing)
+ == PACKET_ENABLE)
{
pos = buf;
const char *event_tracing = conf->pt.event_tracing ? "yes" : "no";
--
2.53.0
________________________________________
Intel Deutschland GmbH
Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany
Tel: +49 (89) 99143-0
www.intel.de
Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman
Chairperson of the Supervisory Board: Sonja Pierer
Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
next prev parent reply other threads:[~2026-10-30 14:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 13:57 [PATCH 0/5] gdb, gdbserver, btrace: enhanced resync on decode error Markus Metzger
2026-10-30 13:57 ` [PATCH 1/5] gdb, btrace: refactor handle_pt_insn_events() Markus Metzger
2026-10-30 13:57 ` [PATCH 2/5] gdb, btrace: refactor ftrace_add_pt() Markus Metzger
2026-10-30 13:57 ` Markus Metzger [this message]
2026-10-30 13:57 ` [PATCH 4/5] gdb, gdbserver, btrace: allow disabling return compression Markus Metzger
2026-10-30 14:30 ` Eli Zaretskii
2026-10-30 13:57 ` [PATCH 5/5] gdb, gdbserver, btrace: resync on error Markus Metzger
2026-10-30 14:31 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261030135744.921562-4-markus.t.metzger@intel.com \
--to=markus.t.metzger@intel.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox