xref: /OK3568_Linux_fs/kernel/tools/lib/traceevent/Documentation/libtraceevent-parse_event.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyunlibtraceevent(3)
2*4882a593Smuzhiyun================
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunNAME
5*4882a593Smuzhiyun----
6*4882a593Smuzhiyuntep_parse_event, tep_parse_format - Parse the event format information
7*4882a593Smuzhiyun
8*4882a593SmuzhiyunSYNOPSIS
9*4882a593Smuzhiyun--------
10*4882a593Smuzhiyun[verse]
11*4882a593Smuzhiyun--
12*4882a593Smuzhiyun*#include <event-parse.h>*
13*4882a593Smuzhiyun
14*4882a593Smuzhiyunenum tep_errno *tep_parse_event*(struct tep_handle pass:[*]_tep_, const char pass:[*]_buf_, unsigned long _size_, const char pass:[*]_sys_);
15*4882a593Smuzhiyunenum 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*4882a593Smuzhiyun--
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunDESCRIPTION
19*4882a593Smuzhiyun-----------
20*4882a593SmuzhiyunThe _tep_parse_event()_ function parses the event format and creates an event
21*4882a593Smuzhiyunstructure to quickly parse raw data for a given event. The _tep_ argument is
22*4882a593Smuzhiyunthe trace event parser context. The created event structure is stored in the
23*4882a593Smuzhiyun_tep_ context. The _buf_ argument is a buffer with _size_, where the event
24*4882a593Smuzhiyunformat data is. The event format data can be taken from
25*4882a593Smuzhiyuntracefs/events/.../.../format files. The _sys_ argument is the system of
26*4882a593Smuzhiyunthe event.
27*4882a593Smuzhiyun
28*4882a593SmuzhiyunThe _tep_parse_format()_ function does the same as _tep_parse_event()_. The only
29*4882a593Smuzhiyundifference is in the extra _eventp_ argument, where the newly created event
30*4882a593Smuzhiyunstructure is returned.
31*4882a593Smuzhiyun
32*4882a593SmuzhiyunRETURN VALUE
33*4882a593Smuzhiyun------------
34*4882a593SmuzhiyunBoth _tep_parse_event()_ and _tep_parse_format()_ functions return 0 on success,
35*4882a593Smuzhiyunor TEP_ERRNO__... in case of an error.
36*4882a593Smuzhiyun
37*4882a593SmuzhiyunEXAMPLE
38*4882a593Smuzhiyun-------
39*4882a593Smuzhiyun[source,c]
40*4882a593Smuzhiyun--
41*4882a593Smuzhiyun#include <event-parse.h>
42*4882a593Smuzhiyun...
43*4882a593Smuzhiyunstruct tep_handle *tep = tep_alloc();
44*4882a593Smuzhiyun...
45*4882a593Smuzhiyunchar *buf;
46*4882a593Smuzhiyunint size;
47*4882a593Smuzhiyunstruct tep_event *event = NULL;
48*4882a593Smuzhiyunbuf = read_file("/sys/kernel/tracing/events/ftrace/print/format", &size);
49*4882a593Smuzhiyunif (tep_parse_event(tep, buf, size, "ftrace") != 0) {
50*4882a593Smuzhiyun	/* Failed to parse the ftrace print format */
51*4882a593Smuzhiyun}
52*4882a593Smuzhiyun
53*4882a593Smuzhiyunif (tep_parse_format(tep, &event, buf, size, "ftrace") != 0) {
54*4882a593Smuzhiyun	/* Failed to parse the ftrace print format */
55*4882a593Smuzhiyun}
56*4882a593Smuzhiyun...
57*4882a593Smuzhiyun--
58*4882a593Smuzhiyun
59*4882a593SmuzhiyunFILES
60*4882a593Smuzhiyun-----
61*4882a593Smuzhiyun[verse]
62*4882a593Smuzhiyun--
63*4882a593Smuzhiyun*event-parse.h*
64*4882a593Smuzhiyun	Header file to include in order to have access to the library APIs.
65*4882a593Smuzhiyun*-ltraceevent*
66*4882a593Smuzhiyun	Linker switch to add when building a program that uses the library.
67*4882a593Smuzhiyun--
68*4882a593Smuzhiyun
69*4882a593SmuzhiyunSEE ALSO
70*4882a593Smuzhiyun--------
71*4882a593Smuzhiyun_libtraceevent(3)_, _trace-cmd(1)_
72*4882a593Smuzhiyun
73*4882a593SmuzhiyunAUTHOR
74*4882a593Smuzhiyun------
75*4882a593Smuzhiyun[verse]
76*4882a593Smuzhiyun--
77*4882a593Smuzhiyun*Steven Rostedt* <rostedt@goodmis.org>, author of *libtraceevent*.
78*4882a593Smuzhiyun*Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>, author of this man page.
79*4882a593Smuzhiyun--
80*4882a593SmuzhiyunREPORTING BUGS
81*4882a593Smuzhiyun--------------
82*4882a593SmuzhiyunReport bugs to  <linux-trace-devel@vger.kernel.org>
83*4882a593Smuzhiyun
84*4882a593SmuzhiyunLICENSE
85*4882a593Smuzhiyun-------
86*4882a593Smuzhiyunlibtraceevent is Free Software licensed under the GNU LGPL 2.1
87*4882a593Smuzhiyun
88*4882a593SmuzhiyunRESOURCES
89*4882a593Smuzhiyun---------
90*4882a593Smuzhiyunhttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
91