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 systemsys. and ifsysisNULL(aka you just didn't specify it, no big deal), you get the first event that has thatname. first come first served fr fr πΈtep_find_event_by_record()β this one finds an event based on a givenrecord. like, the record knows what it is, we're just asking it to spill π«Άtep_record_is_event()β this tests whether the givenrecordis of the type of theevent. 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 π
rostedt@goodmis.orgmailto:rostedt@goodmis.orgtz.stoyanov@gmail.commailto:tz.stoyanov@gmail.comlinux-trace-devel@vger.kernel.orgmailto: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
- 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