* [PATCH 1/5] gdb, btrace: refactor handle_pt_insn_events()
2026-10-30 13:57 [PATCH 0/5] gdb, gdbserver, btrace: enhanced resync on decode error Markus Metzger
@ 2026-10-30 13:57 ` Markus Metzger
2026-10-30 13:57 ` [PATCH 2/5] gdb, btrace: refactor ftrace_add_pt() Markus Metzger
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Markus Metzger @ 2026-10-30 13:57 UTC (permalink / raw)
To: gdb-patches
Make handle_pt_insn_events() only handle a single event and move the while
loop that checks for pending events into the caller to prepare for a
subsequent patch.
To reflect that change, rename it to handle_pt_insn_event().
Also move declarations closer to their actual use, thereby duplicating
them as needed.
This is supposed to be a refactoring with no functional changes.
---
gdb/btrace.c | 560 ++++++++++++++++++++++++++-------------------------
1 file changed, 284 insertions(+), 276 deletions(-)
diff --git a/gdb/btrace.c b/gdb/btrace.c
index f5f2d6da972..ddc7b2551df 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -1285,379 +1285,384 @@ decode_interrupt_vector (const uint8_t vector)
}
#endif /* (LIBIPT_VERSION >= 0x201) */
-/* Handle instruction decode events (libipt-v2). */
+#if defined (HAVE_PT_INSN_EVENT)
+/* Handle an instruction decode event (libipt-v2). */
static int
-handle_pt_insn_events (struct btrace_thread_info *btinfo,
- struct pt_insn_decoder *decoder,
- std::vector<unsigned int> &gaps, int status)
+handle_pt_insn_event (btrace_thread_info *btinfo, pt_insn_decoder *decoder,
+ std::vector<unsigned int> &gaps)
{
-#if defined (HAVE_PT_INSN_EVENT)
- while (status & pts_event_pending)
+ pt_event event;
+ int status = pt_insn_event (decoder, &event, sizeof (event));
+ if (status < 0)
+ return status;
+
+ switch (event.type)
{
- struct pt_event event;
- uint64_t offset;
- std::optional<CORE_ADDR> pc;
+ default:
+ break;
- status = pt_insn_event (decoder, &event, sizeof (event));
- if (status < 0)
+ case ptev_enabled:
+ if (event.status_update != 0)
break;
- switch (event.type)
+ /* Only create a new gap if there are non-aux instructions in the
+ trace since the last gap. We could be at the beginning of the
+ recording and could already have handled one or more events, like
+ ptev_iret, that created aux insns. In that case we don't want to
+ create a gap or print a warning. */
+ if (event.variant.enabled.resumed == 0
+ && ftrace_contains_non_aux_since_last_gap (btinfo))
{
- default:
- break;
-
- case ptev_enabled:
- {
- if (event.status_update != 0)
- break;
-
- /* Only create a new gap if there are non-aux instructions in
- the trace since the last gap. We could be at the beginning
- of the recording and could already have handled one or more
- events, like ptev_iret, that created aux insns. In that
- case we don't want to create a gap or print a warning. */
- if (event.variant.enabled.resumed == 0
- && ftrace_contains_non_aux_since_last_gap (btinfo))
- {
- struct btrace_function *bfun
- = ftrace_new_gap (btinfo, BDE_PT_NON_CONTIGUOUS, gaps);
+ btrace_function *bfun
+ = ftrace_new_gap (btinfo, BDE_PT_NON_CONTIGUOUS, gaps);
- pt_insn_get_offset (decoder, &offset);
+ uint64_t offset;
+ pt_insn_get_offset (decoder, &offset);
- warning
- (_("Non-contiguous trace at instruction %u (offset = 0x%"
- PRIx64 ")."), bfun->insn_offset - 1, offset);
- }
+ warning
+ (_("Non-contiguous trace at instruction %u (offset = 0x%"
+ PRIx64 ")."), bfun->insn_offset - 1, offset);
+ }
- break;
- }
+ break;
- case ptev_overflow:
- {
- struct btrace_function *bfun
- = ftrace_new_gap (btinfo, BDE_PT_OVERFLOW, gaps);
+ case ptev_overflow:
+ {
+ btrace_function *bfun
+ = ftrace_new_gap (btinfo, BDE_PT_OVERFLOW, gaps);
- pt_insn_get_offset (decoder, &offset);
+ uint64_t offset;
+ pt_insn_get_offset (decoder, &offset);
- warning (_("Overflow at instruction %u (offset = 0x%" PRIx64 ")."),
- bfun->insn_offset - 1, offset);
+ warning (_("Overflow at instruction %u (offset = 0x%" PRIx64 ")."),
+ bfun->insn_offset - 1, offset);
- break;
- }
+ break;
+ }
#if defined (HAVE_STRUCT_PT_EVENT_VARIANT_PTWRITE)
- case ptev_ptwrite:
+ case ptev_ptwrite:
+ {
+ std::optional<std::string> ptw_string;
+ std::optional<CORE_ADDR> pc;
+
+ /* Lookup the PC if available. The event often doesn't provide
+ one, so we look into the last function segment as well.
+ Looking further back makes limited sense for ptwrite. */
+ if (event.ip_suppressed == 0)
+ pc = event.variant.ptwrite.ip;
+ else if (!btinfo->functions.empty ())
{
- std::optional<std::string> ptw_string;
-
- /* Lookup the PC if available. The event often doesn't provide
- one, so we look into the last function segment as well.
- Looking further back makes limited sense for ptwrite. */
- if (event.ip_suppressed == 0)
- pc = event.variant.ptwrite.ip;
- else if (!btinfo->functions.empty ())
+ std::vector<btrace_insn> &insns = btinfo->functions.back ().insn;
+ for (auto insn = insns.rbegin (); insn != insns.rend (); ++insn)
{
- std::vector<btrace_insn> &insns
- = btinfo->functions.back ().insn;
- for (auto insn = insns.rbegin (); insn != insns.rend ();
- ++insn)
+ switch (insn->iclass)
{
- switch (insn->iclass)
- {
- case BTRACE_INSN_AUX:
- continue;
-
- case BTRACE_INSN_OTHER:
- case BTRACE_INSN_CALL:
- case BTRACE_INSN_RETURN:
- case BTRACE_INSN_JUMP:
- pc = insn->pc;
- break;
- /* No default to rely on compiler warnings. */
- }
+ case BTRACE_INSN_AUX:
+ continue;
+
+ case BTRACE_INSN_OTHER:
+ case BTRACE_INSN_CALL:
+ case BTRACE_INSN_RETURN:
+ case BTRACE_INSN_JUMP:
+ pc = insn->pc;
break;
+ /* No default to rely on compiler warnings. */
}
+ break;
}
+ }
- if (!pc.has_value ())
- warning (_("Failed to determine the PC for ptwrite."));
-
+ if (!pc.has_value ())
+ warning (_("Failed to determine the PC for ptwrite."));
- if (btinfo->ptw_callback_fun != nullptr)
- ptw_string
- = btinfo->ptw_callback_fun (event.variant.ptwrite.payload,
- pc, btinfo->ptw_context);
+ if (btinfo->ptw_callback_fun != nullptr)
+ ptw_string
+ = btinfo->ptw_callback_fun (event.variant.ptwrite.payload,
+ pc, btinfo->ptw_context);
- if (ptw_string.has_value () && (*ptw_string).empty ())
- continue;
+ if (ptw_string.has_value () && (*ptw_string).empty ())
+ break;
- if (!ptw_string.has_value ())
- ptw_string = hex_string (event.variant.ptwrite.payload);
+ if (!ptw_string.has_value ())
+ ptw_string = hex_string (event.variant.ptwrite.payload);
- handle_pt_aux_insn (btinfo, *ptw_string, pc);
+ handle_pt_aux_insn (btinfo, *ptw_string, pc);
- break;
- }
+ break;
+ }
#endif /* defined (HAVE_STRUCT_PT_EVENT_VARIANT_PTWRITE) */
#if (LIBIPT_VERSION >= 0x201)
- case ptev_interrupt:
- {
- std::string aux_string = std::string (_("interrupt: vector = "))
- + hex_string (event.variant.interrupt.vector);
-
- const char *decoded
- = decode_interrupt_vector (event.variant.interrupt.vector);
- if (decoded != nullptr)
- aux_string += std::string (" (") + decoded + ")";
+ case ptev_interrupt:
+ {
+ std::string aux_string = std::string (_("interrupt: vector = "))
+ + hex_string (event.variant.interrupt.vector);
+ std::optional<CORE_ADDR> pc;
- if (event.variant.interrupt.has_cr2 != 0)
- {
- aux_string += std::string (", cr2 = ")
- + hex_string (event.variant.interrupt.cr2);
- }
+ const char *decoded
+ = decode_interrupt_vector (event.variant.interrupt.vector);
+ if (decoded != nullptr)
+ aux_string += std::string (" (") + decoded + ")";
- if (event.ip_suppressed == 0)
- {
- pc = event.variant.interrupt.ip;
- aux_string += std::string (", ip = ") + hex_string (*pc);
- }
-
- handle_pt_aux_insn (btinfo, aux_string, pc);
- break;
+ if (event.variant.interrupt.has_cr2 != 0)
+ {
+ aux_string += std::string (", cr2 = ")
+ + hex_string (event.variant.interrupt.cr2);
}
- case ptev_iret:
+ if (event.ip_suppressed == 0)
{
- std::string aux_string = std::string (_("iret"));
+ pc = event.variant.interrupt.ip;
+ aux_string += std::string (", ip = ") + hex_string (*pc);
+ }
- if (event.ip_suppressed == 0)
- {
- pc = event.variant.iret.ip;
- aux_string += std::string (": ip = ") + hex_string (*pc);
- }
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
- handle_pt_aux_insn (btinfo, aux_string, pc);
- break;
- }
+ case ptev_iret:
+ {
+ std::string aux_string = std::string (_("iret"));
+ std::optional<CORE_ADDR> pc;
- case ptev_smi:
+ if (event.ip_suppressed == 0)
{
- std::string aux_string = std::string (_("smi"));
+ pc = event.variant.iret.ip;
+ aux_string += std::string (": ip = ") + hex_string (*pc);
+ }
- if (event.ip_suppressed == 0)
- {
- pc = event.variant.smi.ip;
- aux_string += std::string (": ip = ") + hex_string (*pc);
- }
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
- handle_pt_aux_insn (btinfo, aux_string, pc);
- break;
- }
+ case ptev_smi:
+ {
+ std::string aux_string = std::string (_("smi"));
+ std::optional<CORE_ADDR> pc;
- case ptev_rsm:
+ if (event.ip_suppressed == 0)
{
- std::string aux_string = std::string (_("rsm"));
+ pc = event.variant.smi.ip;
+ aux_string += std::string (": ip = ") + hex_string (*pc);
+ }
- if (event.ip_suppressed == 0)
- {
- pc = event.variant.rsm.ip;
- aux_string += std::string (": ip = ") + hex_string (*pc);
- }
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
- handle_pt_aux_insn (btinfo, aux_string, pc);
- break;
- }
+ case ptev_rsm:
+ {
+ std::string aux_string = std::string (_("rsm"));
+ std::optional<CORE_ADDR> pc;
- case ptev_sipi:
+ if (event.ip_suppressed == 0)
{
- std::string aux_string = std::string (_("sipi: vector = "))
- + hex_string (event.variant.sipi.vector);
-
- handle_pt_aux_insn (btinfo, aux_string, pc);
- break;
+ pc = event.variant.rsm.ip;
+ aux_string += std::string (": ip = ") + hex_string (*pc);
}
- case ptev_init:
- {
- std::string aux_string = std::string (_("init"));
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
- if (event.ip_suppressed == 0)
- {
- pc = event.variant.init.ip;
- aux_string += std::string (": ip = ") + hex_string (*pc);
- }
+ case ptev_sipi:
+ {
+ std::string aux_string = std::string (_("sipi: vector = "))
+ + hex_string (event.variant.sipi.vector);
+ std::optional<CORE_ADDR> pc;
- handle_pt_aux_insn (btinfo, aux_string, pc);
- break;
- }
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
- case ptev_vmentry:
+ case ptev_init:
+ {
+ std::string aux_string = std::string (_("init"));
+ std::optional<CORE_ADDR> pc;
+
+ if (event.ip_suppressed == 0)
{
- std::string aux_string = std::string (_("vmentry"));
+ pc = event.variant.init.ip;
+ aux_string += std::string (": ip = ") + hex_string (*pc);
+ }
- if (event.ip_suppressed == 0)
- {
- pc = event.variant.vmentry.ip;
- aux_string += std::string (": ip = ") + hex_string (*pc);
- }
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
- handle_pt_aux_insn (btinfo, aux_string, pc);
- break;
- }
+ case ptev_vmentry:
+ {
+ std::string aux_string = std::string (_("vmentry"));
+ std::optional<CORE_ADDR> pc;
- case ptev_vmexit:
+ if (event.ip_suppressed == 0)
{
- std::string aux_string = std::string (_("vmexit"));
+ pc = event.variant.vmentry.ip;
+ aux_string += std::string (": ip = ") + hex_string (*pc);
+ }
- if (event.variant.vmexit.has_vector != 0
- || event.variant.vmexit.has_vmxr != 0
- || event.variant.vmexit.has_vmxq != 0
- || event.ip_suppressed != 0)
- aux_string += std::string (":");
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
- if (event.variant.vmexit.has_vector != 0)
- {
- aux_string += std::string (_(" vector = "))
- + hex_string (event.variant.vmexit.vector);
+ case ptev_vmexit:
+ {
+ std::string aux_string = std::string (_("vmexit"));
+ std::optional<CORE_ADDR> pc;
- const char* decoded = decode_interrupt_vector
- (event.variant.vmexit.vector);
- if (decoded != nullptr)
- aux_string += std::string (" (") + decoded + ")";
- }
+ if (event.variant.vmexit.has_vector != 0
+ || event.variant.vmexit.has_vmxr != 0
+ || event.variant.vmexit.has_vmxq != 0
+ || event.ip_suppressed != 0)
+ aux_string += std::string (":");
- if (event.variant.vmexit.has_vmxr != 0)
- {
- std::string separator = aux_string.back () == ':' ? "" : ",";
- aux_string += separator + std::string (" vmxr = ")
- + hex_string (event.variant.vmexit.vmxr);
- }
+ if (event.variant.vmexit.has_vector != 0)
+ {
+ aux_string += std::string (_(" vector = "))
+ + hex_string (event.variant.vmexit.vector);
- if (event.variant.vmexit.has_vmxq != 0)
- {
- std::string separator = aux_string.back () == ':' ? "" : ",";
- aux_string += separator + std::string (" vmxq = ")
- + hex_string (event.variant.vmexit.vmxq);
- }
+ const char* decoded = decode_interrupt_vector
+ (event.variant.vmexit.vector);
+ if (decoded != nullptr)
+ aux_string += std::string (" (") + decoded + ")";
+ }
- if (event.ip_suppressed == 0)
- {
- pc = event.variant.vmexit.ip;
- std::string separator = aux_string.back () == ':' ? "" : ",";
- aux_string += separator + std::string (" ip = ")
- + hex_string (*pc);
- }
+ if (event.variant.vmexit.has_vmxr != 0)
+ {
+ std::string separator = aux_string.back () == ':' ? "" : ",";
+ aux_string += separator + std::string (" vmxr = ")
+ + hex_string (event.variant.vmexit.vmxr);
+ }
- handle_pt_aux_insn (btinfo, aux_string, pc);
- break;
+ if (event.variant.vmexit.has_vmxq != 0)
+ {
+ std::string separator = aux_string.back () == ':' ? "" : ",";
+ aux_string += separator + std::string (" vmxq = ")
+ + hex_string (event.variant.vmexit.vmxq);
}
- case ptev_shutdown:
+ if (event.ip_suppressed == 0)
{
- std::string aux_string = std::string (_("shutdown"));
+ pc = event.variant.vmexit.ip;
+ std::string separator = aux_string.back () == ':' ? "" : ",";
+ aux_string += separator + std::string (" ip = ")
+ + hex_string (*pc);
+ }
- if (event.ip_suppressed == 0)
- {
- pc = event.variant.shutdown.ip;
- aux_string += std::string (": ip = ") + hex_string (*pc);
- }
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
- handle_pt_aux_insn (btinfo, aux_string, pc);
- break;
- }
+ case ptev_shutdown:
+ {
+ std::string aux_string = std::string (_("shutdown"));
+ std::optional<CORE_ADDR> pc;
- case ptev_uintr:
+ if (event.ip_suppressed == 0)
{
- std::string aux_string = std::string (_("uintr: vector = "))
- + hex_string (event.variant.uintr.vector);
+ pc = event.variant.shutdown.ip;
+ aux_string += std::string (": ip = ") + hex_string (*pc);
+ }
- if (event.ip_suppressed == 0)
- {
- pc = event.variant.uintr.ip;
- aux_string += std::string (", ip = ") + hex_string (*pc);
- }
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
- handle_pt_aux_insn (btinfo, aux_string, pc);
- break;
- }
+ case ptev_uintr:
+ {
+ std::string aux_string = std::string (_("uintr: vector = "))
+ + hex_string (event.variant.uintr.vector);
+ std::optional<CORE_ADDR> pc;
- case ptev_uiret:
+ if (event.ip_suppressed == 0)
{
- std::string aux_string = std::string (_("uiret"));
+ pc = event.variant.uintr.ip;
+ aux_string += std::string (", ip = ") + hex_string (*pc);
+ }
- if (event.ip_suppressed == 0)
- {
- pc = event.variant.uiret.ip;
- aux_string += std::string (": ip = ") + hex_string (*pc);
- }
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
- handle_pt_aux_insn (btinfo, aux_string, pc);
- break;
- }
-#endif /* (LIBIPT_VERSION >= 0x201) */
+ case ptev_uiret:
+ {
+ std::string aux_string = std::string (_("uiret"));
+ std::optional<CORE_ADDR> pc;
-#if (LIBIPT_VERSION >= 0x202)
- case ptev_trig:
+ if (event.ip_suppressed == 0)
{
- std::string aux_string
- = (std::string (_("trig: trbv = "))
- + hex_string (event.variant.trig.trbv));
+ pc = event.variant.uiret.ip;
+ aux_string += std::string (": ip = ") + hex_string (*pc);
+ }
- if (event.variant.trig.mult != 0)
- aux_string += std::string (", mult");
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
+#endif /* (LIBIPT_VERSION >= 0x201) */
- if (event.ip_suppressed == 0)
- {
- pc = event.variant.trig.ip;
- aux_string += (std::string (", ip = ") + hex_string (*pc));
- }
+#if (LIBIPT_VERSION >= 0x202)
+ case ptev_trig:
+ {
+ std::string aux_string
+ = (std::string (_("trig: trbv = "))
+ + hex_string (event.variant.trig.trbv));
+ std::optional<CORE_ADDR> pc;
- if (event.variant.trig.icnt != 0)
- aux_string += (std::string (", icnt = ")
- + hex_string (event.variant.trig.icnt));
+ if (event.variant.trig.mult != 0)
+ aux_string += std::string (", mult");
- handle_pt_aux_insn (btinfo, aux_string, pc);
- break;
+ if (event.ip_suppressed == 0)
+ {
+ pc = event.variant.trig.ip;
+ aux_string += (std::string (", ip = ") + hex_string (*pc));
}
- case ptev_swintr:
- {
- std::string aux_string
- = (std::string (_("swintr: vector = "))
- + hex_string (event.variant.swintr.vector));
+ if (event.variant.trig.icnt != 0)
+ aux_string += (std::string (", icnt = ")
+ + hex_string (event.variant.trig.icnt));
- if (event.ip_suppressed == 0)
- {
- pc = event.variant.swintr.ip;
- aux_string += (std::string (", ip = ") + hex_string (*pc));
- }
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
- handle_pt_aux_insn (btinfo, aux_string, pc);
- break;
- }
+ case ptev_swintr:
+ {
+ std::string aux_string
+ = (std::string (_("swintr: vector = "))
+ + hex_string (event.variant.swintr.vector));
+ std::optional<CORE_ADDR> pc;
- case ptev_syscall:
+ if (event.ip_suppressed == 0)
{
- std::string aux_string = std::string (_("syscall"));
+ pc = event.variant.swintr.ip;
+ aux_string += (std::string (", ip = ") + hex_string (*pc));
+ }
- if (event.ip_suppressed == 0)
- {
- pc = event.variant.syscall.ip;
- aux_string += (std::string (": ip = ") + hex_string (*pc));
- }
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
- handle_pt_aux_insn (btinfo, aux_string, pc);
- break;
+ case ptev_syscall:
+ {
+ std::string aux_string = std::string (_("syscall"));
+ std::optional<CORE_ADDR> pc;
+
+ if (event.ip_suppressed == 0)
+ {
+ pc = event.variant.syscall.ip;
+ aux_string += (std::string (": ip = ") + hex_string (*pc));
}
+
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
#endif /* (LIBIPT_VERSION >= 0x202) */
- }
}
-#endif /* defined (HAVE_PT_INSN_EVENT) */
return status;
}
+#endif /* defined (HAVE_PT_INSN_EVENT) */
/* Handle events indicated by flags in INSN (libipt-v1). */
@@ -1735,8 +1740,11 @@ ftrace_add_pt (struct btrace_thread_info *btinfo,
for (;;)
{
+#if defined (HAVE_PT_INSN_EVENT)
/* Handle events from the previous iteration or synchronization. */
- status = handle_pt_insn_events (btinfo, decoder, gaps, status);
+ while ((status != 0) && (status & pts_event_pending))
+ status = handle_pt_insn_event (btinfo, decoder, gaps);
+#endif
if (status < 0)
break;
--
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.
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 2/5] gdb, btrace: refactor ftrace_add_pt()
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 ` Markus Metzger
2026-10-30 13:57 ` [PATCH 3/5] gdb, btrace: fix btrace remote configuration Markus Metzger
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Markus Metzger @ 2026-10-30 13:57 UTC (permalink / raw)
To: gdb-patches
Extract the main decode loop and generating a decode error warning out of
ftrace_add_pt() to prepare for a subsequent patch to extend decode error
handling.
There should be no functional change except that the decode error warning
would now print pc=? if an error was added after a preceding gap or
auxiliary instruction instead of the PC of the last real instruction.
The PC value now matches the instruction offset that is also printed with
the decode error warning.
---
gdb/btrace.c | 112 +++++++++++++++++++++++++++++++--------------------
1 file changed, 69 insertions(+), 43 deletions(-)
diff --git a/gdb/btrace.c b/gdb/btrace.c
index ddc7b2551df..5c47f9129ae 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -1710,26 +1710,83 @@ handle_pt_insn_event_flags (struct btrace_thread_info *btinfo,
#endif /* defined (HAVE_STRUCT_PT_INSN_RESYNCED) */
}
+/* Generate a decode error warning. */
+
+static void
+ftrace_warn_pt (btrace_thread_info *btinfo, pt_insn_decoder *decoder,
+ btrace_function *bfun, int status)
+{
+ gdb_assert (bfun != nullptr);
+
+ unsigned int ioffset = bfun->insn_offset - 1;
+ uint64_t offset;
+ pt_insn_get_offset (decoder, &offset);
+
+ btrace_insn_iterator it;
+ int found = btrace_find_insn_by_number (&it, btinfo, ioffset);
+ const btrace_insn *binsn = (found != 0) ? btrace_insn_get (&it) : nullptr;
+
+ warning (_("Decode error (%d) at instruction %u (offset = 0x%" PRIx64
+ ", pc = %s): %s."), status, ioffset, offset,
+ (binsn != nullptr) ? hex_string (binsn->pc) : "?",
+ pt_errstr (pt_errcode (status)));
+}
+
+/* Decode the trace and handle events as long as there is no error.
+ Returns the last decoder status. */
+
+static int
+ftrace_decode_pt (btrace_thread_info *btinfo,
+ pt_insn_decoder *decoder,
+ int *plevel,
+ std::vector<unsigned int> &gaps,
+ int status)
+{
+ gdb_assert (status >= 0);
+ for (;;)
+ {
+#if defined (HAVE_PT_INSN_EVENT)
+ /* Handle events from the previous iteration or synchronization. */
+ while (status & pts_event_pending)
+ {
+ status = handle_pt_insn_event (btinfo, decoder, gaps);
+ if (status < 0)
+ return status;
+ }
+#endif
+ pt_insn insn;
+ status = pt_insn_next (decoder, &insn, sizeof (insn));
+ if (status < 0)
+ return status;
+
+ /* Handle events indicated by flags in INSN. */
+ handle_pt_insn_event_flags (btinfo, decoder, insn, gaps);
+
+ btrace_function *bfun
+ = ftrace_update_function (btinfo,
+ std::make_optional<CORE_ADDR> (insn.ip));
+
+ /* Maintain the function level offset. */
+ *plevel = std::min (*plevel, bfun->level);
+
+ ftrace_update_insns (bfun, pt_btrace_insn (insn));
+ }
+}
+
/* Add function branch trace to BTINFO using DECODER. */
static void
-ftrace_add_pt (struct btrace_thread_info *btinfo,
- struct pt_insn_decoder *decoder,
+ftrace_add_pt (btrace_thread_info *btinfo,
+ pt_insn_decoder *decoder,
int *plevel,
std::vector<unsigned int> &gaps)
{
- struct btrace_function *bfun;
- uint64_t offset;
- int status;
-
/* Register the ptwrite filter. */
apply_ext_lang_ptwrite_filter (btinfo);
for (;;)
{
- struct pt_insn insn;
-
- status = pt_insn_sync_forward (decoder);
+ int status = pt_insn_sync_forward (decoder);
if (status < 0)
{
if (status != -pte_eos)
@@ -1738,44 +1795,13 @@ ftrace_add_pt (struct btrace_thread_info *btinfo,
break;
}
- for (;;)
- {
-#if defined (HAVE_PT_INSN_EVENT)
- /* Handle events from the previous iteration or synchronization. */
- while ((status != 0) && (status & pts_event_pending))
- status = handle_pt_insn_event (btinfo, decoder, gaps);
-#endif
- if (status < 0)
- break;
-
- status = pt_insn_next (decoder, &insn, sizeof(insn));
- if (status < 0)
- break;
-
- /* Handle events indicated by flags in INSN. */
- handle_pt_insn_event_flags (btinfo, decoder, insn, gaps);
-
- bfun
- = ftrace_update_function (btinfo,
- std::make_optional<CORE_ADDR> (insn.ip));
-
- /* Maintain the function level offset. */
- *plevel = std::min (*plevel, bfun->level);
-
- ftrace_update_insns (bfun, pt_btrace_insn (insn));
- }
-
+ status = ftrace_decode_pt (btinfo, decoder, plevel, gaps, status);
if (status == -pte_eos)
break;
/* Indicate the gap in the trace. */
- bfun = ftrace_new_gap (btinfo, status, gaps);
-
- pt_insn_get_offset (decoder, &offset);
-
- warning (_("Decode error (%d) at instruction %u (offset = 0x%" PRIx64
- ", pc = 0x%" PRIx64 "): %s."), status, bfun->insn_offset - 1,
- offset, insn.ip, pt_errstr (pt_errcode (status)));
+ btrace_function *bfun = ftrace_new_gap (btinfo, status, gaps);
+ ftrace_warn_pt (btinfo, decoder, bfun, status);
}
}
--
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.
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 3/5] gdb, btrace: fix btrace remote configuration
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
2026-10-30 13:57 ` [PATCH 4/5] gdb, gdbserver, btrace: allow disabling return compression Markus Metzger
2026-10-30 13:57 ` [PATCH 5/5] gdb, gdbserver, btrace: resync on error Markus Metzger
4 siblings, 0 replies; 8+ messages in thread
From: Markus Metzger @ 2026-10-30 13:57 UTC (permalink / raw)
To: gdb-patches
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.
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 4/5] gdb, gdbserver, btrace: allow disabling return compression
2026-10-30 13:57 [PATCH 0/5] gdb, gdbserver, btrace: enhanced resync on decode error Markus Metzger
` (2 preceding siblings ...)
2026-10-30 13:57 ` [PATCH 3/5] gdb, btrace: fix btrace remote configuration Markus Metzger
@ 2026-10-30 13:57 ` 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
4 siblings, 1 reply; 8+ messages in thread
From: Markus Metzger @ 2026-10-30 13:57 UTC (permalink / raw)
To: gdb-patches
When recording with Intel Processor Trace, return compression is enabled
by default and can be explicitly disabled.
Add a new setting
set record btrace pt return-compression on|off
to expose that functionality and a new RSP packet
Qbtrace-conf:pt:return-compression
to configure this for remote targets.
---
gdb/NEWS | 9 ++++++
gdb/doc/gdb.texinfo | 32 ++++++++++++++++++++
gdb/features/btrace-conf.dtd | 1 +
gdb/nat/linux-btrace.c | 4 +++
gdb/record-btrace.c | 36 ++++++++++++++++++++++
gdb/remote.c | 58 ++++++++++++++++++++++++++++++++++--
gdbserver/linux-low.cc | 2 ++
gdbserver/server.cc | 15 ++++++++++
gdbsupport/btrace-common.h | 3 ++
9 files changed, 158 insertions(+), 2 deletions(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index 7303ec0e460..cddecf2040e 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -71,6 +71,10 @@ maintenance info source-tracking-context BPNUM
Displays the captured source context that GDB uses to track and
adjust a breakpoint when source changes.
+set record btrace pt return-compression on|off
+show record btrace pt return-compression
+ Enable or disable Intel Processor Trace return compression (default: on).
+
* Changed commands
set stop-on-solib-events on|off
@@ -83,6 +87,11 @@ info locals
The new "-shadowed on|off" option overrides the "set print shadowed"
setting for a single invocation of the command.
+* New remote packets
+
+Qbtrace-conf:pt:return-compression
+ Configure Intel Processor Trace return-compression settings.
+
*** Changes in GDB 18
* Support for the Common Trace Format (CTF) has been removed. GDB now
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 66152d2582e..8cfaffd4fc7 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -8422,6 +8422,17 @@ effect on an active recording. The default is off.
@item show record btrace pt event-tracing
Show the current setting of Intel Processor Trace event tracing.
+@item set record btrace pt return-compression on|off
+Enable or disable Intel Processor Trace return compression. This is a
+hardware compression technique that represents a return to the natural
+return address of a preceding call instruction with a single bit. The
+trace decoder maintains a stack of active calls and can determine the
+return address of such a compressed return. This reduces tracing
+overhead and trace size. The default is on.
+
+@item show record btrace pt return-compression
+Show the current setting of Intel Processor Trace return compression.
+
@kindex info record
@item info record
Show various statistics about the recording depending on the recording
@@ -45843,6 +45854,11 @@ These are the currently defined stub features and their properties:
@tab @samp{-}
@tab Yes
+@item @samp{Qbtrace-conf:pt:return-compression}
+@tab Yes
+@tab @samp{-}
+@tab Yes
+
@item @samp{QNonStop}
@tab No
@tab @samp{-}
@@ -46185,6 +46201,10 @@ The remote stub understands the @samp{Qbtrace-conf:pt:ptwrite} packet.
@item Qbtrace-conf:pt:event-tracing
The remote stub understands the @samp{Qbtrace-conf:pt:event-tracing} packet.
+@item Qbtrace-conf:pt:return-compression
+The remote stub understands the @samp{Qbtrace-conf:pt:return-compression}
+packet.
+
@item swbreak
The remote stub reports the @samp{swbreak} stop reason for memory
breakpoints.
@@ -46754,6 +46774,17 @@ The event-tracing config parameter has been set.
A badly formed request or an error was encountered.
@end table
+@item Qbtrace-conf:pt:return-compression=@var{(yes|no)}
+Configure Intel Processor Trace return-compression.
+
+Reply:
+@table @samp
+@item OK
+The return-compression config parameter has been set.
+@item E.errtext
+A badly formed request or an error was encountered.
+@end table
+
@end table
@node Architecture-Specific Protocol Details
@@ -49422,6 +49453,7 @@ The formal DTD for the branch trace configuration format is given below:
<!ATTLIST pt size CDATA #IMPLIED>
<!ATTLIST pt ptwrite (yes | no) #IMPLIED>
<!ATTLIST pt event-tracing (yes | no) #IMPLIED>
+<!ATTLIST pt return-compression (yes | no) #IMPLIED>
@end smallexample
@include agentexpr.texi
diff --git a/gdb/features/btrace-conf.dtd b/gdb/features/btrace-conf.dtd
index 717da623d3e..94b18be63e2 100644
--- a/gdb/features/btrace-conf.dtd
+++ b/gdb/features/btrace-conf.dtd
@@ -14,3 +14,4 @@
<!ATTLIST pt size CDATA #IMPLIED>
<!ATTLIST pt ptwrite (yes | no) #IMPLIED>
<!ATTLIST pt event-tracing (yes | no) #IMPLIED>
+<!ATTLIST pt return-compression (yes | no) #IMPLIED>
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
index 2e0c2eedfbb..8f0c4c1b442 100644
--- a/gdb/nat/linux-btrace.c
+++ b/gdb/nat/linux-btrace.c
@@ -697,6 +697,10 @@ linux_enable_pt (ptid_t ptid, const struct btrace_config_pt *conf)
error (_("Event tracing for record btrace pt is not supported."));
}
+ tinfo->conf.pt.return_compression = conf->return_compression;
+ if (!tinfo->conf.pt.return_compression)
+ tinfo->attr.config |= linux_read_pt_config_bitmask ("noretcomp");
+
errno = 0;
scoped_fd fd (syscall (SYS_perf_event_open, &tinfo->attr, pid, -1, -1, 0));
if (fd.get () < 0)
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index dae243ee2db..30cd8c8b2b6 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -3146,6 +3146,27 @@ set_record_pt_event_tracing_value (const char *args, int from_tty,
#endif /* defined (LIBIPT_VERSION >= 0x201) */
}
+static bool return_compression = true;
+
+/* The "record pt return-compression show value function. */
+
+static void
+show_record_pt_return_compression_value (ui_file *file, int from_tty,
+ cmd_list_element *c,
+ const char *value)
+{
+ gdb_printf (file, _("record pt return-compression is %s.\n"), value);
+}
+
+/* The "record pt return-compression" set value function. */
+
+static void
+set_record_pt_return_compression_value (const char *args, int from_tty,
+ cmd_list_element *c)
+{
+ record_btrace_conf.pt.return_compression = return_compression;
+}
+
/* Initialize btrace commands. */
INIT_GDB_FILE (record_btrace)
@@ -3276,6 +3297,20 @@ effect on an active recording."),
&set_record_btrace_pt_cmdlist,
&show_record_btrace_pt_cmdlist);
+ add_setshow_boolean_cmd ("return-compression", no_class,
+ &return_compression,
+ _("Set return-compression for record pt."),
+ _("Show return-compression for record pt."),
+ _("\
+Use \"on\" to enable Intel Processor Trace return compression and \"off\" to\n\
+disable it.\n\
+Without an argument, return-compression is enabled. Changing this setting\n\
+has no effect on an active recording. The default is \"on\"."),
+ set_record_pt_return_compression_value,
+ show_record_pt_return_compression_value,
+ &set_record_btrace_pt_cmdlist,
+ &show_record_btrace_pt_cmdlist);
+
add_target (record_btrace_target_info, record_btrace_target_open);
record_btrace_conf.bts.size = 64 * 1024;
@@ -3286,4 +3321,5 @@ effect on an active recording."),
record_btrace_conf.pt.ptwrite = false;
#endif
record_btrace_conf.pt.event_tracing = false;
+ record_btrace_conf.pt.return_compression = return_compression;
}
diff --git a/gdb/remote.c b/gdb/remote.c
index e0e508bd0ce..3e564fdd91f 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -373,6 +373,9 @@ enum {
/* Support for the Qbtrace-conf:pt:event-tracing packet. */
PACKET_Qbtrace_conf_pt_event_tracing,
+ /* Support for the Qbtrace-conf:pt:return-compression packet. */
+ PACKET_Qbtrace_conf_pt_return_compression,
+
/* Support for exec events. */
PACKET_exec_event_feature,
@@ -6181,6 +6184,8 @@ static const struct protocol_feature remote_protocol_features[] = {
PACKET_Qbtrace_conf_pt_ptwrite },
{ "Qbtrace-conf:pt:event-tracing", PACKET_DISABLE, remote_supported_packet,
PACKET_Qbtrace_conf_pt_event_tracing },
+ { "Qbtrace-conf:pt:return-compression", PACKET_DISABLE,
+ remote_supported_packet, PACKET_Qbtrace_conf_pt_return_compression },
{ "vContSupported", PACKET_DISABLE, remote_supported_packet, PACKET_vContSupported },
{ "QThreadEvents", PACKET_DISABLE, remote_supported_packet, PACKET_QThreadEvents },
{ "QThreadOptions", PACKET_DISABLE, remote_supported_thread_options,
@@ -15359,8 +15364,8 @@ parse_xml_btrace_conf_pt (struct gdb_xml_parser *parser,
void *user_data,
std::vector<gdb_xml_value> &attributes)
{
- struct btrace_config *conf;
- struct gdb_xml_value *size, *ptwrite, *event_tracing;
+ btrace_config *conf;
+ gdb_xml_value *size, *ptwrite, *event_tracing, *return_compression;
conf = (struct btrace_config *) user_data;
conf->format = BTRACE_FORMAT_PT;
@@ -15377,6 +15382,11 @@ parse_xml_btrace_conf_pt (struct gdb_xml_parser *parser,
event_tracing = xml_find_attribute (attributes, "event-tracing");
if (event_tracing != nullptr)
conf->pt.event_tracing = (bool) *(ULONGEST *) event_tracing->value.get ();
+
+ return_compression = xml_find_attribute (attributes, "return-compression");
+ if (return_compression != nullptr)
+ conf->pt.return_compression
+ = (bool) *(ULONGEST *) return_compression->value.get ();
}
static const struct gdb_xml_attribute btrace_conf_pt_attributes[] = {
@@ -15385,6 +15395,8 @@ static const struct gdb_xml_attribute btrace_conf_pt_attributes[] = {
gdb_xml_enums_boolean },
{ "event-tracing", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_enum,
gdb_xml_enums_boolean },
+ { "return-compression", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_enum,
+ gdb_xml_enums_boolean },
{ NULL, GDB_XML_AF_NONE, NULL, NULL }
};
@@ -15551,6 +15563,44 @@ remote_target::btrace_sync_conf (const btrace_config *conf)
rs->btrace_config.pt.event_tracing = conf->pt.event_tracing;
}
+
+ /* Return compression is a user setting, which is enabled by default on
+ older targets. Warn if it is set but the target doesn't support
+ it. */
+ if ((m_features.packet_support (PACKET_Qbtrace_conf_pt_return_compression)
+ != PACKET_ENABLE)
+ && !conf->pt.return_compression)
+ warning (_("Target does not support disabling return-compression."));
+
+ if (m_features.packet_support (PACKET_Qbtrace_conf_pt_return_compression)
+ == PACKET_ENABLE)
+ {
+ pos = buf;
+ const char *return_compression
+ = conf->pt.return_compression ? "yes" : "no";
+ const char *name
+ = packets_descriptions[PACKET_Qbtrace_conf_pt_return_compression]
+ .name;
+ pos += xsnprintf (pos, endbuf - pos, "%s=\"%s\"", name,
+ return_compression);
+
+ putpkt (buf);
+ getpkt (&rs->buf, 0);
+
+ packet_result result
+ = m_features.packet_ok (buf,
+ PACKET_Qbtrace_conf_pt_return_compression);
+ if (result.status () == PACKET_ERROR)
+ {
+ if (buf[0] == 'E' && buf[1] == '.')
+ error (_("Failed to sync return-compression config: %s"),
+ buf + 2);
+ else
+ error (_("Failed to sync return-compression config."));
+ }
+
+ rs->btrace_config.pt.return_compression = conf->pt.return_compression;
+ }
}
/* Read TP's btrace configuration from the target and store it into CONF. */
@@ -17014,6 +17064,10 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL,
"Qbtrace-conf:pt:event-tracing",
"btrace-conf-pt-event-tracing", 0);
+ add_packet_config_cmd (PACKET_Qbtrace_conf_pt_return_compression,
+ "Qbtrace-conf:pt:return-compression",
+ "btrace-conf-pt-return-compression", 0);
+
add_packet_config_cmd (PACKET_vContSupported, "vContSupported",
"verbose-resume-supported", 0);
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index c4daba0bf40..7bcb85e641a 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -7025,6 +7025,8 @@ linux_process_target::read_btrace_conf (const btrace_target_info *tinfo,
conf->pt.ptwrite ? "yes" : "no");
string_xml_appendf (*buffer, " event-tracing=\"%s\"",
conf->pt.event_tracing ? "yes" : "no");
+ string_xml_appendf (*buffer, " return-compression=\"%s\"",
+ conf->pt.return_compression ? "yes" : "no");
string_xml_appendf (*buffer, "/>\n");
break;
}
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 74774fcde7c..26837225785 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -568,6 +568,20 @@ handle_btrace_conf_general_set (char *own_buf)
return -1;
}
}
+ else if (strncmp (op, "pt:return-compression=",
+ strlen ("pt:return-compression=")) == 0)
+ {
+ op += strlen ("pt:return-compression=");
+ if (strncmp (op, "\"yes\"", strlen ("\"yes\"")) == 0)
+ current_btrace_conf.pt.return_compression = true;
+ else if (strncmp (op, "\"no\"", strlen ("\"no\"")) == 0)
+ current_btrace_conf.pt.return_compression = false;
+ else
+ {
+ strcpy (own_buf, "E.Bad return-compression value.");
+ return -1;
+ }
+ }
else
{
strcpy (own_buf, "E.Bad Qbtrace configuration option.");
@@ -2482,6 +2496,7 @@ supported_btrace_packets (char *buf)
strcat (buf, ";Qbtrace-conf:pt:size+");
strcat (buf, ";Qbtrace-conf:pt:ptwrite+");
strcat (buf, ";Qbtrace-conf:pt:event-tracing+");
+ strcat (buf, ";Qbtrace-conf:pt:return-compression+");
strcat (buf, ";Qbtrace:off+");
strcat (buf, ";qXfer:btrace:read+");
strcat (buf, ";qXfer:btrace-conf:read+");
diff --git a/gdbsupport/btrace-common.h b/gdbsupport/btrace-common.h
index 928e471de8f..f2b274c79a7 100644
--- a/gdbsupport/btrace-common.h
+++ b/gdbsupport/btrace-common.h
@@ -126,6 +126,9 @@ struct btrace_config_pt
/* Event tracing setting. */
bool event_tracing;
+
+ /* Return compression setting. */
+ bool return_compression;
};
/* A branch tracing configuration.
--
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.
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 4/5] gdb, gdbserver, btrace: allow disabling return compression
2026-10-30 13:57 ` [PATCH 4/5] gdb, gdbserver, btrace: allow disabling return compression Markus Metzger
@ 2026-10-30 14:30 ` Eli Zaretskii
0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2026-10-30 14:30 UTC (permalink / raw)
To: Markus Metzger; +Cc: gdb-patches
> From: Markus Metzger <markus.t.metzger@intel.com>
> Date: Fri, 30 Oct 2026 14:57:43 +0100
>
> When recording with Intel Processor Trace, return compression is enabled
> by default and can be explicitly disabled.
>
> Add a new setting
>
> set record btrace pt return-compression on|off
>
> to expose that functionality and a new RSP packet
>
> Qbtrace-conf:pt:return-compression
>
> to configure this for remote targets.
> ---
> gdb/NEWS | 9 ++++++
> gdb/doc/gdb.texinfo | 32 ++++++++++++++++++++
> gdb/features/btrace-conf.dtd | 1 +
> gdb/nat/linux-btrace.c | 4 +++
> gdb/record-btrace.c | 36 ++++++++++++++++++++++
> gdb/remote.c | 58 ++++++++++++++++++++++++++++++++++--
> gdbserver/linux-low.cc | 2 ++
> gdbserver/server.cc | 15 ++++++++++
> gdbsupport/btrace-common.h | 3 ++
> 9 files changed, 158 insertions(+), 2 deletions(-)
Thanks, the documentation parts of this are okay.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 5/5] gdb, gdbserver, btrace: resync on error
2026-10-30 13:57 [PATCH 0/5] gdb, gdbserver, btrace: enhanced resync on decode error Markus Metzger
` (3 preceding siblings ...)
2026-10-30 13:57 ` [PATCH 4/5] gdb, gdbserver, btrace: allow disabling return compression Markus Metzger
@ 2026-10-30 13:57 ` Markus Metzger
2026-10-30 14:31 ` Eli Zaretskii
4 siblings, 1 reply; 8+ messages in thread
From: Markus Metzger @ 2026-10-30 13:57 UTC (permalink / raw)
To: gdb-patches
Starting with libipt version 2.2, we can try to re-synchronize on the next
IP-providing packet instead of skipping everything until the next trace
stream synchronization packet on CPUs that do not support deferred TIPs.
Add a new setting
set record btrace pt enhanced-resync on|off
to enable that on supported CPUs and extend the
qXfer:btrace:read
response with a new attribute
allow_resync
in the pt-config part of the response.
This should normally not be needed and the setting defaults to off. When
running into decode errors, however, it may help as an advanced option to
make the most out of the recorded trace.
---
gdb/NEWS | 12 +++++++
gdb/btrace.c | 68 +++++++++++++++++++++++++++++++++-----
gdb/doc/gdb.texinfo | 26 +++++++++++++++
gdb/features/btrace.dtd | 1 +
gdb/nat/linux-btrace.c | 1 +
gdb/record-btrace.c | 57 +++++++++++++++++++++++++++++++-
gdb/record-btrace.h | 5 +++
gdb/remote.c | 27 +++++++++++++--
gdbserver/linux-low.cc | 3 +-
gdbsupport/btrace-common.h | 6 ++++
10 files changed, 194 insertions(+), 12 deletions(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index cddecf2040e..c582095068a 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -75,6 +75,11 @@ set record btrace pt return-compression on|off
show record btrace pt return-compression
Enable or disable Intel Processor Trace return compression (default: on).
+set record btrace pt enhanced-resync on|off
+show record btrace pt enhanced-resync
+ Enable or disable enhanced decoder synchronization after a trace
+ decoding error (default: off).
+
* Changed commands
set stop-on-solib-events on|off
@@ -92,6 +97,13 @@ info locals
Qbtrace-conf:pt:return-compression
Configure Intel Processor Trace return-compression settings.
+* Changed remote packets
+
+qXfer:btrace:read
+ The pt-config part of a pt response may now contain a new attribute
+ allow_resync to indicate to GDB that enhanced decoder synchronization
+ after a trace decoding error is supported on this processor.
+
*** Changes in GDB 18
* Support for the Common Trace Format (CTF) has been removed. GDB now
diff --git a/gdb/btrace.c b/gdb/btrace.c
index 5c47f9129ae..b1c78075d0f 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -35,7 +35,7 @@
#include "extension.h"
#include "gdbarch.h"
-/* For maintenance commands. */
+/* For maintenance commands and record_btrace_conf. */
#include "record-btrace.h"
#include <inttypes.h>
@@ -1732,6 +1732,40 @@ ftrace_warn_pt (btrace_thread_info *btinfo, pt_insn_decoder *decoder,
pt_errstr (pt_errcode (status)));
}
+#if (LIBIPT_VERSION >= 0x202)
+/* Resynchronize at an IP-providing packet, if possible. Returns the
+ decoder status, which is non-negative on success and negative
+ otherwise. */
+
+static int
+ftrace_resync_pt (btrace_thread_info *btinfo, pt_insn_decoder *decoder,
+ std::vector<unsigned int> &gaps)
+{
+ int status;
+
+ for (;;)
+ {
+ status = pt_insn_resync (decoder);
+ if (status >= 0)
+ return status;
+
+ if (status != -pte_event_ignored)
+ break;
+
+ /* This libipt version will HAVE_PT_INSN_EVENT. */
+ status = handle_pt_insn_event (btinfo, decoder, gaps);
+ if (status < 0)
+ break;
+ }
+
+ if (status != -pte_eos)
+ warning (_("Resynchronization error (%d): %s"), status,
+ pt_errstr (pt_errcode (status)));
+
+ return status;
+}
+#endif /* (LIBIPT_VERSION >= 0x202) */
+
/* Decode the trace and handle events as long as there is no error.
Returns the last decoder status. */
@@ -1777,6 +1811,7 @@ ftrace_decode_pt (btrace_thread_info *btinfo,
static void
ftrace_add_pt (btrace_thread_info *btinfo,
+ const btrace_data_pt_config *config,
pt_insn_decoder *decoder,
int *plevel,
std::vector<unsigned int> &gaps)
@@ -1795,13 +1830,30 @@ ftrace_add_pt (btrace_thread_info *btinfo,
break;
}
- status = ftrace_decode_pt (btinfo, decoder, plevel, gaps, status);
- if (status == -pte_eos)
- break;
+ for (;;)
+ {
+ status = ftrace_decode_pt (btinfo, decoder, plevel, gaps, status);
+ gdb_assert (status < 0);
+ if (status == -pte_eos)
+ return;
+
+ /* Indicate the gap in the trace. */
+ btrace_function *bfun = ftrace_new_gap (btinfo, status, gaps);
+ ftrace_warn_pt (btinfo, decoder, bfun, status);
- /* Indicate the gap in the trace. */
- btrace_function *bfun = ftrace_new_gap (btinfo, status, gaps);
- ftrace_warn_pt (btinfo, decoder, bfun, status);
+#if (LIBIPT_VERSION >= 0x202)
+ if (record_btrace_conf.pt.enhanced_resync
+ && config->allow_resync)
+ status = ftrace_resync_pt (btinfo, decoder, gaps);
+#endif
+ if (status < 0)
+ {
+ if (status == -pte_eos)
+ return;
+
+ break;
+ }
+ }
}
}
@@ -1928,7 +1980,7 @@ btrace_compute_ftrace_pt (struct thread_info *tp,
error (_("Failed to configure the Intel Processor Trace decoder: "
"%s."), pt_errstr (pt_errcode (errcode)));
- ftrace_add_pt (btinfo, decoder, &level, gaps);
+ ftrace_add_pt (btinfo, &btrace->config, decoder, &level, gaps);
}
catch (const gdb_exception &error)
{
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 8cfaffd4fc7..9462dccc205 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -8433,6 +8433,31 @@ overhead and trace size. The default is on.
@item show record btrace pt return-compression
Show the current setting of Intel Processor Trace return compression.
+@item set record btrace pt enhanced-resync
+Enable or disable enhanced synchronization. When disabled and trace
+decode fails with an error, the decoder synchronizes at the next trace
+synchronization packet sequence (PSB+). This provides the initial
+decode state for the next trace section. This is a safe option but
+may skip a fair amount of trace.
+
+When enabled and trace decode fails with an error, the decoder
+synchronizes at the next packet that provides a full instruction
+address on processors that do not use deferred TIP packets. This
+usually skips a lot less trace, but it does not allow the decoder to
+maintain its decode state, which may lead to subsequent decode errors.
+
+Most notably, the call stack will not be maintained for direct calls,
+which may lead to decode errors when encountering a compressed return.
+Disabling return compression avoids that at the cost of increased
+trace size and recording overhead.
+
+The default is off. The setting may be changed at any time. When the
+setting is changed, threads stop replaying and trace is re-decoded
+with the new setting.
+
+@item show record btrace pt enhanced-resync
+Show the current setting of enhanced synchronization.
+
@kindex info record
@item info record
Show various statistics about the recording depending on the recording
@@ -49400,6 +49425,7 @@ The formal DTD for the branch trace format is given below:
<!ELEMENT pt (pt-config?, raw?)>
<!ELEMENT pt-config (cpu?)>
+<!ATTLIST pt-config allow_resync (yes | no) #IMPLIED>
<!ELEMENT cpu EMPTY>
<!ATTLIST cpu vendor CDATA #REQUIRED
diff --git a/gdb/features/btrace.dtd b/gdb/features/btrace.dtd
index a7d5db7faf6..9342bc0cbcc 100644
--- a/gdb/features/btrace.dtd
+++ b/gdb/features/btrace.dtd
@@ -14,6 +14,7 @@
<!ELEMENT pt (pt-config?, raw?)>
<!ELEMENT pt-config (cpu?)>
+<!ATTLIST pt-config allow_resync (yes | no) #IMPLIED>
<!ELEMENT cpu EMPTY>
<!ATTLIST cpu vendor CDATA #REQUIRED
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
index 8f0c4c1b442..38b617a82b4 100644
--- a/gdb/nat/linux-btrace.c
+++ b/gdb/nat/linux-btrace.c
@@ -947,6 +947,7 @@ static void
linux_fill_btrace_pt_config (struct btrace_data_pt_config *conf)
{
conf->cpu = btrace_this_cpu ();
+ conf->allow_resync = linux_supports_pt_feature ("topa_multiple_entries");
}
/* Read branch trace data in Intel Processor Trace format for the thread
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 30cd8c8b2b6..115a954e056 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -186,7 +186,7 @@ static struct async_event_handler *record_btrace_async_inferior_event_handler;
static int record_btrace_generating_corefile;
/* The current branch trace configuration. */
-static struct btrace_config record_btrace_conf;
+btrace_config record_btrace_conf;
/* Command list for "record btrace". */
static struct cmd_list_element *record_btrace_cmdlist;
@@ -3167,6 +3167,38 @@ set_record_pt_return_compression_value (const char *args, int from_tty,
record_btrace_conf.pt.return_compression = return_compression;
}
+static bool enhanced_resync = false;
+
+/* The "record pt enhanced-resync" show value function. */
+
+static void
+show_record_pt_enhanced_resync_value (ui_file *file, int from_tty,
+ cmd_list_element *c, const char *value)
+{
+ gdb_printf (file, _("record pt enhanced-resync is %s.\n"), value);
+}
+
+/* The "record pt enhanced-resync" set value function. */
+
+static void
+set_record_pt_enhanced_resync_value (const char *args, int from_tty,
+ cmd_list_element *c)
+{
+#if (LIBIPT_VERSION >= 0x202)
+ if (record_btrace_conf.pt.enhanced_resync != enhanced_resync)
+ {
+ record_btrace_conf.pt.enhanced_resync = enhanced_resync;
+
+ /* Clear the trace of all threads so we decode with the new
+ settings. This also stops replaying. */
+ for (thread_info &tp : all_non_exited_threads ())
+ btrace_clear (&tp);
+ }
+#else
+ error (_("Enhanced synchronization is not supported by GDB.\n"));
+#endif
+}
+
/* Initialize btrace commands. */
INIT_GDB_FILE (record_btrace)
@@ -3311,8 +3343,30 @@ has no effect on an active recording. The default is \"on\"."),
&set_record_btrace_pt_cmdlist,
&show_record_btrace_pt_cmdlist);
+ add_setshow_boolean_cmd
+ ("enhanced-resync", no_class, &enhanced_resync,
+ _("Set enhanced synchronizing after a decode error."),
+ _("Show enhanced synchronizing after a decode error."),
+ _("\
+Use \"on\" to enable enhanced synchronization and \"off\" to disable it.\n\n\
+After a trace decoding error, decode synchronizes at special packets (PSB+)\n\
+in the trace stream that supply the initial decode state. This may skip a\n\
+fair amount of trace.\n\
+With this option, the decoder tries to synchronize earlier at packets that\n\
+provide a full instruction address. This usually skips much less trace, but\n\
+may result in subsequent decode errors because the decoder is not able to\n\
+update its state while skipping packets. Disabling return compression may\n\
+help in this situation.\n\n\
+This setting is \"off\" by default and may be changed at any time. When the\n\
+setting changes, stop replaying and re-decode the trace for all threads."),
+ set_record_pt_enhanced_resync_value,
+ show_record_pt_enhanced_resync_value,
+ &set_record_btrace_pt_cmdlist,
+ &show_record_btrace_pt_cmdlist);
+
add_target (record_btrace_target_info, record_btrace_target_open);
+ memset (&record_btrace_conf, 0, sizeof (record_btrace_conf));
record_btrace_conf.bts.size = 64 * 1024;
record_btrace_conf.pt.size = 16 * 1024;
#if (LIBIPT_VERSION >= 0x200)
@@ -3322,4 +3376,5 @@ has no effect on an active recording. The default is \"on\"."),
#endif
record_btrace_conf.pt.event_tracing = false;
record_btrace_conf.pt.return_compression = return_compression;
+ record_btrace_conf.pt.enhanced_resync = enhanced_resync;
}
diff --git a/gdb/record-btrace.h b/gdb/record-btrace.h
index 99ea0741709..caa17aa7b2b 100644
--- a/gdb/record-btrace.h
+++ b/gdb/record-btrace.h
@@ -22,6 +22,8 @@
#ifndef GDB_RECORD_BTRACE_H
#define GDB_RECORD_BTRACE_H
+#include "gdbsupport/btrace-common.h"
+
/* Push the record_btrace target. */
extern void record_btrace_push_target (void);
@@ -29,4 +31,7 @@ extern void record_btrace_push_target (void);
NULL if the cpu was configured as auto. */
extern const struct btrace_cpu *record_btrace_get_cpu (void);
+/* The current branch trace configuration. */
+extern btrace_config record_btrace_conf;
+
#endif /* GDB_RECORD_BTRACE_H */
diff --git a/gdb/remote.c b/gdb/remote.c
index 3e564fdd91f..2cf735a1f2a 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -15228,6 +15228,22 @@ parse_xml_btrace_pt_config_cpu (struct gdb_xml_parser *parser,
btrace->variant.pt.config.cpu.stepping = *stepping;
}
+/* Parse a btrace pt-config xml record. */
+
+static void
+parse_xml_btrace_pt_config (gdb_xml_parser *parser,
+ const gdb_xml_element *element, void *user_data,
+ std::vector<gdb_xml_value> &attributes)
+{
+ btrace_data *btrace = (btrace_data *) user_data;
+ gdb_xml_value *allow_resync = xml_find_attribute (attributes,
+ "allow_resync");
+ btrace->variant.pt.config.allow_resync
+ = ((allow_resync != nullptr)
+ ? (bool) *(ULONGEST *) allow_resync->value.get ()
+ : false);
+}
+
/* Parse a btrace pt "raw" xml record. */
static void
@@ -15255,6 +15271,7 @@ parse_xml_btrace_pt (struct gdb_xml_parser *parser,
btrace = (struct btrace_data *) user_data;
btrace->format = BTRACE_FORMAT_PT;
btrace->variant.pt.config.cpu.vendor = CV_UNKNOWN;
+ btrace->variant.pt.config.allow_resync = false;
btrace->variant.pt.data = NULL;
btrace->variant.pt.size = 0;
}
@@ -15273,6 +15290,12 @@ static const struct gdb_xml_attribute btrace_pt_config_cpu_attributes[] = {
{ NULL, GDB_XML_AF_NONE, NULL, NULL }
};
+static const struct gdb_xml_attribute btrace_pt_config_attributes[] = {
+ { "allow_resync", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_enum,
+ gdb_xml_enums_boolean },
+ { NULL, GDB_XML_AF_NONE, NULL, NULL }
+};
+
static const struct gdb_xml_element btrace_pt_config_children[] = {
{ "cpu", btrace_pt_config_cpu_attributes, NULL, GDB_XML_EF_OPTIONAL,
parse_xml_btrace_pt_config_cpu, NULL },
@@ -15280,8 +15303,8 @@ static const struct gdb_xml_element btrace_pt_config_children[] = {
};
static const struct gdb_xml_element btrace_pt_children[] = {
- { "pt-config", NULL, btrace_pt_config_children, GDB_XML_EF_OPTIONAL, NULL,
- NULL },
+ { "pt-config", btrace_pt_config_attributes, btrace_pt_config_children,
+ GDB_XML_EF_OPTIONAL, parse_xml_btrace_pt_config, NULL },
{ "raw", NULL, NULL, GDB_XML_EF_OPTIONAL, NULL, parse_xml_btrace_pt_raw },
{ NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
};
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 7bcb85e641a..661447a8062 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6889,7 +6889,8 @@ static void
linux_low_encode_pt_config (std::string *buffer,
const struct btrace_data_pt_config *config)
{
- *buffer += "<pt-config>\n";
+ string_xml_appendf (*buffer, "<pt-config allow_resync=\"%s\">\n",
+ (config->allow_resync ? "yes" : "no"));
switch (config->cpu.vendor)
{
diff --git a/gdbsupport/btrace-common.h b/gdbsupport/btrace-common.h
index f2b274c79a7..10c58ef3c88 100644
--- a/gdbsupport/btrace-common.h
+++ b/gdbsupport/btrace-common.h
@@ -129,6 +129,9 @@ struct btrace_config_pt
/* Return compression setting. */
bool return_compression;
+
+ /* Configuration bit for enhanced synchronization after decode errors. */
+ bool enhanced_resync;
};
/* A branch tracing configuration.
@@ -164,6 +167,9 @@ struct btrace_data_pt_config
{
/* The processor on which the trace has been collected. */
struct btrace_cpu cpu;
+
+ /* Whether the processor supports resyncing on IP-providing packets. */
+ bool allow_resync;
};
/* Branch trace in Intel Processor Trace format. */
--
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.
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 5/5] gdb, gdbserver, btrace: resync on error
2026-10-30 13:57 ` [PATCH 5/5] gdb, gdbserver, btrace: resync on error Markus Metzger
@ 2026-10-30 14:31 ` Eli Zaretskii
0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2026-10-30 14:31 UTC (permalink / raw)
To: Markus Metzger; +Cc: gdb-patches
> From: Markus Metzger <markus.t.metzger@intel.com>
> Date: Fri, 30 Oct 2026 14:57:44 +0100
>
> Starting with libipt version 2.2, we can try to re-synchronize on the next
> IP-providing packet instead of skipping everything until the next trace
> stream synchronization packet on CPUs that do not support deferred TIPs.
>
> Add a new setting
>
> set record btrace pt enhanced-resync on|off
>
> to enable that on supported CPUs and extend the
>
> qXfer:btrace:read
>
> response with a new attribute
>
> allow_resync
>
> in the pt-config part of the response.
>
> This should normally not be needed and the setting defaults to off. When
> running into decode errors, however, it may help as an advanced option to
> make the most out of the recorded trace.
> ---
> gdb/NEWS | 12 +++++++
> gdb/btrace.c | 68 +++++++++++++++++++++++++++++++++-----
> gdb/doc/gdb.texinfo | 26 +++++++++++++++
> gdb/features/btrace.dtd | 1 +
> gdb/nat/linux-btrace.c | 1 +
> gdb/record-btrace.c | 57 +++++++++++++++++++++++++++++++-
> gdb/record-btrace.h | 5 +++
> gdb/remote.c | 27 +++++++++++++--
> gdbserver/linux-low.cc | 3 +-
> gdbsupport/btrace-common.h | 6 ++++
> 10 files changed, 194 insertions(+), 12 deletions(-)
The documentation parts are okay, thanks.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
^ permalink raw reply [flat|nested] 8+ messages in thread