1libtracefs(3) 2============= 3 4NAME 5---- 6tracefs_local_events, tracefs_local_events_system, tracefs_fill_local_events, 7tracefs_load_cmdlines, tracefs_load_headers - 8Initialize a tep handler with trace events from the local system. 9 10SYNOPSIS 11-------- 12[verse] 13-- 14*#include <tracefs.h>* 15 16struct tep_handle pass:[*]*tracefs_local_events*(const char pass:[*]_tracing_dir_); 17struct tep_handle pass:[*]*tracefs_local_events_system*(const char pass:[*]_tracing_dir_, const char pass:[*] const pass:[*]_sys_names_); 18int *tracefs_fill_local_events*(const char pass:[*]_tracing_dir_, struct tep_handle pass:[*]_tep_, int pass:[*]_parsing_failures_); 19int *tracefs_load_cmdlines*(const char pass:[*]_tracing_dir_, struct tep_handle pass:[*]_tep_); 20int *tracefs_load_headers*(const char pass:[*]_tracing_dir_, struct tep_handle pass:[*]_tep_); 21-- 22 23DESCRIPTION 24----------- 25Functions for initializing a tep handler with trace events from the local system. 26 27The *tracefs_local_events()* function allocates a new _tep_ handler and 28initializes it with events from all trace systems, located in the given 29_tracing_dir_ directory. This could be NULL or the location of the tracefs 30mount point for the trace systems of the local machine, or it may be a path 31to a copy of the tracefs directory from another machine. 32 33The *tracefs_local_events_system()* function allocates a new _tep_ handler 34and initializes it with events from specified trace systems _sys_names_, 35located in the given _tracing_dir_ directory. This could be NULL or the 36location of the tracefs mount point for the trace systems of the local 37machine, or it may be a path to a copy of the tracefs directory from another 38machine. The _sys_names_ argument is an array of trace system names, that 39will be used for _tep_ handler initialization. The last element in that 40array must be a NULL pointer. 41 42The *tracefs_fill_local_events()* function initializes already allocated _tep_ 43handler with events from all trace systems, located in the given _tracing_dir_ 44directory. This could be NULL or the location of the tracefs mount point 45for the trace systems of the local machine, or it may be a path to a copy 46of the tracefs directory from another machine. The _tep_ argument must be 47a pointer to already allocated tep handler, that is going to be initialized. 48The _parsing_failures_ argument could be NULL or a pointer to an integer, 49where the number of failures while parsing the event files are returned. 50 51The above functions will also load the mappings between pids and the process 52command line names. In some cases the _tep_ handle is created with one 53of the above before tracing begins. As the mappings get updated during the 54trace, there may be a need to read the mappings again after the trace. 55The *tracefs_load_cmdlines()* does just that. The _tracing_dir_ is 56the directory of the mount point to load from, or NULL to use the 57mount point of the tracefs file system. 58 59The *tracefs_load_headers()* will reade the "header_page" of the events 60directory that will update the _tep_ handle with information on how to parse the 61tracing ring buffer sub-buffer. 62 63RETURN VALUE 64------------ 65The *tracefs_local_events()* and *tracefs_local_events_system()* functions 66return pointer to allocated and initialized _tep_ handler, or NULL in 67case of an error. The returned _tep_ handler must be freed with *tep_free*(3). 68 69The *tracefs_fill_local_events()* function returns -1 in case of an error or 700 otherwise. 71 72The *tracefs_load_cmdlines()* function returns -1 in case of an error, or 730 otherwise. 74 75EXAMPLE 76------- 77[source,c] 78-- 79#include <tracefs.h> 80 81struct tep_handle *tep; 82... 83 tep = tracefs_local_events(NULL); 84 if (!tep) { 85 /* Failed to initialise tep handler with local events from top instance */ 86 ... 87 } 88... 89 tep_free(tep); 90... 91 const char *systems[] = {"ftrace", "irq", NULL}; 92 tep = tracefs_local_events_system(NULL, systems); 93 if (!tep) { 94 /* Failed to initialise tep handler with local events from 95 * ftrace and irq systems in top instance. 96 */ 97 ... 98 } 99... 100 tep_free(tep); 101... 102 int parsing_failures; 103 tep = tep_alloc(); 104 if (!tep) { 105 /* Failed to allocate a tep handler */ 106 ... 107 } 108 if (tracefs_fill_local_events(NULL, tep, &parsing_failures) < 0) { 109 /* Failed to initialise tep handler with local events from top instance */ 110 } 111 tracefs_load_cmdlines(NULL, tep); 112... 113 tep_free(tep); 114-- 115FILES 116----- 117[verse] 118-- 119*tracefs.h* 120 Header file to include in order to have access to the library APIs. 121*-ltracefs* 122 Linker switch to add when building a program that uses the library. 123-- 124 125SEE ALSO 126-------- 127*libtracefs*(3), 128*libtraceevent*(3), 129*trace-cmd*(1) 130 131AUTHOR 132------ 133[verse] 134-- 135*Steven Rostedt* <rostedt@goodmis.org> 136*Tzvetomir Stoyanov* <tz.stoyanov@gmail.com> 137-- 138REPORTING BUGS 139-------------- 140Report bugs to <linux-trace-devel@vger.kernel.org> 141 142LICENSE 143------- 144libtracefs is Free Software licensed under the GNU LGPL 2.1 145 146RESOURCES 147--------- 148https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/ 149 150COPYING 151------- 152Copyright \(C) 2020 VMware, Inc. Free use of this software is granted under 153the terms of the GNU Public License (GPL). 154