PT_BLK_GET_OFFSET(3)

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

πŸ’– PT_BLK_GET_OFFSET(3) πŸ’–

okay bestie, we're in pt_blk_get_offset(3) territory and it's literally the cutest little pair of functions. no cap. they're about peeking at where an Intel(R) Processor Trace block decoder is currently vibing inside its trace buffer. two of them. twins. iconic.


✨ NAME ✨

pt_blk_get_offset, pt_blk_get_sync_offset β€” get an Intel(R) Processor Trace block decoder's current/synchronization trace buffer offset 🫢

like. that's the whole assignment. one tells you where you are, the other tells you where you last synced. both in bytes. both adorable.


🌸 SYNOPSIS 🌸

#include <intel-pt.h>
int pt_blk_get_offset(const struct pt_block_decoder *decoder,
                      uint64_t *offset);
int pt_blk_get_sync_offset(const struct pt_block_decoder *decoder,
                           uint64_t *offset);

and then, the part nobody reads but everybody needs:

Link with -lipt.

that's it. that's the link line. don't forget it or the linker will simply end you. πŸ’€


πŸ¦‹ DESCRIPTION πŸ¦‹

so, pt_blk_get_offset() hands you the decoder's current position, expressed as an offset in bytes from the beginning of the decoder's trace buffer, and it drops that number into the unsigned integer variable that offset is pointing at. your decoder's little "you are here" pin on the map. πŸ“

meanwhile pt_blk_get_sync_offset() gives you the decoder's last synchronization point β€” same deal, an offset in bytes from the beginning of the decoder's trace buffer β€” and it writes that into the unsigned integer variable pointed to by offset. that's the last spot where your decoder actually got its bearings. the anchor. the safe lil checkpoint. βš“

two functions. two offsets. both uint64_t. both giving main character energy.


πŸ’… RETURN VALUE πŸ’…

both of them return zero on success, or a negative pt_error_code enumeration constant if something went wrong. so like. check your return values. always. it's giving basic self-respect.


😭 ERRORS 😭

  • pte_invalid β€” the decoder or offset argument is NULL. yeah. you passed a nothing where a something should be. we've all been there but bestie please.
  • pte_nosync β€” decoder has not been synchronized onto the trace stream yet. it's lost. it's confused. it doesn't know where it is. use pt_blk_sync_forward(3), pt_blk_sync_backward(3), or pt_blk_sync_set(3) to synchronize decoder and get it back on its feet. 🧚
real talk: if you get pte_nosync and you just keep calling anyway, you're not getting a number, you're getting a whole attitude from the library. sync first. periodt.

πŸ‘‘ SEE ALSO πŸ‘‘

the whole friend group. go read them. slay. 🌈


and that's the page, bestie β€” PT_BLK_GET_OFFSET(3), signed off right there in the footer like the queen she is, source and date and all, no notes. mwah. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from