1*287e80b3SSadaf Ebrahimilibtracefs(3) 2*287e80b3SSadaf Ebrahimi============= 3*287e80b3SSadaf Ebrahimi 4*287e80b3SSadaf EbrahimiNAME 5*287e80b3SSadaf Ebrahimi---- 6*287e80b3SSadaf Ebrahimitracefs_options_get_supported, tracefs_option_is_supported, tracefs_options_get_enabled, 7*287e80b3SSadaf Ebrahimitracefs_option_is_enabled, tracefs_option_mask_is_set, tracefs_option_id 8*287e80b3SSadaf Ebrahimi- Get and check ftrace options. 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 Ebrahimiconst struct tracefs_options_mask pass:[*]*tracefs_options_get_supported*(struct tracefs_instance pass:[*]_instance_); 17*287e80b3SSadaf Ebrahimibool *tracefs_option_is_supported*(struct tracefs_instance pass:[*]_instance_, enum tracefs_option_id _id_); 18*287e80b3SSadaf Ebrahimiconst struct tracefs_options_mask pass:[*]*tracefs_options_get_enabled*(struct tracefs_instance pass:[*]_instance_); 19*287e80b3SSadaf Ebrahimibool *tracefs_option_is_enabled*(struct tracefs_instance pass:[*]_instance_, enum tracefs_option_id _id_); 20*287e80b3SSadaf Ebrahimibool *tracefs_option_mask_is_set*(const struct tracefs_options_mask *options, enum tracefs_option_id id); 21*287e80b3SSadaf Ebrahimienum tracefs_option_id *tracefs_option_id*(const char pass:[*]_name_); 22*287e80b3SSadaf Ebrahimi-- 23*287e80b3SSadaf Ebrahimi 24*287e80b3SSadaf EbrahimiDESCRIPTION 25*287e80b3SSadaf Ebrahimi----------- 26*287e80b3SSadaf EbrahimiThis set of APIs can be used to get and check current ftrace options. Supported ftrace options may 27*287e80b3SSadaf Ebrahimidepend on the kernel version and the kernel configuration. 28*287e80b3SSadaf Ebrahimi 29*287e80b3SSadaf EbrahimiThe *tracefs_options_get_supported()* function gets all ftrace options supported by the system in 30*287e80b3SSadaf Ebrahimithe given _instance_. If _instance_ is NULL, supported options of the top trace instance are 31*287e80b3SSadaf Ebrahimireturned. The set of supported options is the same in all created trace instances, but may be different 32*287e80b3SSadaf Ebrahimithan the top trace instance. 33*287e80b3SSadaf Ebrahimi 34*287e80b3SSadaf EbrahimiThe *tracefs_option_is_supported()/ function checks if the option with given _id_ is supported by 35*287e80b3SSadaf Ebrahimithe system in the given _instance_. If _instance_ is NULL, the top trace instance is used. If an 36*287e80b3SSadaf Ebrahimioption is supported at the top trace instance, it it may not be supported in a created trace instance. 37*287e80b3SSadaf Ebrahimi 38*287e80b3SSadaf EbrahimiThe *tracefs_options_get_enabled()* function gets all ftrace options, currently enabled in 39*287e80b3SSadaf Ebrahimithe given _instance_. If _instance_ is NULL, enabled options of the top trace instance are returned. 40*287e80b3SSadaf Ebrahimi 41*287e80b3SSadaf EbrahimiThe *tracefs_option_is_enabled()* function checks if the option with given _id_ is enabled in the 42*287e80b3SSadaf Ebrahimigiven _instance_. If _instance_ is NULL, the top trace instance is used. 43*287e80b3SSadaf Ebrahimi 44*287e80b3SSadaf EbrahimiThe *tracefs_option_mask_is_set()* function checks if the bit, corresponding to the option with _id_ is 45*287e80b3SSadaf Ebrahimiset in the _options_ bitmask returned from *tracefs_option_get_enabled()* and *tracefs_option_is_supported()*. 46*287e80b3SSadaf Ebrahimi 47*287e80b3SSadaf EbrahimiThe *tracefs_option_id()* converts an option _name_ into its corresponding id, if it is found. 48*287e80b3SSadaf EbrahimiThis allows to find the option _id_ to use in the other functions if only the _name_ is known. 49*287e80b3SSadaf Ebrahimi 50*287e80b3SSadaf EbrahimiRETURN VALUE 51*287e80b3SSadaf Ebrahimi------------ 52*287e80b3SSadaf EbrahimiThe *tracefs_options_get_supported()* and *tracefs_options_get_enabled()* functions, on success, 53*287e80b3SSadaf Ebrahimireturn a pointer to the bitmask within the instance, or a global bitmask for the top level, 54*287e80b3SSadaf Ebrahimior NULL in case of an error. As the returned bitmask is part of the instance structure (or a 55*287e80b3SSadaf Ebrahimiglobal variable) and must not be freed or modified. 56*287e80b3SSadaf Ebrahimi 57*287e80b3SSadaf EbrahimiThe *tracefs_option_is_supported()* and *tracefs_option_is_enabled()* functions return true if the 58*287e80b3SSadaf Ebrahimioption in supported / enabled, or false otherwise. 59*287e80b3SSadaf Ebrahimi 60*287e80b3SSadaf EbrahimiThe *tracefs_option_mask_is_set()* returns true if the corresponding option is set in the mask 61*287e80b3SSadaf Ebrahimior false otherwise. 62*287e80b3SSadaf Ebrahimi 63*287e80b3SSadaf EbrahimiThe *tracefs_option_id()* returns the corresponding id defined by *tracefs_options*(3) from 64*287e80b3SSadaf Ebrahimithe given _name_. If the _name_ can not be found, then TRACEFS_OPTION_INVALID is returned. 65*287e80b3SSadaf Ebrahimi 66*287e80b3SSadaf EbrahimiEXAMPLE 67*287e80b3SSadaf Ebrahimi------- 68*287e80b3SSadaf Ebrahimi[source,c] 69*287e80b3SSadaf Ebrahimi-- 70*287e80b3SSadaf Ebrahimi#include <tracefs.h> 71*287e80b3SSadaf Ebrahimi... 72*287e80b3SSadaf Ebrahimiconst struct tracefs_options_mask *options; 73*287e80b3SSadaf Ebrahimi... 74*287e80b3SSadaf Ebrahimioptions = tracefs_options_get_supported(NULL); 75*287e80b3SSadaf Ebrahimiif (!options) { 76*287e80b3SSadaf Ebrahimi /* Failed to get supported options */ 77*287e80b3SSadaf Ebrahimi} else { 78*287e80b3SSadaf Ebrahimi ... 79*287e80b3SSadaf Ebrahimi} 80*287e80b3SSadaf Ebrahimi... 81*287e80b3SSadaf Ebrahimioptions = tracefs_options_get_enabled(NULL); 82*287e80b3SSadaf Ebrahimiif (!options) { 83*287e80b3SSadaf Ebrahimi /* Failed to get options, enabled in the top instance */ 84*287e80b3SSadaf Ebrahimi} else { 85*287e80b3SSadaf Ebrahimi ... 86*287e80b3SSadaf Ebrahimi} 87*287e80b3SSadaf Ebrahimiif (tracefs_options_mask_is_set(options, TRACEFS_OPTION_LATENCY_FORMAT)) { 88*287e80b3SSadaf Ebrahimi ... 89*287e80b3SSadaf Ebrahimi} 90*287e80b3SSadaf Ebrahimi... 91*287e80b3SSadaf Ebrahimi 92*287e80b3SSadaf Ebrahimiif (tracefs_option_is_supported(NULL, TRACEFS_OPTION_LATENCY_FORMAT)) { 93*287e80b3SSadaf Ebrahimi /* Latency format option is supprted */ 94*287e80b3SSadaf Ebrahimi} 95*287e80b3SSadaf Ebrahimi 96*287e80b3SSadaf Ebrahimi... 97*287e80b3SSadaf Ebrahimi 98*287e80b3SSadaf Ebrahimiif (tracefs_option_is_enabled(NULL, TRACEFS_OPTION_STACKTRACE)) { 99*287e80b3SSadaf Ebrahimi /* Stacktrace option is enabled in the top instance */ 100*287e80b3SSadaf Ebrahimi} 101*287e80b3SSadaf Ebrahimi 102*287e80b3SSadaf Ebrahimi-- 103*287e80b3SSadaf EbrahimiFILES 104*287e80b3SSadaf Ebrahimi----- 105*287e80b3SSadaf Ebrahimi[verse] 106*287e80b3SSadaf Ebrahimi-- 107*287e80b3SSadaf Ebrahimi*tracefs.h* 108*287e80b3SSadaf Ebrahimi Header file to include in order to have access to the library APIs. 109*287e80b3SSadaf Ebrahimi*-ltracefs* 110*287e80b3SSadaf Ebrahimi Linker switch to add when building a program that uses the library. 111*287e80b3SSadaf Ebrahimi-- 112*287e80b3SSadaf Ebrahimi 113*287e80b3SSadaf EbrahimiSEE ALSO 114*287e80b3SSadaf Ebrahimi-------- 115*287e80b3SSadaf Ebrahimi*libtracefs*(3), 116*287e80b3SSadaf Ebrahimi*libtraceevent*(3), 117*287e80b3SSadaf Ebrahimi*trace-cmd*(1) 118*287e80b3SSadaf Ebrahimi 119*287e80b3SSadaf EbrahimiAUTHOR 120*287e80b3SSadaf Ebrahimi------ 121*287e80b3SSadaf Ebrahimi[verse] 122*287e80b3SSadaf Ebrahimi-- 123*287e80b3SSadaf Ebrahimi*Steven Rostedt* <[email protected]> 124*287e80b3SSadaf Ebrahimi*Tzvetomir Stoyanov* <[email protected]> 125*287e80b3SSadaf Ebrahimi-- 126*287e80b3SSadaf EbrahimiREPORTING BUGS 127*287e80b3SSadaf Ebrahimi-------------- 128*287e80b3SSadaf EbrahimiReport bugs to <[email protected]> 129*287e80b3SSadaf Ebrahimi 130*287e80b3SSadaf EbrahimiLICENSE 131*287e80b3SSadaf Ebrahimi------- 132*287e80b3SSadaf Ebrahimilibtracefs is Free Software licensed under the GNU LGPL 2.1 133*287e80b3SSadaf Ebrahimi 134*287e80b3SSadaf EbrahimiRESOURCES 135*287e80b3SSadaf Ebrahimi--------- 136*287e80b3SSadaf Ebrahimihttps://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/ 137*287e80b3SSadaf Ebrahimi 138*287e80b3SSadaf EbrahimiCOPYING 139*287e80b3SSadaf Ebrahimi------- 140*287e80b3SSadaf EbrahimiCopyright \(C) 2020 VMware, Inc. Free use of this software is granted under 141*287e80b3SSadaf Ebrahimithe terms of the GNU Public License (GPL). 142