Merge tag 'for-linus-20190524' of git://git.kernel.dk/linux-block
[linux-2.6-microblaze.git] / tools / lib / traceevent / Documentation / libtraceevent-parse_event.txt
1 libtraceevent(3)
2 ================
3
4 NAME
5 ----
6 tep_parse_event, tep_parse_format - Parse the event format information
7
8 SYNOPSIS
9 --------
10 [verse]
11 --
12 *#include <event-parse.h>*
13
14 enum tep_errno *tep_parse_event*(struct tep_handle pass:[*]_tep_, const char pass:[*]_buf_, unsigned long _size_, const char pass:[*]_sys_);
15 enum tep_errno *tep_parse_format*(struct tep_handle pass:[*]_tep_, struct tep_event pass:[*]pass:[*]_eventp_, const char pass:[*]_buf_, unsigned long _size_, const char pass:[*]_sys_);
16 --
17
18 DESCRIPTION
19 -----------
20 The _tep_parse_event()_ function parses the event format and creates an event
21 structure to quickly parse raw data for a given event. The _tep_ argument is
22 the trace event parser context. The created event structure is stored in the
23 _tep_ context. The _buf_ argument is a buffer with _size_, where the event
24 format data is. The event format data can be taken from
25 tracefs/events/.../.../format files. The _sys_ argument is the system of
26 the event.
27
28 The _tep_parse_format()_ function does the same as _tep_parse_event()_. The only
29 difference is in the extra _eventp_ argument, where the newly created event
30 structure is returned.
31
32 RETURN VALUE
33 ------------
34 Both _tep_parse_event()_ and _tep_parse_format()_ functions return 0 on success,
35 or TEP_ERRNO__... in case of an error.
36
37 EXAMPLE
38 -------
39 [source,c]
40 --
41 #include <event-parse.h>
42 ...
43 struct tep_handle *tep = tep_alloc();
44 ...
45 char *buf;
46 int size;
47 struct tep_event *event = NULL;
48 buf = read_file("/sys/kernel/tracing/events/ftrace/print/format", &size);
49 if (tep_parse_event(tep, buf, size, "ftrace") != 0) {
50         /* Failed to parse the ftrace print format */
51 }
52
53 if (tep_parse_format(tep, &event, buf, size, "ftrace") != 0) {
54         /* Failed to parse the ftrace print format */
55 }
56 ...
57 --
58
59 FILES
60 -----
61 [verse]
62 --
63 *event-parse.h*
64         Header file to include in order to have access to the library APIs.
65 *-ltraceevent*
66         Linker switch to add when building a program that uses the library.
67 --
68
69 SEE ALSO
70 --------
71 _libtraceevent(3)_, _trace-cmd(1)_
72
73 AUTHOR
74 ------
75 [verse]
76 --
77 *Steven Rostedt* <rostedt@goodmis.org>, author of *libtraceevent*.
78 *Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>, author of this man page.
79 --
80 REPORTING BUGS
81 --------------
82 Report bugs to  <linux-trace-devel@vger.kernel.org>
83
84 LICENSE
85 -------
86 libtraceevent is Free Software licensed under the GNU LGPL 2.1
87
88 RESOURCES
89 ---------
90 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git