1*287e80b3SSadaf Ebrahimilibtracefs(3) 2*287e80b3SSadaf Ebrahimi============= 3*287e80b3SSadaf Ebrahimi 4*287e80b3SSadaf EbrahimiNAME 5*287e80b3SSadaf Ebrahimi---- 6*287e80b3SSadaf Ebrahimitracefs_local_events, tracefs_local_events_system, tracefs_fill_local_events, 7*287e80b3SSadaf Ebrahimitracefs_load_cmdlines - 8*287e80b3SSadaf EbrahimiInitialize a tep handler with trace events from the local system. 9*287e80b3SSadaf Ebrahimi 10*287e80b3SSadaf EbrahimiSYNOPSIS 11*287e80b3SSadaf Ebrahimi-------- 12*287e80b3SSadaf Ebrahimi[verse] 13*287e80b3SSadaf Ebrahimi-- 14*287e80b3SSadaf Ebrahimi*#include <tracefs.h>* 15*287e80b3SSadaf Ebrahimi 16*287e80b3SSadaf Ebrahimistruct tep_handle pass:[*]*tracefs_local_events*(const char pass:[*]_tracing_dir_); 17*287e80b3SSadaf Ebrahimistruct tep_handle pass:[*]*tracefs_local_events_system*(const char pass:[*]_tracing_dir_, const char pass:[*] const pass:[*]_sys_names_); 18*287e80b3SSadaf Ebrahimiint *tracefs_fill_local_events*(const char pass:[*]_tracing_dir_, struct tep_handle pass:[*]_tep_, int pass:[*]_parsing_failures_); 19*287e80b3SSadaf Ebrahimiint *tracefs_load_cmdlines*(const char pass:[*]_tracing_dir_, struct tep_handle pass:[*]_tep_); 20*287e80b3SSadaf Ebrahimi-- 21*287e80b3SSadaf Ebrahimi 22*287e80b3SSadaf EbrahimiDESCRIPTION 23*287e80b3SSadaf Ebrahimi----------- 24*287e80b3SSadaf EbrahimiFunctions for initializing a tep handler with trace events from the local system. 25*287e80b3SSadaf Ebrahimi 26*287e80b3SSadaf EbrahimiThe *tracefs_local_events()* function allocates a new _tep_ handler and 27*287e80b3SSadaf Ebrahimiinitializes it with events from all trace systems, located in the given 28*287e80b3SSadaf Ebrahimi_tracing_dir_ directory. This could be NULL or the location of the tracefs 29*287e80b3SSadaf Ebrahimimount point for the trace systems of the local machine, or it may be a path 30*287e80b3SSadaf Ebrahimito a copy of the tracefs directory from another machine. 31*287e80b3SSadaf Ebrahimi 32*287e80b3SSadaf EbrahimiThe *tracefs_local_events_system()* function allocates a new _tep_ handler 33*287e80b3SSadaf Ebrahimiand initializes it with events from specified trace systems _sys_names_, 34*287e80b3SSadaf Ebrahimilocated in the given _tracing_dir_ directory. This could be NULL or the 35*287e80b3SSadaf Ebrahimilocation of the tracefs mount point for the trace systems of the local 36*287e80b3SSadaf Ebrahimimachine, or it may be a path to a copy of the tracefs directory from another 37*287e80b3SSadaf Ebrahimimachine. The _sys_names_ argument is an array of trace system names, that 38*287e80b3SSadaf Ebrahimiwill be used for _tep_ handler initialization. The last element in that 39*287e80b3SSadaf Ebrahimiarray must be a NULL pointer. 40*287e80b3SSadaf Ebrahimi 41*287e80b3SSadaf EbrahimiThe *tracefs_fill_local_events()* function initializes already allocated _tep_ 42*287e80b3SSadaf Ebrahimihandler with events from all trace systems, located in the given _tracing_dir_ 43*287e80b3SSadaf Ebrahimidirectory. This could be NULL or the location of the tracefs mount point 44*287e80b3SSadaf Ebrahimifor the trace systems of the local machine, or it may be a path to a copy 45*287e80b3SSadaf Ebrahimiof the tracefs directory from another machine. The _tep_ argument must be 46*287e80b3SSadaf Ebrahimia pointer to already allocated tep handler, that is going to be initialized. 47*287e80b3SSadaf EbrahimiThe _parsing_failures_ argument could be NULL or a pointer to an integer, 48*287e80b3SSadaf Ebrahimiwhere the number of failures while parsing the event files are returned. 49*287e80b3SSadaf Ebrahimi 50*287e80b3SSadaf EbrahimiThe above functions will also load the mappings between pids and the process 51*287e80b3SSadaf Ebrahimicommand line names. In some cases the _tep_ handle is created with one 52*287e80b3SSadaf Ebrahimiof the above before tracing begins. As the mappings get updated during the 53*287e80b3SSadaf Ebrahimitrace, there may be a need to read the mappings again after the trace. 54*287e80b3SSadaf EbrahimiThe *tracefs_load_cmdlines()* does just that. The _tracing_dir_ is 55*287e80b3SSadaf Ebrahimithe directory of the mount point to load from, or NULL to use the 56*287e80b3SSadaf Ebrahimimount point of the tracefs file system. 57*287e80b3SSadaf Ebrahimi 58*287e80b3SSadaf EbrahimiRETURN VALUE 59*287e80b3SSadaf Ebrahimi------------ 60*287e80b3SSadaf EbrahimiThe *tracefs_local_events()* and *tracefs_local_events_system()* functions 61*287e80b3SSadaf Ebrahimireturn pointer to allocated and initialized _tep_ handler, or NULL in 62*287e80b3SSadaf Ebrahimicase of an error. The returned _tep_ handler must be freed with *tep_free*(3). 63*287e80b3SSadaf Ebrahimi 64*287e80b3SSadaf EbrahimiThe *tracefs_fill_local_events()* function returns -1 in case of an error or 65*287e80b3SSadaf Ebrahimi0 otherwise. 66*287e80b3SSadaf Ebrahimi 67*287e80b3SSadaf EbrahimiThe *tracefs_load_cmdlines()* function returns -1 in case of an error, or 68*287e80b3SSadaf Ebrahimi0 otherwise. 69*287e80b3SSadaf Ebrahimi 70*287e80b3SSadaf EbrahimiEXAMPLE 71*287e80b3SSadaf Ebrahimi------- 72*287e80b3SSadaf Ebrahimi[source,c] 73*287e80b3SSadaf Ebrahimi-- 74*287e80b3SSadaf Ebrahimi#include <tracefs.h> 75*287e80b3SSadaf Ebrahimi 76*287e80b3SSadaf Ebrahimistruct tep_handle *tep; 77*287e80b3SSadaf Ebrahimi... 78*287e80b3SSadaf Ebrahimi tep = tracefs_local_events(NULL); 79*287e80b3SSadaf Ebrahimi if (!tep) { 80*287e80b3SSadaf Ebrahimi /* Failed to initialise tep handler with local events from top instance */ 81*287e80b3SSadaf Ebrahimi ... 82*287e80b3SSadaf Ebrahimi } 83*287e80b3SSadaf Ebrahimi... 84*287e80b3SSadaf Ebrahimi tep_free(tep); 85*287e80b3SSadaf Ebrahimi... 86*287e80b3SSadaf Ebrahimi const char *systems[] = {"ftrace", "irq", NULL}; 87*287e80b3SSadaf Ebrahimi tep = tracefs_local_events_system(NULL, systems); 88*287e80b3SSadaf Ebrahimi if (!tep) { 89*287e80b3SSadaf Ebrahimi /* Failed to initialise tep handler with local events from 90*287e80b3SSadaf Ebrahimi * ftrace and irq systems in top instance. 91*287e80b3SSadaf Ebrahimi */ 92*287e80b3SSadaf Ebrahimi ... 93*287e80b3SSadaf Ebrahimi } 94*287e80b3SSadaf Ebrahimi... 95*287e80b3SSadaf Ebrahimi tep_free(tep); 96*287e80b3SSadaf Ebrahimi... 97*287e80b3SSadaf Ebrahimi int parsing_failures; 98*287e80b3SSadaf Ebrahimi tep = tep_alloc(); 99*287e80b3SSadaf Ebrahimi if (!tep) { 100*287e80b3SSadaf Ebrahimi /* Failed to allocate a tep handler */ 101*287e80b3SSadaf Ebrahimi ... 102*287e80b3SSadaf Ebrahimi } 103*287e80b3SSadaf Ebrahimi if (tracefs_fill_local_events(NULL, tep, &parsing_failures) < 0) { 104*287e80b3SSadaf Ebrahimi /* Failed to initialise tep handler with local events from top instance */ 105*287e80b3SSadaf Ebrahimi } 106*287e80b3SSadaf Ebrahimi tracefs_load_cmdlines(NULL, tep); 107*287e80b3SSadaf Ebrahimi... 108*287e80b3SSadaf Ebrahimi tep_free(tep); 109*287e80b3SSadaf Ebrahimi-- 110*287e80b3SSadaf EbrahimiFILES 111*287e80b3SSadaf Ebrahimi----- 112*287e80b3SSadaf Ebrahimi[verse] 113*287e80b3SSadaf Ebrahimi-- 114*287e80b3SSadaf Ebrahimi*tracefs.h* 115*287e80b3SSadaf Ebrahimi Header file to include in order to have access to the library APIs. 116*287e80b3SSadaf Ebrahimi*-ltracefs* 117*287e80b3SSadaf Ebrahimi Linker switch to add when building a program that uses the library. 118*287e80b3SSadaf Ebrahimi-- 119*287e80b3SSadaf Ebrahimi 120*287e80b3SSadaf EbrahimiSEE ALSO 121*287e80b3SSadaf Ebrahimi-------- 122*287e80b3SSadaf Ebrahimi*libtracefs*(3), 123*287e80b3SSadaf Ebrahimi*libtraceevent*(3), 124*287e80b3SSadaf Ebrahimi*trace-cmd*(1) 125*287e80b3SSadaf Ebrahimi 126*287e80b3SSadaf EbrahimiAUTHOR 127*287e80b3SSadaf Ebrahimi------ 128*287e80b3SSadaf Ebrahimi[verse] 129*287e80b3SSadaf Ebrahimi-- 130*287e80b3SSadaf Ebrahimi*Steven Rostedt* <[email protected]> 131*287e80b3SSadaf Ebrahimi*Tzvetomir Stoyanov* <[email protected]> 132*287e80b3SSadaf Ebrahimi-- 133*287e80b3SSadaf EbrahimiREPORTING BUGS 134*287e80b3SSadaf Ebrahimi-------------- 135*287e80b3SSadaf EbrahimiReport bugs to <[email protected]> 136*287e80b3SSadaf Ebrahimi 137*287e80b3SSadaf EbrahimiLICENSE 138*287e80b3SSadaf Ebrahimi------- 139*287e80b3SSadaf Ebrahimilibtracefs is Free Software licensed under the GNU LGPL 2.1 140*287e80b3SSadaf Ebrahimi 141*287e80b3SSadaf EbrahimiRESOURCES 142*287e80b3SSadaf Ebrahimi--------- 143*287e80b3SSadaf Ebrahimihttps://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/ 144*287e80b3SSadaf Ebrahimi 145*287e80b3SSadaf EbrahimiCOPYING 146*287e80b3SSadaf Ebrahimi------- 147*287e80b3SSadaf EbrahimiCopyright \(C) 2020 VMware, Inc. Free use of this software is granted under 148*287e80b3SSadaf Ebrahimithe terms of the GNU Public License (GPL). 149