LIBTRACEEVENT(3)

πŸ’– LIBTRACEEVENT πŸ’–

okay bestie, this is a libtraceevent manual page, and we're getting into the whole create/destroy/reference-counting situation for the trace event parser context. no cap, it's giving foundational.


✨ NAME ✨

tep_alloc, tep_free, tep_ref, tep_unref, tep_get_ref, tep_kbuffer β€” um, literally create, destroy, and manage the references of a trace event parser context. that's the whole vibe. πŸ¦‹


🌸 SYNOPSIS 🌸

#include <event-parse.h>

struct tep_handle *tep_alloc(void);
void tep_free(struct tep_handle *tep);
void tep_ref(struct tep_handle *tep);
void tep_unref(struct tep_handle *tep);
int tep_get_ref(struct tep_handle *tep);
struct kbuffer *tep_kbuffer(struct tep_handle *tep);

πŸ‘‘ DESCRIPTION πŸ‘‘

so these are the main character functions, fr. they create and destroy tep_handle β€” which is the big structural girl, the one representing the trace event parser context. that context gets passed in as the input parameter of most of the library's APIs, so like... everything kind of revolves around her. πŸ’…

  • tep_alloc() β€” allocates and initializes the tep context. new tep, who dis. ✨
  • tep_free() β€” decrements the reference of the tep handler. and when there are no more references left? it frees the handler, and cleans up all its resources that it had used. the tep argument is the pointer to the trace event parser context. rip boo, you served well. 😭
  • tep_ref() β€” adds a reference to the tep handler. one more bestie holding on. 🫢
  • tep_unref() β€” removes a reference from the tep handler. and when the last reference is removed, the tep is destroyed, and all the resources it had used get cleaned up. periodt. πŸ’€
  • tep_ref_get() β€” gets the current references of the tep handler. (yes it's spelled that way up here, don't come for me, the synopsis says tep_get_ref β€” iykyk πŸ™ˆ)
  • tep_kbuffer() β€” allocates a kbuffer descriptor that can be used to parse raw data that is represented by the tep handle descriptor. and listen, it must be freed with kbuf_free(3). no leaking, that's not the vibe.

🌈 RETURN VALUE 🌈

  • tep_alloc() returns a pointer to a newly created tep_handle structure. it returns NULL in case there is not enough free memory to allocate it. (lowkey tragic but okay ✨)
  • tep_ref_get() returns the current references of tep. if tep is NULL, 0 is returned.
  • tep_kbuffer() returns a kbuffer descriptor that can parse the raw data that represents the tep handle. must be freed with kbuf_free(3). πŸŽ€

🧚 EXAMPLE 🧚

okay here's the whole glow-up in action:

#include <event-parse.h>

...
struct tep_handle *tep = tep_alloc();
...
int ref = tep_get_ref(tep);
tep_ref(tep);
if ( (ref+1) != tep_get_ref(tep)) {
        /* Something wrong happened, the counter is not incremented by 1 */
}
tep_unref(tep);
...
tep_free(tep);
...

πŸ“ FILES πŸ“

  • event-parse.h β€” header file to include in order to have access to the library APIs. gotta have her. πŸ’œ
  • -ltraceevent β€” linker switch to add when building a program that uses the library.

πŸ”₯ SEE ALSO πŸ”₯

libtraceevent(3), trace-cmd(1)


⭐ AUTHOR ⭐

  • Steven Rostedt <rostedt@goodmis.org[1]>, author of libtraceevent. πŸ‘‘
  • Tzvetomir Stoyanov <tz.stoyanov@gmail.com[2]>, author of this man page. πŸ’–

πŸŽ€ REPORTING BUGS πŸŽ€

Report bugs to <linux-trace-devel@vger.kernel.org[3]>


🌸 LICENSE 🌸

libtraceevent is Free Software licensed under the GNU LGPL 2.1. slay, legally speaking. πŸ’…


πŸ¦‹ RESOURCES πŸ¦‹

https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/


πŸ“Ž NOTES πŸ“Ž

  1. rostedt@goodmis.org mailto:rostedt@goodmis.org
  2. tz.stoyanov@gmail.com mailto:tz.stoyanov@gmail.com
  3. linux-trace-devel@vger.kernel.org mailto:linux-trace-devel@vger.kernel.org

bestie, remember: every tep_ref() needs its tep_unref(), and every tep_alloc() needs its tep_free(). balance. harmony. main character energy. ✨

and that's the whole page, no cap πŸ’– β€” brought to you by libtraceevent 1.9.0, dated 06/15/2026, and yeah we're still calling it LIBTRACEEVENT(3) over here. mwah. 🫢🌸

πŸ“¦ where this page comes from