LIBTRACEEVENT(3)

✨ LIBTRACEEVENT(3) ✨

okay bestie, welcome to the libtraceevent manual πŸ’– this one's about a single lil function that reads the header page and sets up your trace event parser context. it's giving foundational. it's giving "you need this before anything else works." let's get into it 🫢


🌸 NAME 🌸

tep_parse_header_page β€” parses the data stored in the header page. that's it, that's the whole job. no cap πŸ’…


🌈 SYNOPSIS 🌈

#include <event-parse.h>

int tep_parse_header_page(struct tep_handle *tep, char *buf, unsigned long size, int long_size);

πŸ’œ DESCRIPTION πŸ’œ

so here's the tea β˜• β€” tep_parse_header_page() parses the header page data sitting in buf, and it initializes tep (your trace event parser context, the main character of this whole library) with it. the buffer buf comes with size, and it's supposed to be copied from tracefs/events/header_page. literally that's where it lives. go get it from there, don't improvise πŸ™ˆ

⚠️ heads up: some old kernels do not have header page info. like, it's just not there. in this case, you can call tep_parse_header_page() with size equal to 0. and then the tep context gets initialized with default values instead. it's fine, she copes πŸ’…

and in that use case, you can use long_size to set the size of a long integer to be used. so you're not left hanging β€” you still get to tell it how big your longs are. iconic behavior honestly ✨


πŸ”₯ RETURN VALUE πŸ”₯

  • 0 β€” success, we ate πŸŽ€
  • -1 β€” an error happened, not slay 😭

⭐ EXAMPLE ⭐

here's how it looks in the wild, bestie. copy it, run it, live your truth:

#include <event-parse.h>
...
struct tep_handle *tep = tep_alloc();
...
char *buf;
int size;
buf = read_file("/sys/kernel/tracing/events/header_page", &size);
if (tep_parse_header_page(tep, buf, size, sizeof(unsigned long)) != 0) {
        /* Failed to parse the header page */
}
...

see that sizeof(unsigned long)? that's your long_size in action. and that comment in the if is the sad path β€” if it's not 0, the parse failed. tragic but informative πŸ’€


πŸ¦‹ FILES πŸ¦‹

  • event-parse.h β€” the header file you need to include so you can actually access the library APIs. no include, no vibes. periodt.
  • -ltraceevent β€” the linker switch to add when building a program that uses the library. don't forget it or the linker will simply not know her πŸ‘‘

🌸 SEE ALSO 🌸

go read those next, iykyk πŸ’–


πŸ’… AUTHOR πŸ’…

  • Steven Rostedt <rostedt@goodmis.org[1]> β€” author of libtraceevent. the originator. the blueprint. πŸ‘‘
  • Tzvetomir Stoyanov <tz.stoyanov@gmail.com[2]> β€” author of this man page. thank you for your service 🫢

πŸŽ€ REPORTING BUGS πŸŽ€

found a bug? don't gatekeep it, report it to <linux-trace-devel@vger.kernel.org[3]> ✨


πŸ’œ LICENSE πŸ’œ

libtraceevent is Free Software licensed under the GNU LGPL 2.1. free as in freedom, bestie 🌈


🌟 RESOURCES 🌟

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

the source. the mothership. go look 🧚


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

and that's the whole page, bestie πŸ’– this was libtraceevent 1.9.0, dated 06/15/2026 β€” go parse that header page and slay βœ¨πŸ¦‹ no cap fr fr πŸ’…

πŸ“¦ where this page comes from