1*436bf2bcSAndroid Build Coastguard Workerlibtraceevent(3) 2*436bf2bcSAndroid Build Coastguard Worker================ 3*436bf2bcSAndroid Build Coastguard Worker 4*436bf2bcSAndroid Build Coastguard WorkerNAME 5*436bf2bcSAndroid Build Coastguard Worker---- 6*436bf2bcSAndroid Build Coastguard Workertep_register_print_function,tep_unregister_print_function - 7*436bf2bcSAndroid Build Coastguard WorkerRegisters / Unregisters a helper function. 8*436bf2bcSAndroid Build Coastguard Worker 9*436bf2bcSAndroid Build Coastguard WorkerSYNOPSIS 10*436bf2bcSAndroid Build Coastguard Worker-------- 11*436bf2bcSAndroid Build Coastguard Worker[verse] 12*436bf2bcSAndroid Build Coastguard Worker-- 13*436bf2bcSAndroid Build Coastguard Worker*#include <event-parse.h>* 14*436bf2bcSAndroid Build Coastguard Worker 15*436bf2bcSAndroid Build Coastguard Workerenum *tep_func_arg_type* { 16*436bf2bcSAndroid Build Coastguard Worker TEP_FUNC_ARG_VOID, 17*436bf2bcSAndroid Build Coastguard Worker TEP_FUNC_ARG_INT, 18*436bf2bcSAndroid Build Coastguard Worker TEP_FUNC_ARG_LONG, 19*436bf2bcSAndroid Build Coastguard Worker TEP_FUNC_ARG_STRING, 20*436bf2bcSAndroid Build Coastguard Worker TEP_FUNC_ARG_PTR, 21*436bf2bcSAndroid Build Coastguard Worker TEP_FUNC_ARG_MAX_TYPES 22*436bf2bcSAndroid Build Coastguard Worker}; 23*436bf2bcSAndroid Build Coastguard Worker 24*436bf2bcSAndroid Build Coastguard Workertypedef unsigned long long (*pass:[*]tep_func_handler*)(struct trace_seq pass:[*]s, unsigned long long pass:[*]args); 25*436bf2bcSAndroid Build Coastguard Worker 26*436bf2bcSAndroid Build Coastguard Workerint *tep_register_print_function*(struct tep_handle pass:[*]_tep_, tep_func_handler _func_, enum tep_func_arg_type _ret_type_, char pass:[*]_name_, _..._); 27*436bf2bcSAndroid Build Coastguard Workerint *tep_unregister_print_function*(struct tep_handle pass:[*]_tep_, tep_func_handler _func_, char pass:[*]_name_); 28*436bf2bcSAndroid Build Coastguard Worker-- 29*436bf2bcSAndroid Build Coastguard Worker 30*436bf2bcSAndroid Build Coastguard WorkerDESCRIPTION 31*436bf2bcSAndroid Build Coastguard Worker----------- 32*436bf2bcSAndroid Build Coastguard WorkerSome events may have helper functions in the print format arguments. 33*436bf2bcSAndroid Build Coastguard WorkerThis allows a plugin to dynamically create a way to process one of 34*436bf2bcSAndroid Build Coastguard Workerthese functions. 35*436bf2bcSAndroid Build Coastguard Worker 36*436bf2bcSAndroid Build Coastguard WorkerThe *tep_register_print_function()* registers such helper function. The _tep_ 37*436bf2bcSAndroid Build Coastguard Workerargument is the trace event parser context. The _func_ argument is a pointer 38*436bf2bcSAndroid Build Coastguard Workerto the helper function. The _ret_type_ argument is the return type of the 39*436bf2bcSAndroid Build Coastguard Workerhelper function, value from the _tep_func_arg_type_ enum. The _name_ is the name 40*436bf2bcSAndroid Build Coastguard Workerof the helper function, as seen in the print format arguments. The _..._ is a 41*436bf2bcSAndroid Build Coastguard Workervariable list of _tep_func_arg_type_ enums, the _func_ function arguments. 42*436bf2bcSAndroid Build Coastguard WorkerThis list must end with _TEP_FUNC_ARG_VOID_. See 'EXAMPLE' section. 43*436bf2bcSAndroid Build Coastguard Worker 44*436bf2bcSAndroid Build Coastguard WorkerThe *tep_unregister_print_function()* unregisters a helper function, previously 45*436bf2bcSAndroid Build Coastguard Workerregistered with *tep_register_print_function()*. The _tep_ argument is the 46*436bf2bcSAndroid Build Coastguard Workertrace event parser context. The _func_ and _name_ arguments are the same, used 47*436bf2bcSAndroid Build Coastguard Workerwhen the helper function was registered. 48*436bf2bcSAndroid Build Coastguard Worker 49*436bf2bcSAndroid Build Coastguard WorkerThe _tep_func_handler_ is the type of the helper function. The _s_ argument is 50*436bf2bcSAndroid Build Coastguard Workerthe trace sequence, it can be used to create a custom string. 51*436bf2bcSAndroid Build Coastguard WorkerThe _args_ is a list of arguments, defined when the helper function was 52*436bf2bcSAndroid Build Coastguard Workerregistered. 53*436bf2bcSAndroid Build Coastguard Worker 54*436bf2bcSAndroid Build Coastguard WorkerRETURN VALUE 55*436bf2bcSAndroid Build Coastguard Worker------------ 56*436bf2bcSAndroid Build Coastguard WorkerThe *tep_register_print_function()* function returns 0 in case of success. 57*436bf2bcSAndroid Build Coastguard WorkerIn case of an error, TEP_ERRNO_... code is returned. 58*436bf2bcSAndroid Build Coastguard Worker 59*436bf2bcSAndroid Build Coastguard WorkerThe *tep_unregister_print_function()* returns 0 in case of success, or -1 in 60*436bf2bcSAndroid Build Coastguard Workercase of an error. 61*436bf2bcSAndroid Build Coastguard Worker 62*436bf2bcSAndroid Build Coastguard WorkerEXAMPLE 63*436bf2bcSAndroid Build Coastguard Worker------- 64*436bf2bcSAndroid Build Coastguard WorkerSome events have internal functions calls, that appear in the print format 65*436bf2bcSAndroid Build Coastguard Workeroutput. For example "tracefs/events/i915/g4x_wm/format" has: 66*436bf2bcSAndroid Build Coastguard Worker[source,c] 67*436bf2bcSAndroid Build Coastguard Worker-- 68*436bf2bcSAndroid Build Coastguard Workerprint fmt: "pipe %c, frame=%u, scanline=%u, wm %d/%d/%d, sr %s/%d/%d/%d, hpll %s/%d/%d/%d, fbc %s", 69*436bf2bcSAndroid Build Coastguard Worker ((REC->pipe) + 'A'), REC->frame, REC->scanline, REC->primary, 70*436bf2bcSAndroid Build Coastguard Worker REC->sprite, REC->cursor, yesno(REC->cxsr), REC->sr_plane, 71*436bf2bcSAndroid Build Coastguard Worker REC->sr_cursor, REC->sr_fbc, yesno(REC->hpll), REC->hpll_plane, 72*436bf2bcSAndroid Build Coastguard Worker REC->hpll_cursor, REC->hpll_fbc, yesno(REC->fbc) 73*436bf2bcSAndroid Build Coastguard Worker-- 74*436bf2bcSAndroid Build Coastguard WorkerNotice the call to function *yesno()* in the print arguments. In the kernel 75*436bf2bcSAndroid Build Coastguard Workercontext, this function has the following implementation: 76*436bf2bcSAndroid Build Coastguard Worker[source,c] 77*436bf2bcSAndroid Build Coastguard Worker-- 78*436bf2bcSAndroid Build Coastguard Workerstatic const char *yesno(int x) 79*436bf2bcSAndroid Build Coastguard Worker{ 80*436bf2bcSAndroid Build Coastguard Worker static const char *yes = "yes"; 81*436bf2bcSAndroid Build Coastguard Worker static const char *no = "no"; 82*436bf2bcSAndroid Build Coastguard Worker 83*436bf2bcSAndroid Build Coastguard Worker return x ? yes : no; 84*436bf2bcSAndroid Build Coastguard Worker} 85*436bf2bcSAndroid Build Coastguard Worker-- 86*436bf2bcSAndroid Build Coastguard WorkerThe user space event parser has no idea how to handle this *yesno()* function. 87*436bf2bcSAndroid Build Coastguard WorkerThe *tep_register_print_function()* API can be used to register a user space 88*436bf2bcSAndroid Build Coastguard Workerhelper function, mapped to the kernel's *yesno()*: 89*436bf2bcSAndroid Build Coastguard Worker[source,c] 90*436bf2bcSAndroid Build Coastguard Worker-- 91*436bf2bcSAndroid Build Coastguard Worker#include <event-parse.h> 92*436bf2bcSAndroid Build Coastguard Worker#include <trace-seq.h> 93*436bf2bcSAndroid Build Coastguard Worker... 94*436bf2bcSAndroid Build Coastguard Workerstruct tep_handle *tep = tep_alloc(); 95*436bf2bcSAndroid Build Coastguard Worker... 96*436bf2bcSAndroid Build Coastguard Workerstatic const char *yes_no_helper(int x) 97*436bf2bcSAndroid Build Coastguard Worker{ 98*436bf2bcSAndroid Build Coastguard Worker return x ? "yes" : "no"; 99*436bf2bcSAndroid Build Coastguard Worker} 100*436bf2bcSAndroid Build Coastguard Worker... 101*436bf2bcSAndroid Build Coastguard Worker if ( tep_register_print_function(tep, 102*436bf2bcSAndroid Build Coastguard Worker yes_no_helper, 103*436bf2bcSAndroid Build Coastguard Worker TEP_FUNC_ARG_STRING, 104*436bf2bcSAndroid Build Coastguard Worker "yesno", 105*436bf2bcSAndroid Build Coastguard Worker TEP_FUNC_ARG_INT, 106*436bf2bcSAndroid Build Coastguard Worker TEP_FUNC_ARG_VOID) != 0) { 107*436bf2bcSAndroid Build Coastguard Worker /* Failed to register yes_no_helper function */ 108*436bf2bcSAndroid Build Coastguard Worker } 109*436bf2bcSAndroid Build Coastguard Worker 110*436bf2bcSAndroid Build Coastguard Worker/* 111*436bf2bcSAndroid Build Coastguard Worker Now, when the event parser encounters this yesno() function, it will know 112*436bf2bcSAndroid Build Coastguard Worker how to handle it. 113*436bf2bcSAndroid Build Coastguard Worker*/ 114*436bf2bcSAndroid Build Coastguard Worker... 115*436bf2bcSAndroid Build Coastguard Worker if (tep_unregister_print_function(tep, yes_no_helper, "yesno") != 0) { 116*436bf2bcSAndroid Build Coastguard Worker /* Failed to unregister yes_no_helper function */ 117*436bf2bcSAndroid Build Coastguard Worker } 118*436bf2bcSAndroid Build Coastguard Worker-- 119*436bf2bcSAndroid Build Coastguard Worker 120*436bf2bcSAndroid Build Coastguard WorkerFILES 121*436bf2bcSAndroid Build Coastguard Worker----- 122*436bf2bcSAndroid Build Coastguard Worker[verse] 123*436bf2bcSAndroid Build Coastguard Worker-- 124*436bf2bcSAndroid Build Coastguard Worker*event-parse.h* 125*436bf2bcSAndroid Build Coastguard Worker Header file to include in order to have access to the library APIs. 126*436bf2bcSAndroid Build Coastguard Worker*trace-seq.h* 127*436bf2bcSAndroid Build Coastguard Worker Header file to include in order to have access to trace sequences 128*436bf2bcSAndroid Build Coastguard Worker related APIs. Trace sequences are used to allow a function to call 129*436bf2bcSAndroid Build Coastguard Worker several other functions to create a string of data to use. 130*436bf2bcSAndroid Build Coastguard Worker*-ltraceevent* 131*436bf2bcSAndroid Build Coastguard Worker Linker switch to add when building a program that uses the library. 132*436bf2bcSAndroid Build Coastguard Worker-- 133*436bf2bcSAndroid Build Coastguard Worker 134*436bf2bcSAndroid Build Coastguard WorkerSEE ALSO 135*436bf2bcSAndroid Build Coastguard Worker-------- 136*436bf2bcSAndroid Build Coastguard Worker*libtraceevent*(3), *trace-cmd*(1) 137*436bf2bcSAndroid Build Coastguard Worker 138*436bf2bcSAndroid Build Coastguard WorkerAUTHOR 139*436bf2bcSAndroid Build Coastguard Worker------ 140*436bf2bcSAndroid Build Coastguard Worker[verse] 141*436bf2bcSAndroid Build Coastguard Worker-- 142*436bf2bcSAndroid Build Coastguard Worker*Steven Rostedt* <[email protected]>, author of *libtraceevent*. 143*436bf2bcSAndroid Build Coastguard Worker*Tzvetomir Stoyanov* <[email protected]>, author of this man page. 144*436bf2bcSAndroid Build Coastguard Worker-- 145*436bf2bcSAndroid Build Coastguard WorkerREPORTING BUGS 146*436bf2bcSAndroid Build Coastguard Worker-------------- 147*436bf2bcSAndroid Build Coastguard WorkerReport bugs to <[email protected]> 148*436bf2bcSAndroid Build Coastguard Worker 149*436bf2bcSAndroid Build Coastguard WorkerLICENSE 150*436bf2bcSAndroid Build Coastguard Worker------- 151*436bf2bcSAndroid Build Coastguard Workerlibtraceevent is Free Software licensed under the GNU LGPL 2.1 152*436bf2bcSAndroid Build Coastguard Worker 153*436bf2bcSAndroid Build Coastguard WorkerRESOURCES 154*436bf2bcSAndroid Build Coastguard Worker--------- 155*436bf2bcSAndroid Build Coastguard Workerhttps://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/ 156