1*287e80b3SSadaf Ebrahimilibtracefs(3) 2*287e80b3SSadaf Ebrahimi============= 3*287e80b3SSadaf Ebrahimi 4*287e80b3SSadaf EbrahimiNAME 5*287e80b3SSadaf Ebrahimi---- 6*287e80b3SSadaf Ebrahimitracefs_binary_init, tracefs_binary_close, tracefs_binary_write - 7*287e80b3SSadaf EbrahimiOpen, close and write binary data in the trace buffer. 8*287e80b3SSadaf Ebrahimi 9*287e80b3SSadaf EbrahimiSYNOPSIS 10*287e80b3SSadaf Ebrahimi-------- 11*287e80b3SSadaf Ebrahimi[verse] 12*287e80b3SSadaf Ebrahimi-- 13*287e80b3SSadaf Ebrahimi*#include <tracefs.h>* 14*287e80b3SSadaf Ebrahimi 15*287e80b3SSadaf Ebrahimiint *tracefs_binary_init*(struct tracefs_instance pass:[*]_instance_); 16*287e80b3SSadaf Ebrahimiint *tracefs_binary_write*(struct tracefs_instance pass:[*]_instance_, void pass:[*]_data_, int _len_); 17*287e80b3SSadaf Ebrahimivoid *tracefs_binary_close*(struct tracefs_instance pass:[*]_instance_); 18*287e80b3SSadaf Ebrahimi 19*287e80b3SSadaf Ebrahimi-- 20*287e80b3SSadaf Ebrahimi 21*287e80b3SSadaf EbrahimiDESCRIPTION 22*287e80b3SSadaf Ebrahimi----------- 23*287e80b3SSadaf EbrahimiSet of functions to write binary data in the trace buffer. 24*287e80b3SSadaf EbrahimiSee Documentation/trace/ftrace.rst from the Linux kernel tree for more information about writing 25*287e80b3SSadaf Ebrahimidata from user space in the trace buffer. All these APIs have _instance_ as a first argument. If 26*287e80b3SSadaf EbrahimiNULL is passed as _instance_, the top trace instance is used. 27*287e80b3SSadaf Ebrahimi 28*287e80b3SSadaf EbrahimiThe *tracefs_binary_init()* function initializes the library for writing into the trace buffer of 29*287e80b3SSadaf Ebrahimithe selected _instance_. It is not mandatory to call this API before writing data, the 30*287e80b3SSadaf Ebrahimi*tracefs_binary_write()* will call it automatically, if the library is not yet initialized. 31*287e80b3SSadaf EbrahimiBut calling *tracefs_binary_init()* in advance will speed up the writing. 32*287e80b3SSadaf Ebrahimi 33*287e80b3SSadaf EbrahimiThe *tracefs_binary_write()* function writes a binary data in the trace buffer of the selected 34*287e80b3SSadaf Ebrahimi_instance_. The _data_ points to the data with length _len_, that is going to be written in 35*287e80b3SSadaf Ebrahimithe trace buffer. 36*287e80b3SSadaf Ebrahimi 37*287e80b3SSadaf EbrahimiThe *tracefs_binary_close()* function closes the resources, used by the library for writing in 38*287e80b3SSadaf Ebrahimithe trace buffer of the selected instance. 39*287e80b3SSadaf Ebrahimi 40*287e80b3SSadaf EbrahimiRETURN VALUE 41*287e80b3SSadaf Ebrahimi------------ 42*287e80b3SSadaf EbrahimiThe *tracefs_binary_init()*, and *tracefs_binary_write()* functions return 0 if the operation is 43*287e80b3SSadaf Ebrahimisuccessful, or -1 in case of an error. 44*287e80b3SSadaf Ebrahimi 45*287e80b3SSadaf EbrahimiEXAMPLE 46*287e80b3SSadaf Ebrahimi------- 47*287e80b3SSadaf Ebrahimi[source,c] 48*287e80b3SSadaf Ebrahimi-- 49*287e80b3SSadaf Ebrahimi#include <tracefs.h> 50*287e80b3SSadaf Ebrahimi 51*287e80b3SSadaf Ebrahimiif (tracefs_binary_init(NULL) < 0) { 52*287e80b3SSadaf Ebrahimi /* Failed to initialize the library for writing in the trace buffer of the top trace instance */ 53*287e80b3SSadaf Ebrahimi} 54*287e80b3SSadaf Ebrahimi 55*287e80b3SSadaf Ebrahimiunsigned int data = 0xdeadbeef; 56*287e80b3SSadaf Ebrahimi 57*287e80b3SSadaf Ebrahimi if (tracefs_binary_write(NULL, &data, sizeof(data)) < 0) { 58*287e80b3SSadaf Ebrahimi /* Failed to write in the trace buffer */ 59*287e80b3SSadaf Ebrahimi } 60*287e80b3SSadaf Ebrahimi 61*287e80b3SSadaf Ebrahimitracefs_binary_close(); 62*287e80b3SSadaf Ebrahimi-- 63*287e80b3SSadaf EbrahimiFILES 64*287e80b3SSadaf Ebrahimi----- 65*287e80b3SSadaf Ebrahimi[verse] 66*287e80b3SSadaf Ebrahimi-- 67*287e80b3SSadaf Ebrahimi*tracefs.h* 68*287e80b3SSadaf Ebrahimi Header file to include in order to have access to the library APIs. 69*287e80b3SSadaf Ebrahimi*-ltracefs* 70*287e80b3SSadaf Ebrahimi Linker switch to add when building a program that uses the library. 71*287e80b3SSadaf Ebrahimi-- 72*287e80b3SSadaf Ebrahimi 73*287e80b3SSadaf EbrahimiSEE ALSO 74*287e80b3SSadaf Ebrahimi-------- 75*287e80b3SSadaf Ebrahimi*libtracefs*(3), 76*287e80b3SSadaf Ebrahimi*libtraceevent*(3), 77*287e80b3SSadaf Ebrahimi*trace-cmd*(1), 78*287e80b3SSadaf EbrahimiDocumentation/trace/ftrace.rst from the Linux kernel tree 79*287e80b3SSadaf Ebrahimi 80*287e80b3SSadaf EbrahimiAUTHOR 81*287e80b3SSadaf Ebrahimi------ 82*287e80b3SSadaf Ebrahimi[verse] 83*287e80b3SSadaf Ebrahimi-- 84*287e80b3SSadaf Ebrahimi*Steven Rostedt* <[email protected]> 85*287e80b3SSadaf Ebrahimi*Tzvetomir Stoyanov* <[email protected]> 86*287e80b3SSadaf Ebrahimi-- 87*287e80b3SSadaf EbrahimiREPORTING BUGS 88*287e80b3SSadaf Ebrahimi-------------- 89*287e80b3SSadaf EbrahimiReport bugs to <[email protected]> 90*287e80b3SSadaf Ebrahimi 91*287e80b3SSadaf EbrahimiLICENSE 92*287e80b3SSadaf Ebrahimi------- 93*287e80b3SSadaf Ebrahimilibtracefs is Free Software licensed under the GNU LGPL 2.1 94*287e80b3SSadaf Ebrahimi 95*287e80b3SSadaf EbrahimiRESOURCES 96*287e80b3SSadaf Ebrahimi--------- 97*287e80b3SSadaf Ebrahimihttps://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/ 98*287e80b3SSadaf Ebrahimi 99*287e80b3SSadaf EbrahimiCOPYING 100*287e80b3SSadaf Ebrahimi------- 101*287e80b3SSadaf EbrahimiCopyright \(C) 2021 VMware, Inc. Free use of this software is granted under 102*287e80b3SSadaf Ebrahimithe terms of the GNU Public License (GPL). 103