xref: /OK3568_Linux_fs/kernel/tools/lib/traceevent/Documentation/libtraceevent.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyunlibtraceevent(3)
2*4882a593Smuzhiyun================
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunNAME
5*4882a593Smuzhiyun----
6*4882a593Smuzhiyunlibtraceevent - Linux kernel trace event library
7*4882a593Smuzhiyun
8*4882a593SmuzhiyunSYNOPSIS
9*4882a593Smuzhiyun--------
10*4882a593Smuzhiyun[verse]
11*4882a593Smuzhiyun--
12*4882a593Smuzhiyun*#include <event-parse.h>*
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunManagement of tep handler data structure and access of its members:
15*4882a593Smuzhiyun	struct tep_handle pass:[*]*tep_alloc*(void);
16*4882a593Smuzhiyun	void *tep_free*(struct tep_handle pass:[*]_tep_);
17*4882a593Smuzhiyun	void *tep_ref*(struct tep_handle pass:[*]_tep_);
18*4882a593Smuzhiyun	void *tep_unref*(struct tep_handle pass:[*]_tep_);
19*4882a593Smuzhiyun	int *tep_get_ref*(struct tep_handle pass:[*]_tep_);
20*4882a593Smuzhiyun	void *tep_set_flag*(struct tep_handle pass:[*]_tep_, enum tep_flag _flag_);
21*4882a593Smuzhiyun	void *tep_clear_flag*(struct tep_handle pass:[*]_tep_, enum tep_flag _flag_);
22*4882a593Smuzhiyun	bool *tep_test_flag*(struct tep_handle pass:[*]_tep_, enum tep_flag _flags_);
23*4882a593Smuzhiyun	int *tep_get_cpus*(struct tep_handle pass:[*]_tep_);
24*4882a593Smuzhiyun	void *tep_set_cpus*(struct tep_handle pass:[*]_tep_, int _cpus_);
25*4882a593Smuzhiyun	int *tep_get_long_size*(strucqt tep_handle pass:[*]_tep_);
26*4882a593Smuzhiyun	void *tep_set_long_size*(struct tep_handle pass:[*]_tep_, int _long_size_);
27*4882a593Smuzhiyun	int *tep_get_page_size*(struct tep_handle pass:[*]_tep_);
28*4882a593Smuzhiyun	void *tep_set_page_size*(struct tep_handle pass:[*]_tep_, int _page_size_);
29*4882a593Smuzhiyun	int *tep_get_header_page_size*(struct tep_handle pass:[*]_tep_);
30*4882a593Smuzhiyun	int *tep_get_header_timestamp_size*(struct tep_handle pass:[*]_tep_);
31*4882a593Smuzhiyun	bool *tep_is_old_format*(struct tep_handle pass:[*]_tep_);
32*4882a593Smuzhiyun	int *tep_strerror*(struct tep_handle pass:[*]_tep_, enum tep_errno _errnum_, char pass:[*]_buf_, size_t _buflen_);
33*4882a593Smuzhiyun
34*4882a593SmuzhiyunRegister / unregister APIs:
35*4882a593Smuzhiyun	int *tep_register_function*(struct tep_handle pass:[*]_tep_, char pass:[*]_name_, unsigned long long _addr_, char pass:[*]_mod_);
36*4882a593Smuzhiyun	int *tep_register_event_handler*(struct tep_handle pass:[*]_tep_, int _id_, const char pass:[*]_sys_name_, const char pass:[*]_event_name_, tep_event_handler_func _func_, void pass:[*]_context_);
37*4882a593Smuzhiyun	int *tep_unregister_event_handler*(struct tep_handle pass:[*]tep, int id, const char pass:[*]sys_name, const char pass:[*]event_name, tep_event_handler_func func, void pass:[*]_context_);
38*4882a593Smuzhiyun	int *tep_register_print_string*(struct tep_handle pass:[*]_tep_, const char pass:[*]_fmt_, unsigned long long _addr_);
39*4882a593Smuzhiyun	int *tep_register_print_function*(struct tep_handle pass:[*]_tep_, tep_func_handler _func_, enum tep_func_arg_type _ret_type_, char pass:[*]_name_, _..._);
40*4882a593Smuzhiyun	int *tep_unregister_print_function*(struct tep_handle pass:[*]_tep_, tep_func_handler _func_, char pass:[*]_name_);
41*4882a593Smuzhiyun
42*4882a593SmuzhiyunPlugins management:
43*4882a593Smuzhiyun	struct tep_plugin_list pass:[*]*tep_load_plugins*(struct tep_handle pass:[*]_tep_);
44*4882a593Smuzhiyun	void *tep_unload_plugins*(struct tep_plugin_list pass:[*]_plugin_list_, struct tep_handle pass:[*]_tep_);
45*4882a593Smuzhiyun	char pass:[*]pass:[*]*tep_plugin_list_options*(void);
46*4882a593Smuzhiyun	void *tep_plugin_free_options_list*(char pass:[*]pass:[*]_list_);
47*4882a593Smuzhiyun	int *tep_plugin_add_options*(const char pass:[*]_name_, struct tep_plugin_option pass:[*]_options_);
48*4882a593Smuzhiyun	void *tep_plugin_remove_options*(struct tep_plugin_option pass:[*]_options_);
49*4882a593Smuzhiyun	void *tep_print_plugins*(struct trace_seq pass:[*]_s_, const char pass:[*]_prefix_, const char pass:[*]_suffix_, const struct tep_plugin_list pass:[*]_list_);
50*4882a593Smuzhiyun
51*4882a593SmuzhiyunEvent related APIs:
52*4882a593Smuzhiyun	struct tep_event pass:[*]*tep_get_event*(struct tep_handle pass:[*]_tep_, int _index_);
53*4882a593Smuzhiyun	struct tep_event pass:[*]*tep_get_first_event*(struct tep_handle pass:[*]_tep_);
54*4882a593Smuzhiyun	int *tep_get_events_count*(struct tep_handle pass:[*]_tep_);
55*4882a593Smuzhiyun	struct tep_event pass:[*]pass:[*]*tep_list_events*(struct tep_handle pass:[*]_tep_, enum tep_event_sort_type _sort_type_);
56*4882a593Smuzhiyun	struct tep_event pass:[*]pass:[*]*tep_list_events_copy*(struct tep_handle pass:[*]_tep_, enum tep_event_sort_type _sort_type_);
57*4882a593Smuzhiyun	void *tep_print_event*(struct tep_handle pass:[*]_tep_, struct trace_seq pass:[*]_s_, struct tep_record pass:[*]_record_, const char pass:[*]_fmt_, _..._);
58*4882a593Smuzhiyun
59*4882a593SmuzhiyunEvent finding:
60*4882a593Smuzhiyun	struct tep_event pass:[*]*tep_find_event*(struct tep_handle pass:[*]_tep_, int _id_);
61*4882a593Smuzhiyun	struct tep_event pass:[*]*tep_find_event_by_name*(struct tep_handle pass:[*]_tep_, const char pass:[*]_sys_, const char pass:[*]_name_);
62*4882a593Smuzhiyun	struct tep_event pass:[*]*tep_find_event_by_record*(struct tep_handle pass:[*]_tep_, struct tep_record pass:[*]_record_);
63*4882a593Smuzhiyun
64*4882a593SmuzhiyunParsing of event files:
65*4882a593Smuzhiyun	int *tep_parse_header_page*(struct tep_handle pass:[*]_tep_, char pass:[*]_buf_, unsigned long _size_, int _long_size_);
66*4882a593Smuzhiyun	enum tep_errno *tep_parse_event*(struct tep_handle pass:[*]_tep_, const char pass:[*]_buf_, unsigned long _size_, const char pass:[*]_sys_);
67*4882a593Smuzhiyun	enum 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_);
68*4882a593Smuzhiyun
69*4882a593SmuzhiyunAPIs related to fields from event's format files:
70*4882a593Smuzhiyun	struct tep_format_field pass:[*]pass:[*]*tep_event_common_fields*(struct tep_event pass:[*]_event_);
71*4882a593Smuzhiyun	struct tep_format_field pass:[*]pass:[*]*tep_event_fields*(struct tep_event pass:[*]_event_);
72*4882a593Smuzhiyun	void pass:[*]*tep_get_field_raw*(struct trace_seq pass:[*]_s_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, int pass:[*]_len_, int _err_);
73*4882a593Smuzhiyun	int *tep_get_field_val*(struct trace_seq pass:[*]_s_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, unsigned long long pass:[*]_val_, int _err_);
74*4882a593Smuzhiyun	int *tep_get_common_field_val*(struct trace_seq pass:[*]_s_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, unsigned long long pass:[*]_val_, int _err_);
75*4882a593Smuzhiyun	int *tep_get_any_field_val*(struct trace_seq pass:[*]_s_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, unsigned long long pass:[*]_val_, int _err_);
76*4882a593Smuzhiyun	int *tep_read_number_field*(struct tep_format_field pass:[*]_field_, const void pass:[*]_data_, unsigned long long pass:[*]_value_);
77*4882a593Smuzhiyun
78*4882a593SmuzhiyunEvent fields printing:
79*4882a593Smuzhiyun	void *tep_print_field*(struct trace_seq pass:[*]_s_, void pass:[*]_data_, struct tep_format_field pass:[*]_field_);
80*4882a593Smuzhiyun	void *tep_print_fields*(struct trace_seq pass:[*]_s_, void pass:[*]_data_, int _size_, struct tep_event pass:[*]_event_);
81*4882a593Smuzhiyun	int *tep_print_num_field*(struct trace_seq pass:[*]_s_, const char pass:[*]_fmt_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, int _err_);
82*4882a593Smuzhiyun	int *tep_print_func_field*(struct trace_seq pass:[*]_s_, const char pass:[*]_fmt_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, int _err_);
83*4882a593Smuzhiyun
84*4882a593SmuzhiyunEvent fields finding:
85*4882a593Smuzhiyun	struct tep_format_field pass:[*]*tep_find_common_field*(struct tep_event pass:[*]_event_, const char pass:[*]_name_);
86*4882a593Smuzhiyun	struct tep_format_field pass:[*]*tep_find_field*(struct tep_event_ormat pass:[*]_event_, const char pass:[*]_name_);
87*4882a593Smuzhiyun	struct tep_format_field pass:[*]*tep_find_any_field*(struct tep_event pass:[*]_event_, const char pass:[*]_name_);
88*4882a593Smuzhiyun
89*4882a593SmuzhiyunFunctions resolver:
90*4882a593Smuzhiyun	int *tep_set_function_resolver*(struct tep_handle pass:[*]_tep_, tep_func_resolver_t pass:[*]_func_, void pass:[*]_priv_);
91*4882a593Smuzhiyun	void *tep_reset_function_resolver*(struct tep_handle pass:[*]_tep_);
92*4882a593Smuzhiyun	const char pass:[*]*tep_find_function*(struct tep_handle pass:[*]_tep_, unsigned long long _addr_);
93*4882a593Smuzhiyun	unsigned long long *tep_find_function_address*(struct tep_handle pass:[*]_tep_, unsigned long long _addr_);
94*4882a593Smuzhiyun
95*4882a593SmuzhiyunFilter management:
96*4882a593Smuzhiyun	struct tep_event_filter pass:[*]*tep_filter_alloc*(struct tep_handle pass:[*]_tep_);
97*4882a593Smuzhiyun	enum tep_errno *tep_filter_add_filter_str*(struct tep_event_filter pass:[*]_filter_, const char pass:[*]_filter_str_);
98*4882a593Smuzhiyun	enum tep_errno *tep_filter_match*(struct tep_event_filter pass:[*]_filter_, struct tep_record pass:[*]_record_);
99*4882a593Smuzhiyun	int *tep_filter_strerror*(struct tep_event_filter pass:[*]_filter_, enum tep_errno _err_, char pass:[*]buf, size_t _buflen_);
100*4882a593Smuzhiyun	int *tep_event_filtered*(struct tep_event_filter pass:[*]_filter_, int _event_id_);
101*4882a593Smuzhiyun	void *tep_filter_reset*(struct tep_event_filter pass:[*]_filter_);
102*4882a593Smuzhiyun	void *tep_filter_free*(struct tep_event_filter pass:[*]_filter_);
103*4882a593Smuzhiyun	char pass:[*]*tep_filter_make_string*(struct tep_event_filter pass:[*]_filter_, int _event_id_);
104*4882a593Smuzhiyun	int *tep_filter_remove_event*(struct tep_event_filter pass:[*]_filter_, int _event_id_);
105*4882a593Smuzhiyun	int *tep_filter_copy*(struct tep_event_filter pass:[*]_dest_, struct tep_event_filter pass:[*]_source_);
106*4882a593Smuzhiyun	int *tep_filter_compare*(struct tep_event_filter pass:[*]_filter1_, struct tep_event_filter pass:[*]_filter2_);
107*4882a593Smuzhiyun
108*4882a593SmuzhiyunParsing various data from the records:
109*4882a593Smuzhiyun	int *tep_data_type*(struct tep_handle pass:[*]_tep_, struct tep_record pass:[*]_rec_);
110*4882a593Smuzhiyun	int *tep_data_pid*(struct tep_handle pass:[*]_tep_, struct tep_record pass:[*]_rec_);
111*4882a593Smuzhiyun	int *tep_data_preempt_count*(struct tep_handle pass:[*]_tep_, struct tep_record pass:[*]_rec_);
112*4882a593Smuzhiyun	int *tep_data_flags*(struct tep_handle pass:[*]_tep_, struct tep_record pass:[*]_rec_);
113*4882a593Smuzhiyun
114*4882a593SmuzhiyunCommand and task related APIs:
115*4882a593Smuzhiyun	const char pass:[*]*tep_data_comm_from_pid*(struct tep_handle pass:[*]_tep_, int _pid_);
116*4882a593Smuzhiyun	struct cmdline pass:[*]*tep_data_pid_from_comm*(struct tep_handle pass:[*]_tep_, const char pass:[*]_comm_, struct cmdline pass:[*]_next_);
117*4882a593Smuzhiyun	int *tep_register_comm*(struct tep_handle pass:[*]_tep_, const char pass:[*]_comm_, int _pid_);
118*4882a593Smuzhiyun	int *tep_override_comm*(struct tep_handle pass:[*]_tep_, const char pass:[*]_comm_, int _pid_);
119*4882a593Smuzhiyun	bool *tep_is_pid_registered*(struct tep_handle pass:[*]_tep_, int _pid_);
120*4882a593Smuzhiyun	int *tep_cmdline_pid*(struct tep_handle pass:[*]_tep_, struct cmdline pass:[*]_cmdline_);
121*4882a593Smuzhiyun
122*4882a593SmuzhiyunEndian related APIs:
123*4882a593Smuzhiyun	int *tep_is_bigendian*(void);
124*4882a593Smuzhiyun	unsigned long long *tep_read_number*(struct tep_handle pass:[*]_tep_, const void pass:[*]_ptr_, int _size_);
125*4882a593Smuzhiyun	bool *tep_is_file_bigendian*(struct tep_handle pass:[*]_tep_);
126*4882a593Smuzhiyun	void *tep_set_file_bigendian*(struct tep_handle pass:[*]_tep_, enum tep_endian _endian_);
127*4882a593Smuzhiyun	bool *tep_is_local_bigendian*(struct tep_handle pass:[*]_tep_);
128*4882a593Smuzhiyun	void *tep_set_local_bigendian*(struct tep_handle pass:[*]_tep_, enum tep_endian _endian_);
129*4882a593Smuzhiyun
130*4882a593SmuzhiyunTrace sequences:
131*4882a593Smuzhiyun*#include <trace-seq.h>*
132*4882a593Smuzhiyun	void *trace_seq_init*(struct trace_seq pass:[*]_s_);
133*4882a593Smuzhiyun	void *trace_seq_reset*(struct trace_seq pass:[*]_s_);
134*4882a593Smuzhiyun	void *trace_seq_destroy*(struct trace_seq pass:[*]_s_);
135*4882a593Smuzhiyun	int *trace_seq_printf*(struct trace_seq pass:[*]_s_, const char pass:[*]_fmt_, ...);
136*4882a593Smuzhiyun	int *trace_seq_vprintf*(struct trace_seq pass:[*]_s_, const char pass:[*]_fmt_, va_list _args_);
137*4882a593Smuzhiyun	int *trace_seq_puts*(struct trace_seq pass:[*]_s_, const char pass:[*]_str_);
138*4882a593Smuzhiyun	int *trace_seq_putc*(struct trace_seq pass:[*]_s_, unsigned char _c_);
139*4882a593Smuzhiyun	void *trace_seq_terminate*(struct trace_seq pass:[*]_s_);
140*4882a593Smuzhiyun	int *trace_seq_do_fprintf*(struct trace_seq pass:[*]_s_, FILE pass:[*]_fp_);
141*4882a593Smuzhiyun	int *trace_seq_do_printf*(struct trace_seq pass:[*]_s_);
142*4882a593Smuzhiyun--
143*4882a593Smuzhiyun
144*4882a593SmuzhiyunDESCRIPTION
145*4882a593Smuzhiyun-----------
146*4882a593SmuzhiyunThe libtraceevent(3) library provides APIs to access kernel tracepoint events,
147*4882a593Smuzhiyunlocated in the tracefs file system under the events directory.
148*4882a593Smuzhiyun
149*4882a593SmuzhiyunENVIRONMENT
150*4882a593Smuzhiyun-----------
151*4882a593Smuzhiyun[verse]
152*4882a593Smuzhiyun--
153*4882a593SmuzhiyunTRACEEVENT_PLUGIN_DIR
154*4882a593Smuzhiyun	Additional plugin directory. All shared object files, located in this directory will be loaded as traceevent plugins.
155*4882a593Smuzhiyun--
156*4882a593Smuzhiyun
157*4882a593SmuzhiyunFILES
158*4882a593Smuzhiyun-----
159*4882a593Smuzhiyun[verse]
160*4882a593Smuzhiyun--
161*4882a593Smuzhiyun*event-parse.h*
162*4882a593Smuzhiyun	Header file to include in order to have access to the library APIs.
163*4882a593Smuzhiyun*trace-seq.h*
164*4882a593Smuzhiyun	Header file to include in order to have access to trace sequences related APIs.
165*4882a593Smuzhiyun	Trace sequences are used to allow a function to call several other functions
166*4882a593Smuzhiyun	to create a string of data to use.
167*4882a593Smuzhiyun*-ltraceevent*
168*4882a593Smuzhiyun	Linker switch to add when building a program that uses the library.
169*4882a593Smuzhiyun--
170*4882a593Smuzhiyun
171*4882a593SmuzhiyunSEE ALSO
172*4882a593Smuzhiyun--------
173*4882a593Smuzhiyun_trace-cmd(1)_
174*4882a593Smuzhiyun
175*4882a593SmuzhiyunAUTHOR
176*4882a593Smuzhiyun------
177*4882a593Smuzhiyun[verse]
178*4882a593Smuzhiyun--
179*4882a593Smuzhiyun*Steven Rostedt* <rostedt@goodmis.org>, author of *libtraceevent*.
180*4882a593Smuzhiyun*Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>, author of this man page.
181*4882a593Smuzhiyun--
182*4882a593SmuzhiyunREPORTING BUGS
183*4882a593Smuzhiyun--------------
184*4882a593SmuzhiyunReport bugs to  <linux-trace-devel@vger.kernel.org>
185*4882a593Smuzhiyun
186*4882a593SmuzhiyunLICENSE
187*4882a593Smuzhiyun-------
188*4882a593Smuzhiyunlibtraceevent is Free Software licensed under the GNU LGPL 2.1
189*4882a593Smuzhiyun
190*4882a593SmuzhiyunRESOURCES
191*4882a593Smuzhiyun---------
192*4882a593Smuzhiyunhttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
193