PT_PKT_GET_OFFSET(3)

πŸ“¦ version 2.1.2, in fedora 43, fedora 44

πŸ’– PT_PKT_GET_OFFSET πŸ’–

okay bestie, welcome to section 3 of the manual, where we talk about pt_pkt_get_offset and pt_pkt_get_sync_offset ✨ these two are the ones that tell you where you are inside an Intel(R) Processor Trace packet decoder's trace buffer β€” like a little "you are here" map pin πŸ“ except for bytes.


🌸 NAME 🌸

pt_pkt_get_offset, pt_pkt_get_sync_offset β€” get an Intel(R) Processor Trace packet decoder's current/synchronization trace buffer offset 🫢


✨ SYNOPSIS ✨

#include <intel-pt.h>
int pt_pkt_get_offset(const struct pt_packet_decoder *decoder,
                      uint64_t *offset);
int pt_pkt_get_sync_offset(const struct pt_packet_decoder *decoder,
                           uint64_t *offset);

and like, don't forget to link with -lipt or it's giving undefined reference 😭


πŸ¦‹ DESCRIPTION πŸ¦‹

pt_pkt_get_offset() hands you the decoder's current position, as an offset in bytes from the very beginning of the decoder's trace buffer, and it drops that number into the unsigned integer variable that offset points to. no cap, that's literally it πŸ’…

pt_pkt_get_sync_offset() does the same lil trick but for the decoder's last synchronization point β€” again as an offset in bytes from the beginning of the decoder's trace buffer, again written into the unsigned integer variable pointed to by offset. one is "where am i rn", the other is "where did i last lock on" πŸŽ€


🌈 RETURN VALUE 🌈

both of these girlies return zero on success πŸ₯³ or a negative pt_error_code enumeration constant if something went wrong πŸ’€


πŸ’œ ERRORS πŸ’œ

  • pte_invalid β€” the decoder or offset argument is NULL. yeah that's a no from me, you gotta actually pass real things πŸ™ˆ
  • pte_nosync β€” the decoder has not been synchronized onto the trace stream yet. you're gonna wanna use pt_pkt_sync_forward(3), pt_pkt_sync_backward(3), or pt_pkt_sync_set(3) to synchronize the decoder first, bestie πŸ”₯

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page!! mwah πŸ’‹ it lives in the PT_PKT_GET_OFFSET(3) section of the manual, so if you ever forget where you read this, that's the icon behavior to remember ⭐ go forth and get those offsets, you main character πŸ§šπŸ’–

πŸ“¦ where this page comes from