PT_IMAGE_ALLOC(3)
π PT_IMAGE_ALLOC(3) β the intel-pt image allocation girlies π
okay bestie, so this is a section 3 manual page (that's library functions, iykyk β¨) for three lil functions that live together in the intel-pt house: pt_image_alloc, pt_image_free, and pt_image_name. they handle the whole allocate / free a traced memory image descriptor situation. let's get into it π«Ά
πΈ NAME πΈ
pt_image_alloc</p>, pt_image_free</p>, pt_image_name</p> β allocate/free a traced memory image descriptor β¨
π SYNOPSIS π
like, literally just:
#include <intel-pt.h>
struct pt_image *pt_image_alloc(const char *name);
const char *pt_image_name(const struct pt_image *image);
void pt_image_free(struct pt_image *image);
and don't forget: Link with -lipt. π
π DESCRIPTION π
pt_image_alloc()
pt_image_alloc()</p> allocates a brand new pt_image and hands you back a pointer to it. main character energy fr fr π
and what is a pt_image object, you ask? it's the memory image that was traced, defined as a collection of file sections plus the virtual addresses at which those sections were loaded. iconic. π
okay so the name argument points to an optional zero-terminated name string. two paths here, bestie:
- if name is
NULLβ it gets ignored, no drama, and the returnedpt_imageobject simply will not have a name. - otherwise β the returned
pt_imageobject gets a copy of the string that name points to, as its name. a whole copy, not just a pointer. slay. π
pt_image_name()
pt_image_name()</p> returns the name of the pt_image object that the image argument points to. that's it, that's the function. β¨
pt_image_free()
pt_image_free()</p> frees the pt_image object pointed to by image.
β οΈ bestie listen β the image argument must beNULLor point to an image that has been allocated by a call topt_image_alloc(). those are the only two options. no improvising. π
β RETURN VALUE β
pt_image_alloc()returns a pointer to apt_imageobject on success, orNULLin case of an error. that's the vibe check πpt_image_name()returns a pointer to a zero-terminated string ofNULLif the image does not have a name.
π¦ EXAMPLE π¦
here's the whole thing in action, look at her go:
int foo(const char *name) {
struct pt_image *image;
errcode;
image = pt_image_alloc(name);
if (!image)
return pte_nomem;
errcode = bar(image);
pt_image_free(image);
return errcode;
}
π SEE ALSO π
go read these next, bestie, they're all part of the same friend group:
pt_image_add_file(3)pt_image_add_cached(3)pt_image_copy(3)pt_image_remove_by_filename(3)pt_image_remove_by_asid(3)pt_image_set_callback(3)pt_insn_set_image(3)pt_insn_get_image(3)
and that's the page!! π this one literally signs off as PT_IMAGE_ALLOC(3) β that's the footer, that's the whole footer, she said what she said π no cap, go allocate something. 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