xref: /OK3568_Linux_fs/kernel/tools/lib/traceevent/Documentation/libtraceevent-event_find.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyunlibtraceevent(3)
2*4882a593Smuzhiyun================
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunNAME
5*4882a593Smuzhiyun----
6*4882a593Smuzhiyuntep_find_event,tep_find_event_by_name,tep_find_event_by_record -
7*4882a593SmuzhiyunFind events by given key.
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunSYNOPSIS
10*4882a593Smuzhiyun--------
11*4882a593Smuzhiyun[verse]
12*4882a593Smuzhiyun--
13*4882a593Smuzhiyun*#include <event-parse.h>*
14*4882a593Smuzhiyun
15*4882a593Smuzhiyunstruct tep_event pass:[*]*tep_find_event*(struct tep_handle pass:[*]_tep_, int _id_);
16*4882a593Smuzhiyunstruct tep_event pass:[*]*tep_find_event_by_name*(struct tep_handle pass:[*]_tep_, const char pass:[*]_sys_, const char pass:[*]_name_);
17*4882a593Smuzhiyunstruct tep_event pass:[*]*tep_find_event_by_record*(struct tep_handle pass:[*]_tep_, struct tep_record pass:[*]_record_);
18*4882a593Smuzhiyun--
19*4882a593Smuzhiyun
20*4882a593SmuzhiyunDESCRIPTION
21*4882a593Smuzhiyun-----------
22*4882a593SmuzhiyunThis set of functions can be used to search for an event, based on a given
23*4882a593Smuzhiyuncriteria. All functions require a pointer to a _tep_, trace event parser
24*4882a593Smuzhiyuncontext.
25*4882a593Smuzhiyun
26*4882a593SmuzhiyunThe _tep_find_event()_ function searches for an event by given event _id_. The
27*4882a593Smuzhiyunevent ID is assigned dynamically and can be viewed in event's format file,
28*4882a593Smuzhiyun"ID" field.
29*4882a593Smuzhiyun
30*4882a593SmuzhiyunThe tep_find_event_by_name()_ function searches for an event by given
31*4882a593Smuzhiyunevent _name_, under the system _sys_. If the _sys_ is NULL (not specified),
32*4882a593Smuzhiyunthe first event with _name_ is returned.
33*4882a593Smuzhiyun
34*4882a593SmuzhiyunThe tep_find_event_by_record()_ function searches for an event from a given
35*4882a593Smuzhiyun_record_.
36*4882a593Smuzhiyun
37*4882a593SmuzhiyunRETURN VALUE
38*4882a593Smuzhiyun------------
39*4882a593SmuzhiyunAll these functions return a pointer to the found event, or NULL if there is no
40*4882a593Smuzhiyunsuch event.
41*4882a593Smuzhiyun
42*4882a593SmuzhiyunEXAMPLE
43*4882a593Smuzhiyun-------
44*4882a593Smuzhiyun[source,c]
45*4882a593Smuzhiyun--
46*4882a593Smuzhiyun#include <event-parse.h>
47*4882a593Smuzhiyun...
48*4882a593Smuzhiyunstruct tep_handle *tep = tep_alloc();
49*4882a593Smuzhiyun...
50*4882a593Smuzhiyunstruct tep_event *event;
51*4882a593Smuzhiyun
52*4882a593Smuzhiyunevent = tep_find_event(tep, 1857);
53*4882a593Smuzhiyunif (event == NULL) {
54*4882a593Smuzhiyun	/* There is no event with ID 1857 */
55*4882a593Smuzhiyun}
56*4882a593Smuzhiyun
57*4882a593Smuzhiyunevent = tep_find_event_by_name(tep, "kvm", "kvm_exit");
58*4882a593Smuzhiyunif (event == NULL) {
59*4882a593Smuzhiyun	/* There is no kvm_exit event, from kvm system */
60*4882a593Smuzhiyun}
61*4882a593Smuzhiyun
62*4882a593Smuzhiyunvoid event_from_record(struct tep_record *record)
63*4882a593Smuzhiyun{
64*4882a593Smuzhiyun struct tep_event *event = tep_find_event_by_record(tep, record);
65*4882a593Smuzhiyun	if (event == NULL) {
66*4882a593Smuzhiyun		/* There is no event from given record */
67*4882a593Smuzhiyun	}
68*4882a593Smuzhiyun}
69*4882a593Smuzhiyun...
70*4882a593Smuzhiyun--
71*4882a593Smuzhiyun
72*4882a593SmuzhiyunFILES
73*4882a593Smuzhiyun-----
74*4882a593Smuzhiyun[verse]
75*4882a593Smuzhiyun--
76*4882a593Smuzhiyun*event-parse.h*
77*4882a593Smuzhiyun	Header file to include in order to have access to the library APIs.
78*4882a593Smuzhiyun*-ltraceevent*
79*4882a593Smuzhiyun	Linker switch to add when building a program that uses the library.
80*4882a593Smuzhiyun--
81*4882a593Smuzhiyun
82*4882a593SmuzhiyunSEE ALSO
83*4882a593Smuzhiyun--------
84*4882a593Smuzhiyun_libtraceevent(3)_, _trace-cmd(1)_
85*4882a593Smuzhiyun
86*4882a593SmuzhiyunAUTHOR
87*4882a593Smuzhiyun------
88*4882a593Smuzhiyun[verse]
89*4882a593Smuzhiyun--
90*4882a593Smuzhiyun*Steven Rostedt* <rostedt@goodmis.org>, author of *libtraceevent*.
91*4882a593Smuzhiyun*Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>, author of this man page.
92*4882a593Smuzhiyun--
93*4882a593SmuzhiyunREPORTING BUGS
94*4882a593Smuzhiyun--------------
95*4882a593SmuzhiyunReport bugs to  <linux-trace-devel@vger.kernel.org>
96*4882a593Smuzhiyun
97*4882a593SmuzhiyunLICENSE
98*4882a593Smuzhiyun-------
99*4882a593Smuzhiyunlibtraceevent is Free Software licensed under the GNU LGPL 2.1
100*4882a593Smuzhiyun
101*4882a593SmuzhiyunRESOURCES
102*4882a593Smuzhiyun---------
103*4882a593Smuzhiyunhttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
104