LIBTRACEEVENT(3)
π LIBTRACEEVENT(3) π
okay bestie, welcome to the libtraceevent Manual β specifically the LIBTRACEEVENT(3) page, and lemme tell you, this one is a whole vibe π¦
β¨ NAME β¨
tep_register_print_function, tep_unregister_print_function β Registers / Unregisters a helper function.
like... it literally signs a helper function up for the group chat, or removes it. that's the whole gig π
πΈ SYNOPSIS πΈ
#include <event-parse.h>
enum tep_func_arg_type {
TEP_FUNC_ARG_VOID,
TEP_FUNC_ARG_INT,
TEP_FUNC_ARG_LONG,
TEP_FUNC_ARG_STRING,
TEP_FUNC_ARG_PTR,
TEP_FUNC_ARG_MAX_TYPES
};
typedef unsigned long long (*tep_func_handler)(struct trace_seq *s, unsigned long long *args);
int tep_register_print_function(struct tep_handle *tep, tep_func_handler func, enum tep_func_arg_type ret_type, char *name, ...);
int tep_unregister_print_function(struct tep_handle *tep, tep_func_handler func, char *name);
no cap, that's the whole signature lineup right there π
π DESCRIPTION π
so here's the tea: some events have helper functions chillin' in their print format arguments. and this API is the way a plugin can dynamically create a way to process one of those functions. main character energy, honestly π₯
tep_register_print_function() registers such a helper function. breaking it down:
- the
tepargument is the trace event parser context. - the
funcargument is a pointer to the helper function. - the
ret_typeargument is the return type of the helper function β a value from thetep_func_arg_typeenum. - the
nameis the name of the helper function, as seen in the print format arguments. - the
...is a variable list oftep_func_arg_typeenums, aka thefuncfunction arguments. this list must end withTEP_FUNC_ARG_VOID. peep the EXAMPLE section for the whole picture β¨
tep_unregister_print_function() unregisters a helper function that was previously registered with tep_register_print_function(). the tep argument is the trace event parser context, and the func and name arguments are the same ones used when the helper function was registered. it's giving "we're removing you from the group chat" π
tep_func_handler is the type of the helper function. the s argument is the trace sequence β you can use it to create a custom string. the args is a list of arguments, defined back when the helper function was registered. iconic.
π«Ά RETURN VALUE π«Ά
tep_register_print_function()returns0in case of success. in case of an error, aTEP_ERRNO_...code is returned.tep_unregister_print_function()returns0in case of success, or-1in case of an error.
π§ EXAMPLE π§
some events have internal function calls that show up in the print format output. for example, "tracefs/events/i915/g4x_wm/format" has:
print fmt: "pipe %c, frame=%u, scanline=%u, wm %d/%d/%d, sr %s/%d/%d/%d, hpll %s/%d/%d/%d, fbc %s",
((REC->pipe) + 'A'), REC->frame, REC->scanline, REC->primary,
REC->sprite, REC->cursor, yesno(REC->cxsr), REC->sr_plane,
REC->sr_cursor, REC->sr_fbc, yesno(REC->hpll), REC->hpll_plane,
REC->hpll_cursor, REC->hpll_fbc, yesno(REC->fbc)
notice the call to the function yesno() in the print arguments? yeah. so in the kernel context, this function has the following implementation:
static const char *yesno(int x)
{
static const char *yes = "yes";
static const char *no = "no";
return x ? yes : no;
}
the user space event parser has no idea how to handle this yesno() function π. so the tep_register_print_function() API can be used to register a user space helper function, mapped to the kernel's yesno():
#include <event-parse.h>
#include <trace-seq.h>
...
struct tep_handle *tep = tep_alloc();
...
static const char *yes_no_helper(int x)
{
return x ? "yes" : "no";
}
...
if ( tep_register_print_function(tep,
yes_no_helper,
TEP_FUNC_ARG_STRING,
"yesno",
TEP_FUNC_ARG_INT,
TEP_FUNC_ARG_VOID) != 0) {
/* Failed to register yes_no_helper function */
}
/*
Now, when the event parser encounters this yesno() function, it will know
how to handle it.
*/
...
if (tep_unregister_print_function(tep, yes_no_helper, "yesno") != 0) {
/* Failed to unregister yes_no_helper function */
}
and just like that, the parser gets it. slay π
π FILES π
event-parse.hβ Header file to include in order to have access to the library APIs.trace-seq.hβ Header file to include in order to have access to trace sequences related APIs. Trace sequences are used to allow a function to call several other functions to create a string of data to use.-ltraceeventβ Linker switch to 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 π
Report bugs to <linux-trace-devel@vger.kernel.org> [3]
β 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
okay that's the whole page bestie, you ate it up πβ¨
this was libtraceevent 1.9.0, dated 06/15/2026 β mwah, periodt ππ¦
π¦ 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