xref: /aosp_15_r20/external/libtraceevent/Documentation/libtraceevent-event_get.txt (revision 436bf2bcd5202612ffffe471bbcc1f277cc8d28e)
1*436bf2bcSAndroid Build Coastguard Workerlibtraceevent(3)
2*436bf2bcSAndroid Build Coastguard Worker================
3*436bf2bcSAndroid Build Coastguard Worker
4*436bf2bcSAndroid Build Coastguard WorkerNAME
5*436bf2bcSAndroid Build Coastguard Worker----
6*436bf2bcSAndroid Build Coastguard Workertep_get_event, tep_get_first_event, tep_get_events_count - Access events.
7*436bf2bcSAndroid Build Coastguard Worker
8*436bf2bcSAndroid Build Coastguard WorkerSYNOPSIS
9*436bf2bcSAndroid Build Coastguard Worker--------
10*436bf2bcSAndroid Build Coastguard Worker[verse]
11*436bf2bcSAndroid Build Coastguard Worker--
12*436bf2bcSAndroid Build Coastguard Worker*#include <event-parse.h>*
13*436bf2bcSAndroid Build Coastguard Worker
14*436bf2bcSAndroid Build Coastguard Workerstruct tep_event pass:[*]*tep_get_event*(struct tep_handle pass:[*]_tep_, int _index_);
15*436bf2bcSAndroid Build Coastguard Workerstruct tep_event pass:[*]*tep_get_first_event*(struct tep_handle pass:[*]_tep_);
16*436bf2bcSAndroid Build Coastguard Workerint *tep_get_events_count*(struct tep_handle pass:[*]_tep_);
17*436bf2bcSAndroid Build Coastguard Worker--
18*436bf2bcSAndroid Build Coastguard Worker
19*436bf2bcSAndroid Build Coastguard WorkerDESCRIPTION
20*436bf2bcSAndroid Build Coastguard Worker-----------
21*436bf2bcSAndroid Build Coastguard WorkerThe *tep_get_event()* function returns a pointer to event at the given _index_.
22*436bf2bcSAndroid Build Coastguard WorkerThe _tep_ argument is trace event parser context, the _index_ is the index of
23*436bf2bcSAndroid Build Coastguard Workerthe requested event.
24*436bf2bcSAndroid Build Coastguard Worker
25*436bf2bcSAndroid Build Coastguard WorkerThe *tep_get_first_event()* function returns a pointer to the first event.
26*436bf2bcSAndroid Build Coastguard WorkerAs events are stored in an array, this function returns the pointer to the
27*436bf2bcSAndroid Build Coastguard Workerbeginning of the array. The _tep_ argument is trace event parser context.
28*436bf2bcSAndroid Build Coastguard Worker
29*436bf2bcSAndroid Build Coastguard WorkerThe *tep_get_events_count()* function returns the number of the events
30*436bf2bcSAndroid Build Coastguard Workerin the array. The _tep_ argument is trace event parser context.
31*436bf2bcSAndroid Build Coastguard Worker
32*436bf2bcSAndroid Build Coastguard WorkerRETURN VALUE
33*436bf2bcSAndroid Build Coastguard Worker------------
34*436bf2bcSAndroid Build Coastguard WorkerThe *tep_get_event()* returns a pointer to the event located at _index_.
35*436bf2bcSAndroid Build Coastguard WorkerNULL is returned in case of error, in case there are no events or _index_ is
36*436bf2bcSAndroid Build Coastguard Workerout of range.
37*436bf2bcSAndroid Build Coastguard Worker
38*436bf2bcSAndroid Build Coastguard WorkerThe *tep_get_first_event()* returns a pointer to the first event. NULL is
39*436bf2bcSAndroid Build Coastguard Workerreturned in case of error, or in case there are no events.
40*436bf2bcSAndroid Build Coastguard Worker
41*436bf2bcSAndroid Build Coastguard WorkerThe *tep_get_events_count()* returns the number of the events. 0 is
42*436bf2bcSAndroid Build Coastguard Workerreturned in case of error, or in case there are no events.
43*436bf2bcSAndroid Build Coastguard Worker
44*436bf2bcSAndroid Build Coastguard WorkerEXAMPLE
45*436bf2bcSAndroid Build Coastguard Worker-------
46*436bf2bcSAndroid Build Coastguard Worker[source,c]
47*436bf2bcSAndroid Build Coastguard Worker--
48*436bf2bcSAndroid Build Coastguard Worker#include <event-parse.h>
49*436bf2bcSAndroid Build Coastguard Worker...
50*436bf2bcSAndroid Build Coastguard Workerstruct tep_handle *tep = tep_alloc();
51*436bf2bcSAndroid Build Coastguard Worker...
52*436bf2bcSAndroid Build Coastguard Workerint i,count = tep_get_events_count(tep);
53*436bf2bcSAndroid Build Coastguard Workerstruct tep_event *event, *events = tep_get_first_event(tep);
54*436bf2bcSAndroid Build Coastguard Worker
55*436bf2bcSAndroid Build Coastguard Workerif (events == NULL) {
56*436bf2bcSAndroid Build Coastguard Worker	/* There are no events */
57*436bf2bcSAndroid Build Coastguard Worker} else {
58*436bf2bcSAndroid Build Coastguard Worker	for (i = 0; i < count; i++) {
59*436bf2bcSAndroid Build Coastguard Worker		event = (events+i);
60*436bf2bcSAndroid Build Coastguard Worker		/* process events[i] */
61*436bf2bcSAndroid Build Coastguard Worker	}
62*436bf2bcSAndroid Build Coastguard Worker
63*436bf2bcSAndroid Build Coastguard Worker	/* Get the last event */
64*436bf2bcSAndroid Build Coastguard Worker	event = tep_get_event(tep, count-1);
65*436bf2bcSAndroid Build Coastguard Worker}
66*436bf2bcSAndroid Build Coastguard Worker--
67*436bf2bcSAndroid Build Coastguard Worker
68*436bf2bcSAndroid Build Coastguard WorkerFILES
69*436bf2bcSAndroid Build Coastguard Worker-----
70*436bf2bcSAndroid Build Coastguard Worker[verse]
71*436bf2bcSAndroid Build Coastguard Worker--
72*436bf2bcSAndroid Build Coastguard Worker*event-parse.h*
73*436bf2bcSAndroid Build Coastguard Worker	Header file to include in order to have access to the library APIs.
74*436bf2bcSAndroid Build Coastguard Worker*-ltraceevent*
75*436bf2bcSAndroid Build Coastguard Worker	Linker switch to add when building a program that uses the library.
76*436bf2bcSAndroid Build Coastguard Worker--
77*436bf2bcSAndroid Build Coastguard Worker
78*436bf2bcSAndroid Build Coastguard WorkerSEE ALSO
79*436bf2bcSAndroid Build Coastguard Worker--------
80*436bf2bcSAndroid Build Coastguard Worker*libtraceevent*(3), *trace-cmd*(1)
81*436bf2bcSAndroid Build Coastguard Worker
82*436bf2bcSAndroid Build Coastguard WorkerAUTHOR
83*436bf2bcSAndroid Build Coastguard Worker------
84*436bf2bcSAndroid Build Coastguard Worker[verse]
85*436bf2bcSAndroid Build Coastguard Worker--
86*436bf2bcSAndroid Build Coastguard Worker*Steven Rostedt* <[email protected]>, author of *libtraceevent*.
87*436bf2bcSAndroid Build Coastguard Worker*Tzvetomir Stoyanov* <[email protected]>, author of this man page.
88*436bf2bcSAndroid Build Coastguard Worker--
89*436bf2bcSAndroid Build Coastguard WorkerREPORTING BUGS
90*436bf2bcSAndroid Build Coastguard Worker--------------
91*436bf2bcSAndroid Build Coastguard WorkerReport bugs to  <[email protected]>
92*436bf2bcSAndroid Build Coastguard Worker
93*436bf2bcSAndroid Build Coastguard WorkerLICENSE
94*436bf2bcSAndroid Build Coastguard Worker-------
95*436bf2bcSAndroid Build Coastguard Workerlibtraceevent is Free Software licensed under the GNU LGPL 2.1
96*436bf2bcSAndroid Build Coastguard Worker
97*436bf2bcSAndroid Build Coastguard WorkerRESOURCES
98*436bf2bcSAndroid Build Coastguard Worker---------
99*436bf2bcSAndroid Build Coastguard Workerhttps://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
100