LIBTRACEEVENT(3)

πŸ’– LIBTRACEEVENT(3) πŸ’–

okay bestie, welcome to the libtraceevent manual β€” yes, the whole thing, section 3, library functions, we're doing this ✨


🌸 NAME 🌸

tep_find_event, tep_find_event_by_name, tep_find_event_by_record, tep_record_is_event β€” find events by a given key πŸ”


πŸŽ€ SYNOPSIS πŸŽ€

#include <event-parse.h>

struct tep_event *tep_find_event(struct tep_handle *tep, int id);
struct tep_event *tep_find_event_by_name(struct tep_handle *tep, const char *sys, const char *name);
struct tep_event *tep_find_event_by_record(struct tep_handle *tep, struct tep_record *record);
bool tep_record_is_event(struct tep_record *record, struct tep_event *event);

✨ DESCRIPTION ✨

so this whole little friend group of functions is for searching for an event based on whatever criteria you bring to the table. every single one of them needs a pointer to a tep, aka your trace event parser context. that's the vibe check they all have to pass πŸ’…

  • tep_find_event() β€” hunts down an event by its event id. heads up tho, that event ID is assigned dynamically, so it's not some fixed forever thing β€” you can peep it in the event's format file, in the "ID" field πŸ‘€
  • tep_find_event_by_name() β€” hunts down an event by its event name, inside the system sys. and if sys is NULL (aka you just didn't specify it, no big deal), you get the first event that has that name. first come first served fr fr 🌸
  • tep_find_event_by_record() β€” this one finds an event based on a given record. like, the record knows what it is, we're just asking it to spill 🫢
  • tep_record_is_event() β€” this tests whether the given record is of the type of the event. ngl this is normally the one you use to check "hey, is this record the event I actually care about," because if it is, then further processing should be done. it's giving "is this my moment or not" πŸ‘‘

⭐ RETURN VALUE ⭐

so with the exception of tep_record_is_event(), all of these functions hand you back a pointer to the event they found. and if there's no such event? you get NULL. no event, no pointer, that's the deal 😭


πŸ¦‹ EXAMPLE πŸ¦‹

here's the whole thing in action, bestie:

#include <event-parse.h>
...
struct tep_handle *tep = tep_alloc();
...
struct tep_event *event;

event = tep_find_event(tep, 1857);
if (event == NULL) {
        /* There is no event with ID 1857 */
}

event = tep_find_event_by_name(tep, "kvm", "kvm_exit");
if (event == NULL) {
        /* There is no kvm_exit event, from kvm system */
}

void event_from_record(struct tep_record *record)
{
 struct tep_event *event = tep_find_event_by_record(tep, record);
        if (event == NULL) {
                /* There is no event from given record */
        }
}
...

look at that. iconic. the comments are literally telling you what went wrong in each case πŸ’€


πŸ’œ FILES πŸ’œ

  • event-parse.h β€” the header file you include so you can actually get access to the library APIs. gotta include it, no skipping πŸŽ€
  • -ltraceevent β€” the linker switch you add when building a program that uses the library. don't forget it or your build will simply not ✨

🌈 SEE ALSO 🌈

libtraceevent(3), trace-cmd(1)

iykyk, go read those next 🫢


πŸ‘‘ AUTHOR πŸ‘‘

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

we stan them both, honestly πŸ’–


πŸ™ˆ REPORTING BUGS πŸ™ˆ

found a bug? report it to <linux-trace-devel@vger.kernel.org[3]> β€” don't be shy, they wanna know πŸ›


πŸ’… LICENSE πŸ’…

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


🧚 RESOURCES 🧚

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

go click, go explore, go be a main character 🌟


πŸ“ 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 entire page bestie πŸ₯Ή libtraceevent 1.9.0, dated 06/15/2026, living under the LIBTRACEEVENT(3) name forever and ever. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from