PT_QRY_SYNC_FORWARD(3)
β¨ NAME β¨
okay bestie, welcome to the pt_qry_sync_forward(3) page π β we're talking about pt_qry_sync_forward, pt_qry_sync_backward, and pt_qry_sync_set, the trio whose whole job is to synchronize an Intel(R) Processor Trace query decoder. no cap, that's literally the entire vibe: get the decoder in position and slay β¨
πΈ SYNOPSIS πΈ
#include <intel-pt.h>
int pt_qry_sync_forward(struct pt_query_decoder *decoder,
uint64_t *ip);
int pt_qry_sync_backward(struct pt_query_decoder *decoder,
uint64_t *ip);
int pt_qry_sync_set(struct pt_query_decoder *decoder,
uint64_t *ip, uint64_t offset);
Link with -lipt.
π DESCRIPTION π
so. these functions take an Intel Processor Trace (Intel PT) query decoder β the one pointed to by decoder β and synchronize it onto the trace stream living in decoder's trace buffer. it's giving "align the stars" energy, honestly π₯
they go hunt for a Packet Stream Boundary (PSB) packet in the trace stream and, if that works out, they set decoder's current position and synchronization position to that packet, then start processing packets. for synchronization to be successfull (fr fr), there has to be a full PSB+ header in the trace stream. no PSB+ header, no sync. periodt.
if the ip argument is not NULL, these functions hand you the code memory address at which tracing starts, dropped into the variable pointed to by ip. and if tracing is disabled at the synchronization point? the lack of an IP gets indicated in the return value by setting the pts_ip_suppressed bit. she's telling you the tea via the return value π
pt_qry_sync_forward()β searches in forward direction, fromdecoder's current position towards the end of the trace buffer. ifdecoderhas been newly allocated and hasn't been synchronized yet, the search starts from the beginning of the trace. π±pt_qry_sync_backward()β searches in backward direction, fromdecoder's current position towards the beginning of the trace buffer. ifdecoderhas been newly allocated and hasn't been synchronized yet, the search starts from the end of the trace. πpt_qry_sync_set()β searches atoffsetbytes from the beginning of its trace buffer. pinpoint precision, main character behavior π
π RETURN VALUE π
all the synchronization functions return zero or a positive value on success, or a negative pt_error_code enumeration constant if something went wrong. (crying in error code π)
on success, you get back a bit-vector of pt_status_flag enumeration constants. the pt_status_flag enumeration is declared like this:
/** Decoder status flags. */
enum pt_status_flag {
/** There is an event pending. */
pts_event_pending = 1 << 0,
/** The address has been suppressed. */
pts_ip_suppressed = 1 << 1,
/** There is no more trace data available. */
pts_eos = 1 << 2
};
look at her go. iconic enum β¨
π¦ ERRORS π¦
pte_invalidβ thedecoderargument isNULL. yeah. you passed nothing. πpte_eosβ there is no (further) PSB+ header in the trace stream (pt_qry_sync_forward()andpt_qry_sync_backward()) or atoffsetbytes into the trace buffer (pt_qry_sync_set()).pte_nosyncβ there is no PSB packet atoffsetbytes from the beginning of the trace. (pt_qry_sync_set()only, bestie, don't @ the other two).pte_bad_opcβ the decoder encountered an unsupported Intel PT packet opcode. π«pte_bad_packetβ the decoder encountered an unsupported Intel PT packet payload. π
none of these are a vibe. check your trace before you blame the decoder, okay? π«Ά
π EXAMPLE π
the following example re-synchronizes an Intel PT query decoder after decode errors β she's a phoenix rising from the ashes, lowkey:
int foo(struct pt_query_decoder *decoder) {
for (;;) {
int errcode;
errcode = pt_qry_sync_forward(decoder);
if (errcode < 0)
return errcode;
do {
errcode = decode(decoder);
} while (errcode >= 0);
}
}
π SEE ALSO π
pt_qry_alloc_decoder(3)pt_qry_free_decoder(3)pt_qry_get_offset(3)pt_qry_get_sync_offset(3)pt_qry_get_config(3)pt_qry_cond_branch(3)pt_qry_indirect_branch(3)pt_qry_event(3)pt_qry_time(3)pt_qry_core_bus_ratio(3)
the whole friend group, go say hi π§
and that's the page, bestie β the header at the very top and the footer at the very bottom both just say PT_QRY_SYNC_FORWARD(3), that's the manual page name and the only thing down there, no extra version or date sprinkled in. so that's a wrap, go synchronize something and slay ππβ
π¦ where this page comes from
- fedora 43: libipt-devel 2.1.2-3.fc43 Β· BSD-3-Clause
- fedora 43: libipt-devel 2.1.2-3.fc43 Β· BSD-3-Clause
- fedora 44: libipt-devel 2.1.2-4.fc44 Β· BSD-3-Clause
- fedora 44: libipt-devel 2.1.2-4.fc44 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms