PT_BLK_ALLOC_DECODER(3)
π pt_blk_alloc_decoder β allocate/free an Intel(R) Processor Trace block decoder π
okay bestie, welcome to PT_BLK_ALLOC_DECODER(3), the manual page that's literally just here to hand you a block decoder and then let you yeet it back when you're done. two functions, one header, zero drama. let's get into it π
β¨ SYNOPSIS β¨
#include <intel-pt.h>
struct pt_block_decoder *
pt_blk_alloc_decoder(const struct pt_config *config);
void pt_blk_free_decoder(struct pt_block_decoder *decoder);
Link with -lipt.
likeβ¦ that's it. that's the whole API. two lines and a linker flag, we love a minimal moment π
πΈ DESCRIPTION πΈ
So a block decoder takes raw Intel Processor Trace (Intel PT) and decodes it into a sequence of blocks of instructions, and those blocks are described by the pt_block structure. wanna know more about the block structure itself? go read pt_blk_next(3), it's the main character of that story π¦
π pt_blk_alloc_decoder()
pt_blk_alloc_decoder() allocates a brand-new block decoder and returns a pointer to it. slay.
The config argument points to a pt_config object β peep pt_config(3) for the deets. Now here's the β¨ important β¨ part, bestie, don't skip this:
The config argument will not be referenced by the returned decoder β but the trace buffer defined by the config argument'sbeginandendfields will be. so like, the config struct itself can dip, but that buffer? it's staying. keep it alive. π₯
Also, heads up: the returned block decoder needs to be synchronized onto the trace stream before you can actually use it. it's giving "new phone, who dis" until you sync it. to do that, use one of these:
π«Ά pt_blk_free_decoder()
pt_blk_free_decoder() frees the Intel PT block decoder pointed to by decoder.
β οΈ the decoder argument must beNULL, or it must point to a decoder that was allocated by a call topt_blk_alloc_decoder(). no random pointers, no impostors, okay? we do not free things we didn't allocate. periodt. π
β RETURN VALUE β
pt_blk_alloc_decoder() returns a pointer to a pt_block_decoder object on success, or NULL if something went wrong. that's the whole vibe check: pointer = good, NULL = error. π
π EXAMPLE π
here's the glow-up, a full little lifecycle in code:
struct pt_block_decoder *decoder;
int errcode;
decoder = pt_blk_alloc_decoder(config);
if (!decoder)
return pte_nomem;
errcode = decode(decoder);
pt_blk_free_decoder(decoder);
return errcode;
alloc β check β decode β free β return. the circle of life, but make it Intel PT π§
π SEE ALSO π
your reading list, bestie, all the cross-references:
pt_config(3)pt_blk_sync_forward(3)pt_blk_sync_backward(3)pt_blk_sync_set(3)pt_blk_get_offset(3)pt_blk_get_sync_offset(3)pt_blk_get_image(3)pt_blk_set_image(3)pt_blk_get_config(3)pt_blk_time(3)pt_blk_core_bus_ratio(3)pt_blk_next(3)
okay and for the lil sign-off moment: this page is filed under PT_BLK_ALLOC_DECODER(3) β that's the manual name at the top and the footer stamp at the very bottom, same string twice because the manpage gods love symmetry. no extra version or date tea on this one, just the section-3 tag itself. mwah, go alloc some decoders responsibly πβ¨π
π¦ 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