PT_ISCACHE_ALLOC(3)
π PT_ISCACHE_ALLOC π
okay bestie, we're in section 3 of the intel-pt manual, and today's episode is the traced memory image section cache β allocation, naming, and freeing. it's giving malloc but make it β¨sectionsβ¨. let's go π¦
β¨ NAME β¨
pt_iscache_alloc, pt_iscache_free, pt_iscache_name β allocate / free a traced memory image section cache. that's the whole gig, no cap π
πΈ SYNOPSIS πΈ
#include <intel-pt.h>
struct pt_image_section_cache *pt_iscache_alloc(const char *name);
const char *pt_iscache_name(const struct pt_image_section_cache *iscache);
void pt_iscache_free(struct pt_image_section_cache *iscache);
and like, link with -lipt obviously. don't forget it or the linker will be SO dramatic about it π
π DESCRIPTION π
so pt_iscache_alloc() allocates a brand new pt_image_section_cache and hands you back a pointer to it. a pt_image_section_cache object is basically a little collection β it holds a bunch of file sections plus the virtual addresses where those sections got loaded. it's the group chat and the pinned locations, together π«Ά
here's the slay part: those image sections can be added to one or more pt_image objects. the underlying file sections get mapped once, and their content is shared across images. no duplicating, no wasting memory, we love an efficient queen π
now, the name argument points to an optional zero-terminated name string. quick rules:
- if
nameisNULLβ it's ignored, and the returnedpt_image_section_cacheobject just won't have a name. no name, no problem π - otherwise β the returned
pt_image_section_objectobject gets a copy of the string thatnamepoints to, as its name. a copy, bestie, not a reference. she keeps her own π
pt_iscache_name() returns the name of the pt_image_section_cache object that the iscache argument points to.
pt_iscache_free() frees the pt_image_section_cache object pointed to by iscache. but listen, there's a rule and it is NOT optional:
theiscacheargument must beNULL, or it must point to an image section cache that was allocated by a call topt_iscache_alloc(). anything else and you're in undefined-behaviour territory, which is not the vibe ππ
β RETURN VALUE β
pt_iscache_alloc()β returns a pointer to apt_image_section_cacheobject on success, orNULLif something went wrong.NULLis the "we don't talk about it" signal πpt_iscache_name()β returns a pointer to a zero-terminated string, orNULLif the image section cache doesn't have a name.
π EXAMPLE π
here's the whole flow, copy-paste ready, literally:
int foo(const char *name) {
struct pt_image_section_cache *iscache;
errcode;
image = pt_iscache_alloc(name);
if (!iscache)
return pte_nomem;
errcode = bar(iscache);
pt_iscache_free(iscache);
return errcode;
}
alloc, do the thing, free. the sacred trilogy πβ¨
π SEE ALSO π
and that's the page, bestie π this was PT_ISCACHE_ALLOC(3) from the intel-pt manual β section 3, in all her glory. go forth and cache responsibly, mwah πππ¦
π¦ 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