6 tep_register_print_function,tep_unregister_print_function -
7 Registers / Unregisters a helper function.
13 *#include <event-parse.h>*
15 enum *tep_func_arg_type* {
21 TEP_FUNC_ARG_MAX_TYPES
24 typedef unsigned long long (*pass:[*]tep_func_handler*)(struct trace_seq pass:[*]s, unsigned long long pass:[*]args);
26 int *tep_register_print_function*(struct tep_handle pass:[*]_tep_, tep_func_handler _func_, enum tep_func_arg_type _ret_type_, char pass:[*]_name_, _..._);
27 int *tep_unregister_print_function*(struct tep_handle pass:[*]_tep_, tep_func_handler _func_, char pass:[*]_name_);
32 Some events may have helper functions in the print format arguments.
33 This allows a plugin to dynamically create a way to process one of
36 The _tep_register_print_function()_ registers such helper function. The _tep_
37 argument is the trace event parser context. The _func_ argument is a pointer
38 to the helper function. The _ret_type_ argument is the return type of the
39 helper function, value from the _tep_func_arg_type_ enum. The _name_ is the name
40 of the helper function, as seen in the print format arguments. The _..._ is a
41 variable list of _tep_func_arg_type_ enums, the _func_ function arguments.
42 This list must end with _TEP_FUNC_ARG_VOID_. See 'EXAMPLE' section.
44 The _tep_unregister_print_function()_ unregisters a helper function, previously
45 registered with _tep_register_print_function()_. The _tep_ argument is the
46 trace event parser context. The _func_ and _name_ arguments are the same, used
47 when the helper function was registered.
49 The _tep_func_handler_ is the type of the helper function. The _s_ argument is
50 the trace sequence, it can be used to create a custom string.
51 The _args_ is a list of arguments, defined when the helper function was
56 The _tep_register_print_function()_ function returns 0 in case of success.
57 In case of an error, TEP_ERRNO_... code is returned.
59 The _tep_unregister_print_function()_ returns 0 in case of success, or -1 in
64 Some events have internal functions calls, that appear in the print format
65 output. For example "tracefs/events/i915/g4x_wm/format" has:
68 print fmt: "pipe %c, frame=%u, scanline=%u, wm %d/%d/%d, sr %s/%d/%d/%d, hpll %s/%d/%d/%d, fbc %s",
69 ((REC->pipe) + 'A'), REC->frame, REC->scanline, REC->primary,
70 REC->sprite, REC->cursor, yesno(REC->cxsr), REC->sr_plane,
71 REC->sr_cursor, REC->sr_fbc, yesno(REC->hpll), REC->hpll_plane,
72 REC->hpll_cursor, REC->hpll_fbc, yesno(REC->fbc)
74 Notice the call to function _yesno()_ in the print arguments. In the kernel
75 context, this function has the following implementation:
78 static const char *yesno(int x)
80 static const char *yes = "yes";
81 static const char *no = "no";
86 The user space event parser has no idea how to handle this _yesno()_ function.
87 The _tep_register_print_function()_ API can be used to register a user space
88 helper function, mapped to the kernel's _yesno()_:
91 #include <event-parse.h>
92 #include <trace-seq.h>
94 struct tep_handle *tep = tep_alloc();
96 static const char *yes_no_helper(int x)
98 return x ? "yes" : "no";
101 if ( tep_register_print_function(tep,
106 TEP_FUNC_ARG_VOID) != 0) {
107 /* Failed to register yes_no_helper function */
111 Now, when the event parser encounters this yesno() function, it will know
115 if (tep_unregister_print_function(tep, yes_no_helper, "yesno") != 0) {
116 /* Failed to unregister yes_no_helper function */
125 Header file to include in order to have access to the library APIs.
127 Header file to include in order to have access to trace sequences
128 related APIs. Trace sequences are used to allow a function to call
129 several other functions to create a string of data to use.
131 Linker switch to add when building a program that uses the library.
136 _libtraceevent(3)_, _trace-cmd(1)_
142 *Steven Rostedt* <rostedt@goodmis.org>, author of *libtraceevent*.
143 *Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>, author of this man page.
147 Report bugs to <linux-trace-devel@vger.kernel.org>
151 libtraceevent is Free Software licensed under the GNU LGPL 2.1
155 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git