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 lengthsize, 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 π
rostedt@goodmis.orgmailto:rostedt@goodmis.orgtz.stoyanov@gmail.commailto:tz.stoyanov@gmail.comlinux-trace-devel@vger.kernel.orgmailto: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
- ubuntu stonking: libtraceevent-doc 1:1.9.0-2 Β· LGPL-2.1-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms