LIBTRACEEVENT(3)
π LIBTRACEEVENT(3) β the libtraceevent manual, bestie edition π
okay so you're here because you want the fields, and honestly? iconic behavior. this is the libtraceevent manual page, and today we're talking about tep_event_common_fields and tep_event_fields β the two besties that hand you a whole array of field pointers for an event. no cap.
β¨ NAME β¨
tep_event_common_fields, tep_event_fields β get a list of fields for an event. that's it. that's the whole vibe. π¦
πΈ SYNOPSIS πΈ
#include <event-parse.h>
struct tep_format_field **tep_event_common_fields(struct tep_event *event);
struct tep_format_field **tep_event_fields(struct tep_event *event);
like. look at those signatures. they're serving. π
π DESCRIPTION π
tep_event_common_fields()
this one returns an array of pointers to the common fields for the event. bestie, listen β the array is allocated inside the function, which means you have to free it with free(). it's yours now. it's your responsibility. the last element of the array is NULL, so you know where to stop walking. πΆββοΈ
tep_event_fields()
and this one? this one returns an array of pointers to the event specific fields for the event. same deal: the array is allocated in the function, and you must free it with free(). the last element is NULL. so consistent. so slay. β¨
fr fr, do not forget the free(). the memory is not gonna free itself and that's the tea. π
π₯ RETURN VALUE π₯
both tep_event_common_fields() and tep_event_fields() return an array of pointers to tep_format_field structures when everything goes right, or NULL when something goes wrong. it's giving success or it's giving NULL, there is no in between. π
π EXAMPLE π
here's the whole thing, verbatim, because copying code wrong is a crime:
#include <event-parse.h>
...
struct tep_handle *tep = tep_alloc();
...
int i;
struct tep_format_field **fields;
struct tep_event *event = tep_find_event_by_name(tep, "kvm", "kvm_exit");
if (event != NULL) {
fields = tep_event_common_fields(event);
if (fields != NULL) {
i = 0;
while (fields[i]) {
/*
walk through the list of the common fields
of the kvm_exit event
*/
i++;
}
free(fields);
}
fields = tep_event_fields(event);
if (fields != NULL) {
i = 0;
while (fields[i]) {
/*
walk through the list of the event specific
fields of the kvm_exit event
*/
i++;
}
free(fields);
}
}
...
see how we free(fields) both times? that's the main character move right there. π
π§ FILES π§
event-parse.hβ the header file you include to get access to the library APIs. gotta have it, no skips.-ltraceeventβ the linker switch you add when building a program that uses the library. don't forget it or the linker will simply choose violence.
π SEE ALSO π
go read those too, they're part of the lore. iykyk π«Ά
π AUTHOR π
- Steven Rostedt
<rostedt@goodmis.org[1]>, author of libtraceevent. - Tzvetomir Stoyanov
<tz.stoyanov@gmail.com[2]>, author of this man page.
absolute legends, respectfully. π
π REPORTING BUGS π
found a bug? report it to <linux-trace-devel@vger.kernel.org[3]>. don't be shy, that's literally what it's for. π
β 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/
π NOTES π
rostedt@goodmis.orgβmailto:rostedt@goodmis.orgtz.stoyanov@gmail.comβmailto:tz.stoyanov@gmail.comlinux-trace-devel@vger.kernel.orgβmailto:linux-trace-devel@vger.kernel.org
and that's the whole page, babe. this was libtraceevent version 1.9.0, dated 06/15/2026. you're welcome, go free() your arrays, hydrate, and slay. πβ¨π
π¦ 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