xref: /aosp_15_r20/external/libtraceevent/Documentation/libtraceevent-event_find.txt (revision 436bf2bcd5202612ffffe471bbcc1f277cc8d28e)
1libtraceevent(3)
2================
3
4NAME
5----
6tep_find_event,tep_find_event_by_name,tep_find_event_by_record, tep_record_is_event -
7Find events by given key.
8
9SYNOPSIS
10--------
11[verse]
12--
13*#include <event-parse.h>*
14
15struct tep_event pass:[*]*tep_find_event*(struct tep_handle pass:[*]_tep_, int _id_);
16struct tep_event pass:[*]*tep_find_event_by_name*(struct tep_handle pass:[*]_tep_, const char pass:[*]_sys_, const char pass:[*]_name_);
17struct tep_event pass:[*]*tep_find_event_by_record*(struct tep_handle pass:[*]_tep_, struct tep_record pass:[*]_record_);
18bool *tep_record_is_event*(struct tep_record pass:[*]record, struct tep_event pass:[*]event);
19--
20
21DESCRIPTION
22-----------
23This set of functions can be used to search for an event, based on a given
24criteria. All functions require a pointer to a _tep_, trace event parser
25context.
26
27The *tep_find_event()* function searches for an event by given event _id_. The
28event ID is assigned dynamically and can be viewed in event's format file,
29"ID" field.
30
31The *tep_find_event_by_name()* function searches for an event by given
32event _name_, under the system _sys_. If the _sys_ is NULL (not specified),
33the first event with _name_ is returned.
34
35The *tep_find_event_by_record()* function searches for an event from a given
36_record_.
37
38The *tep_record_is_event()* function tests if the given _record_ is of the type
39of the _event_. This is normally used to know if the _record_ being processed is
40of an _event_ where further processing should be done.
41
42RETURN VALUE
43------------
44All these functions except *tep_record_is_event()* return a pointer to the found event, or NULL if there is no
45such event.
46
47EXAMPLE
48-------
49[source,c]
50--
51#include <event-parse.h>
52...
53struct tep_handle *tep = tep_alloc();
54...
55struct tep_event *event;
56
57event = tep_find_event(tep, 1857);
58if (event == NULL) {
59	/* There is no event with ID 1857 */
60}
61
62event = tep_find_event_by_name(tep, "kvm", "kvm_exit");
63if (event == NULL) {
64	/* There is no kvm_exit event, from kvm system */
65}
66
67void event_from_record(struct tep_record *record)
68{
69 struct tep_event *event = tep_find_event_by_record(tep, record);
70	if (event == NULL) {
71		/* There is no event from given record */
72	}
73}
74...
75--
76
77FILES
78-----
79[verse]
80--
81*event-parse.h*
82	Header file to include in order to have access to the library APIs.
83*-ltraceevent*
84	Linker switch to add when building a program that uses the library.
85--
86
87SEE ALSO
88--------
89*libtraceevent*(3), *trace-cmd*(1)
90
91AUTHOR
92------
93[verse]
94--
95*Steven Rostedt* <[email protected]>, author of *libtraceevent*.
96*Tzvetomir Stoyanov* <[email protected]>, author of this man page.
97--
98REPORTING BUGS
99--------------
100Report bugs to  <[email protected]>
101
102LICENSE
103-------
104libtraceevent is Free Software licensed under the GNU LGPL 2.1
105
106RESOURCES
107---------
108https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
109