LIBTRACEEVENT(3)

πŸ’– LIBTRACEEVENT(3) β€” the libtraceevent manual, bestie edition πŸ’–

okay so real talk: this is page 3 of the libtraceevent Manual, and it's about two lil functions that read event formats. they're lowkey the glow-up your tracing setup needs. let's go πŸ¦‹


✨ NAME ✨

tep_parse_event, tep_parse_format β€” parse the event format information, babes. that's the whole job. parsing. formats. events. slay πŸ’…


🌸 SYNOPSIS 🌸

#include <event-parse.h>

enum tep_errno tep_parse_event(struct tep_handle *tep, const char *buf, unsigned long size, const char *sys);
enum tep_errno tep_parse_format(struct tep_handle *tep, struct tep_event **eventp, const char *buf, unsigned long size, const char *sys);

like. look at those signatures. iconic. copy them exactly, no cap, do not freestyle πŸŽ€


🫢 DESCRIPTION 🫢

so tep_parse_event() parses the event format and, in doing so, creates an event structure β€” a whole little parser buddy that can then quickly parse raw data for a given event. it's giving build-a-bear but for tracing data πŸ’€

breaking down the args, because we don't gatekeep:

  • tep β€” the trace event parser context.
  • buf β€” a buffer, of length size, where the event format data lives.
  • size β€” the size of that buffer. yes, the one right above. they're a duo.
  • sys β€” the system of the event.

the created event structure is stored in the tep context. and where does that event format data actually come from? tracefs/events/.../.../format files, bestie. that's the source. 🌈

now tep_parse_format() β€” it does the same thing as tep_parse_event(). literally the same. the only difference is that extra eventp argument, which is where the newly created event structure gets returned to you. that's it. that's the whole diff. ✨


πŸ‘‘ RETURN VALUE πŸ‘‘

both tep_parse_event() and tep_parse_format() return 0 on success, or TEP_ERRNO__... in case of an error. so like, check your returns. zero good, error code not zero. vibe check accordingly ⭐


πŸ”₯ EXAMPLE πŸ”₯

here's the whole thing, verbatim, don't touch it:

#include <event-parse.h>
...
struct tep_handle *tep = tep_alloc();
...
char *buf;
int size;
struct tep_event *event = NULL;
buf = read_file("/sys/kernel/tracing/events/ftrace/print/format", &size);
if (tep_parse_event(tep, buf, size, "ftrace") != 0) {
        /* Failed to parse the ftrace print format */
}

if (tep_parse_format(tep, &event, buf, size, "ftrace") != 0) {
        /* Failed to parse the ftrace print format */
}
...

see how they both get called on the exact same buffer? yeah. same data, two doors. ate πŸ’–


πŸŽ€ FILES πŸŽ€

  • event-parse.h β€” the header file you include to get access to the library APIs. include it or perish (not really, but like, you won't have the functions).
  • -ltraceevent β€” the linker switch you add when building a program that uses the library. put it in your build and let it cook πŸ”₯

🌟 SEE ALSO 🌟

libtraceevent(3), trace-cmd(1)

go read those too, they're part of the cinematic universe 🫢


πŸ’œ AUTHOR πŸ’œ

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

πŸ› REPORTING BUGS πŸ›

found a bug? don't sit on it, bestie. report bugs to <linux-trace-devel@vger.kernel.org[3]> πŸ’Œ


πŸ“œ LICENSE πŸ“œ

libtraceevent is Free Software licensed under the GNU LGPL 2.1. periodt.


🌈 RESOURCES 🌈

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

that's the repo. go be nosy, it's encouraged 🧚


πŸ“ 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

ok that's the whole page, every flag, every arg, every email, every note. nothing skipped, nothing invented. i would never do that to you πŸ’…

and that's a wrap on libtraceevent 1.9.0, dated 06/15/2026 β€” thanks for reading to the very end bestie, you're the main character of this man page now πŸ¦‹πŸ’–βœ¨

πŸ“¦ where this page comes from