xref: /aosp_15_r20/external/libtraceevent/Documentation/libtraceevent-handle.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_alloc, tep_free,tep_ref, tep_unref,tep_get_ref, tep_kbuffer - Create, destroy, manage
7*436bf2bcSAndroid Build Coastguard Workerreferences of trace event parser context.
8*436bf2bcSAndroid Build Coastguard Worker
9*436bf2bcSAndroid Build Coastguard WorkerSYNOPSIS
10*436bf2bcSAndroid Build Coastguard Worker--------
11*436bf2bcSAndroid Build Coastguard Worker[verse]
12*436bf2bcSAndroid Build Coastguard Worker--
13*436bf2bcSAndroid Build Coastguard Worker*#include <event-parse.h>*
14*436bf2bcSAndroid Build Coastguard Worker
15*436bf2bcSAndroid Build Coastguard Workerstruct tep_handle pass:[*]*tep_alloc*(void);
16*436bf2bcSAndroid Build Coastguard Workervoid *tep_free*(struct tep_handle pass:[*]_tep_);
17*436bf2bcSAndroid Build Coastguard Workervoid *tep_ref*(struct tep_handle pass:[*]_tep_);
18*436bf2bcSAndroid Build Coastguard Workervoid *tep_unref*(struct tep_handle pass:[*]_tep_);
19*436bf2bcSAndroid Build Coastguard Workerint *tep_get_ref*(struct tep_handle pass:[*]_tep_);
20*436bf2bcSAndroid Build Coastguard Workerstruct kbuffer pass:[*]*tep_kbuffer*(struct tep_handle pass:[*]_tep_);
21*436bf2bcSAndroid Build Coastguard Worker--
22*436bf2bcSAndroid Build Coastguard Worker
23*436bf2bcSAndroid Build Coastguard WorkerDESCRIPTION
24*436bf2bcSAndroid Build Coastguard Worker-----------
25*436bf2bcSAndroid Build Coastguard WorkerThese are the main functions to create and destroy tep_handle - the main
26*436bf2bcSAndroid Build Coastguard Workerstructure, representing the trace event parser context. This context is used as
27*436bf2bcSAndroid Build Coastguard Workerthe input parameter of most library APIs.
28*436bf2bcSAndroid Build Coastguard Worker
29*436bf2bcSAndroid Build Coastguard WorkerThe *tep_alloc()* function allocates and initializes the tep context.
30*436bf2bcSAndroid Build Coastguard Worker
31*436bf2bcSAndroid Build Coastguard WorkerThe *tep_free()* function will decrement the reference of the _tep_ handler.
32*436bf2bcSAndroid Build Coastguard WorkerWhen there is no more references, then it will free the handler, as well
33*436bf2bcSAndroid Build Coastguard Workeras clean up all its resources that it had used. The argument _tep_ is
34*436bf2bcSAndroid Build Coastguard Workerthe pointer to the trace event parser context.
35*436bf2bcSAndroid Build Coastguard Worker
36*436bf2bcSAndroid Build Coastguard WorkerThe *tep_ref()* function adds a reference to the _tep_ handler.
37*436bf2bcSAndroid Build Coastguard Worker
38*436bf2bcSAndroid Build Coastguard WorkerThe *tep_unref()* function removes a reference from the _tep_ handler. When
39*436bf2bcSAndroid Build Coastguard Workerthe last reference is removed, the _tep_ is destroyed, and all resources that
40*436bf2bcSAndroid Build Coastguard Workerit had used are cleaned up.
41*436bf2bcSAndroid Build Coastguard Worker
42*436bf2bcSAndroid Build Coastguard WorkerThe *tep_ref_get()* functions gets the current references of the _tep_ handler.
43*436bf2bcSAndroid Build Coastguard Worker
44*436bf2bcSAndroid Build Coastguard WorkerThe *tep_kbuffer()* function allocates a kbuffer descriptor that can be used to
45*436bf2bcSAndroid Build Coastguard Workerparse raw data that is represented by the _tep_ handle descriptor. It must be freed
46*436bf2bcSAndroid Build Coastguard Workerwith *kbuf_free(3)*.
47*436bf2bcSAndroid Build Coastguard Worker
48*436bf2bcSAndroid Build Coastguard WorkerRETURN VALUE
49*436bf2bcSAndroid Build Coastguard Worker------------
50*436bf2bcSAndroid Build Coastguard Worker*tep_alloc()* returns a pointer to a newly created tep_handle structure.
51*436bf2bcSAndroid Build Coastguard WorkerNULL is returned in case there is not enough free memory to allocate it.
52*436bf2bcSAndroid Build Coastguard Worker
53*436bf2bcSAndroid Build Coastguard Worker*tep_ref_get()* returns the current references of _tep_.
54*436bf2bcSAndroid Build Coastguard WorkerIf _tep_ is NULL, 0 is returned.
55*436bf2bcSAndroid Build Coastguard Worker
56*436bf2bcSAndroid Build Coastguard Worker*tep_kbuffer()* returns a kbuffer descriptor that can parse the raw data that
57*436bf2bcSAndroid Build Coastguard Workerrepresents the tep handle. Must be freed with *kbuf_free(3)*.
58*436bf2bcSAndroid Build Coastguard Worker
59*436bf2bcSAndroid Build Coastguard WorkerEXAMPLE
60*436bf2bcSAndroid Build Coastguard Worker-------
61*436bf2bcSAndroid Build Coastguard Worker[source,c]
62*436bf2bcSAndroid Build Coastguard Worker--
63*436bf2bcSAndroid Build Coastguard Worker#include <event-parse.h>
64*436bf2bcSAndroid Build Coastguard Worker
65*436bf2bcSAndroid Build Coastguard Worker...
66*436bf2bcSAndroid Build Coastguard Workerstruct tep_handle *tep = tep_alloc();
67*436bf2bcSAndroid Build Coastguard Worker...
68*436bf2bcSAndroid Build Coastguard Workerint ref = tep_get_ref(tep);
69*436bf2bcSAndroid Build Coastguard Workertep_ref(tep);
70*436bf2bcSAndroid Build Coastguard Workerif ( (ref+1) != tep_get_ref(tep)) {
71*436bf2bcSAndroid Build Coastguard Worker	/* Something wrong happened, the counter is not incremented by 1 */
72*436bf2bcSAndroid Build Coastguard Worker}
73*436bf2bcSAndroid Build Coastguard Workertep_unref(tep);
74*436bf2bcSAndroid Build Coastguard Worker...
75*436bf2bcSAndroid Build Coastguard Workertep_free(tep);
76*436bf2bcSAndroid Build Coastguard Worker...
77*436bf2bcSAndroid Build Coastguard Worker--
78*436bf2bcSAndroid Build Coastguard WorkerFILES
79*436bf2bcSAndroid Build Coastguard Worker-----
80*436bf2bcSAndroid Build Coastguard Worker[verse]
81*436bf2bcSAndroid Build Coastguard Worker--
82*436bf2bcSAndroid Build Coastguard Worker*event-parse.h*
83*436bf2bcSAndroid Build Coastguard Worker	Header file to include in order to have access to the library APIs.
84*436bf2bcSAndroid Build Coastguard Worker*-ltraceevent*
85*436bf2bcSAndroid Build Coastguard Worker	Linker switch to add when building a program that uses the library.
86*436bf2bcSAndroid Build Coastguard Worker--
87*436bf2bcSAndroid Build Coastguard Worker
88*436bf2bcSAndroid Build Coastguard WorkerSEE ALSO
89*436bf2bcSAndroid Build Coastguard Worker--------
90*436bf2bcSAndroid Build Coastguard Worker*libtraceevent*(3), *trace-cmd*(1)
91*436bf2bcSAndroid Build Coastguard Worker
92*436bf2bcSAndroid Build Coastguard WorkerAUTHOR
93*436bf2bcSAndroid Build Coastguard Worker------
94*436bf2bcSAndroid Build Coastguard Worker[verse]
95*436bf2bcSAndroid Build Coastguard Worker--
96*436bf2bcSAndroid Build Coastguard Worker*Steven Rostedt* <[email protected]>, author of *libtraceevent*.
97*436bf2bcSAndroid Build Coastguard Worker*Tzvetomir Stoyanov* <[email protected]>, author of this man page.
98*436bf2bcSAndroid Build Coastguard Worker--
99*436bf2bcSAndroid Build Coastguard WorkerREPORTING BUGS
100*436bf2bcSAndroid Build Coastguard Worker--------------
101*436bf2bcSAndroid Build Coastguard WorkerReport bugs to  <[email protected]>
102*436bf2bcSAndroid Build Coastguard Worker
103*436bf2bcSAndroid Build Coastguard WorkerLICENSE
104*436bf2bcSAndroid Build Coastguard Worker-------
105*436bf2bcSAndroid Build Coastguard Workerlibtraceevent is Free Software licensed under the GNU LGPL 2.1
106*436bf2bcSAndroid Build Coastguard Worker
107*436bf2bcSAndroid Build Coastguard WorkerRESOURCES
108*436bf2bcSAndroid Build Coastguard Worker---------
109*436bf2bcSAndroid Build Coastguard Workerhttps://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
110