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