summaryrefslogtreecommitdiffstats
path: root/Documentation/libtracefs-marker.txt
blob: adc5419c44dc75521b5fd1f1877417e86ec05a69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
libtracefs(3)
=============

NAME
----
tracefs_print_init, tracefs_print_close, tracefs_printf, tracefs_vprintf -
Open, close and write formated strings in the trace buffer.

SYNOPSIS
--------
[verse]
--
*#include <tracefs.h>*

int *tracefs_print_init*(struct tracefs_instance pass:[*]_instance_);
int *tracefs_printf*(struct tracefs_instance pass:[*]_instance_, const char pass:[*]_fmt_, _..._);
int *tracefs_vprintf*(struct tracefs_instance pass:[*]_instance_, const char pass:[*]_fmt_, va_list _ap_);
void *tracefs_print_close*(struct tracefs_instance pass:[*]_instance_);

--

DESCRIPTION
-----------
Set of functions to write formated strings in the trace buffer.
See Documentation/trace/ftrace.rst from the Linux kernel tree for more information about writing
data from user space in the trace buffer. All these APIs have _instance_ as a first argument. If
NULL is passed as _instance_, the top trace instance is used.

The *tracefs_print_init()* function initializes the library for writing into the trace buffer of
the selected _instance_. It is not mandatory to call this API before writing strings, any of
the printf APIs will call it automatically, if the library is not yet initialized. But calling
*tracefs_print_init()* in advance will speed up the writing.

The *tracefs_printf()* function writes a formatted string in the trace buffer of the selected
_instance_. The _fmt_ argument is a string in printf format, followed by variable arguments _..._.

The *tracefs_vprintf()* function writes a formatted string in the trace buffer of the selected
_instance_. The _fmt_ argument is a string in printf format, followed by list _ap_ of arguments.

The *tracefs_print_close()* function closes the resources, used by the library for writing in
the trace buffer of the selected instance.

RETURN VALUE
------------
The *tracefs_print_init()*, *tracefs_printf()*, and *tracefs_vprintf()* functions return 0 if
the operation is successful, or -1 in case of an error.

EXAMPLE
-------
[source,c]
--
#include <tracefs.h>

if (tracefs_print_init(NULL) < 0) {
 /* Failed to initialize the library for writing in the trace buffer of the top trace instance */
}

void foo_print(char *format, ...)
{
	va_list ap;
	va_start(ap, format);
	if (tracefs_vprintf(NULL, format, ap) < 0) {
		/* Failed to print in the trace buffer */
	}
	va_end(ap);
}

void foo_print_string(char *message)
{
	if (tracefs_printf(NULL, "Message from user space: %s", message) < 0) {
		/* Failed to print in the trace buffer */
	}
}

tracefs_print_close();
--
FILES
-----
[verse]
--
*tracefs.h*
	Header file to include in order to have access to the library APIs.
*-ltracefs*
	Linker switch to add when building a program that uses the library.
--

SEE ALSO
--------
*libtracefs*(3),
*libtraceevent*(3),
*trace-cmd*(1),
Documentation/trace/ftrace.rst from the Linux kernel tree

AUTHOR
------
[verse]
--
*Steven Rostedt* <rostedt@goodmis.org>
*Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>
--
REPORTING BUGS
--------------
Report bugs to  <linux-trace-devel@vger.kernel.org>

LICENSE
-------
libtracefs is Free Software licensed under the GNU LGPL 2.1

RESOURCES
---------
https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/

COPYING
-------
Copyright \(C) 2021 VMware, Inc. Free use of this software is granted under
the terms of the GNU Public License (GPL).