LIBTRACEEVENT(3)
π LIBTRACEEVENT(3) π
okay bestie, so this is a page from the libtraceevent Manual and honestly? it's a good one. buckle up, we're talking event lists π
β¨ NAME β¨
tep_list_events, tep_list_events_copy β get a list of events, sorted by whatever criteria u picked π«
π¦ SYNOPSIS π¦
#include <event-parse.h>
enum tep_event_sort_type {
TEP_EVENT_SORT_ID,
TEP_EVENT_SORT_NAME,
TEP_EVENT_SORT_SYSTEM,
};
struct tep_event **tep_list_events(struct tep_handle *tep, enum tep_event_sort_type sort_type);
struct tep_event **tep_list_events_copy(struct tep_handle *tep, enum tep_event_sort_type sort_type);
πΈ DESCRIPTION πΈ
so tep_list_events() hands u back an array of pointers to the events, all sorted by the sort_type criteria u asked for. the last element of that array is NULL β that's ur little "the list ends here bestie" marker π
π¨ IMPORTANT: the memory u get back must not be freed. it's managed by the library, not by u. hands off. also, this function is not thread safe β do not come for it from multiple threads at once, she will simply not cope π
the tep argument is ur trace event parser context. and sort_type is the sort criteria u want, and there are literally three options:
TEP_EVENT_SORT_IDβ sorts by the event ID πTEP_EVENT_SORT_NAMEβ sorts by the event(name, system, id)triplet β¨TEP_EVENT_SORT_SYSTEMβ sorts by the event(system, name, id)triplet π
now, tep_list_events_copy() is the thread safe version of tep_list_events(). same behavior, same vibe, BUT the returned array is allocated internally and it's on u to free it β that's the deal. note that the content of the array still must not be freed (peep the EXAMPLE down below, it's giving instructions π).
π RETURN VALUE π
tep_list_events() returns an array of pointers to events. if something goes wrong? NULL. and again, for the people in the back: the returned array must not be freed, it is managed by the library. π«Ά
tep_list_events_copy() returns an array of pointers to events. on error, NULL. and this returned array must be freed by the caller. yes queen, u own this one π
π EXAMPLE π
#include <event-parse.h>
...
struct tep_handle *tep = tep_alloc();
...
int i;
struct tep_event_format **events;
i=0;
events = tep_list_events(tep, TEP_EVENT_SORT_ID);
if (events == NULL) {
/* Failed to get the events, sorted by ID */
} else {
while(events[i]) {
/* walk through the list of the events, sorted by ID */
i++;
}
}
i=0;
events = tep_list_events_copy(tep, TEP_EVENT_SORT_NAME);
if (events == NULL) {
/* Failed to get the events, sorted by name */
} else {
while(events[i]) {
/* walk through the list of the events, sorted by name */
i++;
}
free(events);
}
...
see how the copy one gets a lil free(events) at the end and the other one doesn't?? that's the whole tea β the way that detail matters fr fr.
π§ FILES π§
event-parse.hβ the header file u include so u can actually access the library APIs π-ltraceeventβ the linker switch u add when building a program that uses the library π
π SEE ALSO π
libtraceevent(3), trace-cmd(1)
π 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? report it to <linux-trace-devel@vger.kernel.org[3]> β they wanna hear about it, no cap π
β LICENSE β
libtraceevent is Free Software licensed under the GNU LGPL 2.1 π
π₯ RESOURCES π₯
https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
π 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 page bestie!! π«Ά this was libtraceevent 1.9.0, dated 06/15/2026, and it's genuinely iconic of u to read the whole thing. go sort some events, u absolute main character πβ¨π
π¦ 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