1libtraceevent(3) 2================ 3 4NAME 5---- 6libtraceevent - Linux kernel trace event library 7 8SYNOPSIS 9-------- 10[verse] 11-- 12*#include <event-parse.h>* 13 14Management of tep handler data structure and access of its members: 15 struct tep_handle pass:[*]*tep_alloc*(void); 16 void *tep_free*(struct tep_handle pass:[*]_tep_); 17 void *tep_ref*(struct tep_handle pass:[*]_tep_); 18 void *tep_unref*(struct tep_handle pass:[*]_tep_); 19 int *tep_get_ref*(struct tep_handle pass:[*]_tep_); 20 void *tep_set_flag*(struct tep_handle pass:[*]_tep_, enum tep_flag _flag_); 21 void *tep_clear_flag*(struct tep_handle pass:[*]_tep_, enum tep_flag _flag_); 22 bool *tep_test_flag*(struct tep_handle pass:[*]_tep_, enum tep_flag _flags_); 23 int *tep_get_cpus*(struct tep_handle pass:[*]_tep_); 24 void *tep_set_cpus*(struct tep_handle pass:[*]_tep_, int _cpus_); 25 int *tep_get_long_size*(strucqt tep_handle pass:[*]_tep_); 26 void *tep_set_long_size*(struct tep_handle pass:[*]_tep_, int _long_size_); 27 int *tep_get_page_size*(struct tep_handle pass:[*]_tep_); 28 void *tep_set_page_size*(struct tep_handle pass:[*]_tep_, int _page_size_); 29 int *tep_get_sub_buffer_size*(struct tep_handle pass:[*]_tep_); 30 int *tep_get_sub_buffer_data_size*(struct tep_handle pass:[*]_tep_); 31 int *tep_get_sub_buffer_commit_offset*(struct tep_handle pass:[*]_tep_); 32 int *tep_get_header_page_size*(struct tep_handle pass:[*]_tep_); 33 int *tep_get_header_timestamp_size*(struct tep_handle pass:[*]_tep_); 34 bool *tep_is_old_format*(struct tep_handle pass:[*]_tep_); 35 int *tep_strerror*(struct tep_handle pass:[*]_tep_, enum tep_errno _errnum_, char pass:[*]_buf_, size_t _buflen_); 36 struct kbuffer pass:[*]*tep_kbuffer*(struct tep_handle pass:[*]_tep_); 37 38Register / unregister APIs: 39 int *tep_register_function*(struct tep_handle pass:[*]_tep_, char pass:[*]_name_, unsigned long long _addr_, char pass:[*]_mod_); 40 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_); 41 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_); 42 int *tep_register_print_string*(struct tep_handle pass:[*]_tep_, const char pass:[*]_fmt_, unsigned long long _addr_); 43 int *tep_register_print_function*(struct tep_handle pass:[*]_tep_, tep_func_handler _func_, enum tep_func_arg_type _ret_type_, char pass:[*]_name_, _..._); 44 int *tep_unregister_print_function*(struct tep_handle pass:[*]_tep_, tep_func_handler _func_, char pass:[*]_name_); 45 int *tep_get_function_count*(struct tep_handle *_tep_); 46 47Trace printk parsing: 48 void *tep_print_printk*(struct tep_handle pass:[*]tep); 49 void *tep_print_funcs*(struct tep_handle pass:[*]tep); 50 void *tep_set_test_filters*(struct tep_handle pass:[*]tep, int test_filters); 51 void *tep_plugin_print_options*(struct trace_seq pass:[*]s); 52 int *tep_plugin_add_option*(const char pass:[*]_name_, const char pass:[*]_val_); 53 54Meta data parsing: 55 int *tep_parse_saved_cmdlines*(struct tep_handle pass:[*]_tep_, const char pass:[*]_buf_); 56 int *tep_parse_printk_formats*(struct tep_handle pass:[*]_tep_, const char pass:[*]_buf_); 57 int *tep_parse_kallsyms*(struct tep_handle pass:[*]_tep_, const char pass:[*]_buf_); 58 59Plugins management: 60 struct tep_plugin_list pass:[*]*tep_load_plugins*(struct tep_handle pass:[*]_tep_); 61 void *tep_unload_plugins*(struct tep_plugin_list pass:[*]_plugin_list_, struct tep_handle pass:[*]_tep_); 62 char pass:[*]pass:[*]*tep_plugin_list_options*(void); 63 void *tep_plugin_free_options_list*(char pass:[*]pass:[*]_list_); 64 int *tep_plugin_add_options*(const char pass:[*]_name_, struct tep_plugin_option pass:[*]_options_); 65 void *tep_plugin_remove_options*(struct tep_plugin_option pass:[*]_options_); 66 void *tep_print_plugins*(struct trace_seq pass:[*]_s_, const char pass:[*]_prefix_, const char pass:[*]_suffix_, const struct tep_plugin_list pass:[*]_list_); 67 void *tep_load_plugins_hook*(struct tep_handle pass:[*]_tep_, const char pass:[*]_suffix_, 68 void (pass:[*]_load_plugin_)(struct tep_handle pass:[*]tep, 69 const char pass:[*]path, 70 const char pass:[*]name, 71 void pass:[*]data), 72 void pass:[*]_data_); 73 int *tep_add_plugin_path*(struct tep_handle pass:[*]tep, char pass:[*]path, 74 enum tep_plugin_load_priority prio); 75 76Event related APIs: 77 struct tep_event pass:[*]*tep_get_event*(struct tep_handle pass:[*]_tep_, int _index_); 78 struct tep_event pass:[*]*tep_get_first_event*(struct tep_handle pass:[*]_tep_); 79 int *tep_get_events_count*(struct tep_handle pass:[*]_tep_); 80 struct tep_event pass:[*]pass:[*]*tep_list_events*(struct tep_handle pass:[*]_tep_, enum tep_event_sort_type _sort_type_); 81 struct tep_event pass:[*]pass:[*]*tep_list_events_copy*(struct tep_handle pass:[*]_tep_, enum tep_event_sort_type _sort_type_); 82 void *tep_print_event*(struct tep_handle pass:[*]_tep_, struct trace_seq pass:[*]_s_, struct tep_record pass:[*]_record_, const char pass:[*]_fmt_, _..._); 83 84Event finding: 85 struct tep_event pass:[*]*tep_find_event*(struct tep_handle pass:[*]_tep_, int _id_); 86 struct tep_event pass:[*]*tep_find_event_by_name*(struct tep_handle pass:[*]_tep_, const char pass:[*]_sys_, const char pass:[*]_name_); 87 struct tep_event pass:[*]*tep_find_event_by_record*(struct tep_handle pass:[*]_tep_, struct tep_record pass:[*]_record_); 88 bool *tep_record_is_event*(struct tep_record pass:[*]record, struct tep_event pass:[*]event); 89 90Parsing of event files: 91 int *tep_parse_header_page*(struct tep_handle pass:[*]_tep_, char pass:[*]_buf_, unsigned long _size_, int _long_size_); 92 enum tep_errno *tep_parse_event*(struct tep_handle pass:[*]_tep_, const char pass:[*]_buf_, unsigned long _size_, const char pass:[*]_sys_); 93 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_); 94 95APIs related to fields from event's format files: 96 struct tep_format_field pass:[*]pass:[*]*tep_event_common_fields*(struct tep_event pass:[*]_event_); 97 struct tep_format_field pass:[*]pass:[*]*tep_event_fields*(struct tep_event pass:[*]_event_); 98 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_); 99 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_); 100 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_); 101 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_); 102 int *tep_read_number_field*(struct tep_format_field pass:[*]_field_, const void pass:[*]_data_, unsigned long long pass:[*]_value_); 103 104Event fields printing: 105 void *tep_print_field_content*(struct trace_seq pass:[*]_s_, void pass:[*]_data_, int size, struct tep_format_field pass:[*]_field_); 106 void *tep_print_fields*(struct trace_seq pass:[*]_s_, void pass:[*]_data_, int _size_, struct tep_event pass:[*]_event_); 107 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_); 108 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_); 109 void *tep_record_print_fields*(struct trace_seq pass:[*]_s_, struct tep_record pass:[*]_record_, struct tep_event pass:[*]_event_); 110 void *tep_record_print_selected_fields*(struct trace_seq pass:[*]_s_, struct tep_record pass:[*]_record_, struct tep_event pass:[*]_event_, int _select_mask_); 111 112Event fields finding: 113 struct tep_format_field pass:[*]*tep_find_common_field*(struct tep_event pass:[*]_event_, const char pass:[*]_name_); 114 struct tep_format_field pass:[*]*tep_find_field*(struct tep_event_ormat pass:[*]_event_, const char pass:[*]_name_); 115 struct tep_format_field pass:[*]*tep_find_any_field*(struct tep_event pass:[*]_event_, const char pass:[*]_name_); 116 117Functions resolver: 118 int *tep_set_function_resolver*(struct tep_handle pass:[*]_tep_, tep_func_resolver_t pass:[*]_func_, void pass:[*]_priv_); 119 void *tep_reset_function_resolver*(struct tep_handle pass:[*]_tep_); 120 const char pass:[*]*tep_find_function*(struct tep_handle pass:[*]_tep_, unsigned long long _addr_); 121 unsigned long long *tep_find_function_address*(struct tep_handle pass:[*]_tep_, unsigned long long _addr_); 122 int *tep_find_function_info*(struct tep_handle pass:[*]_tep_, unsigned long long _addr_, const char pass:[**]_name_, 123 unsigned long long pass:[*]_start_, unsigned long pass:[*]_size_); 124 125Filter management: 126 struct tep_event_filter pass:[*]*tep_filter_alloc*(struct tep_handle pass:[*]_tep_); 127 enum tep_errno *tep_filter_add_filter_str*(struct tep_event_filter pass:[*]_filter_, const char pass:[*]_filter_str_); 128 enum tep_errno *tep_filter_match*(struct tep_event_filter pass:[*]_filter_, struct tep_record pass:[*]_record_); 129 int *tep_filter_strerror*(struct tep_event_filter pass:[*]_filter_, enum tep_errno _err_, char pass:[*]buf, size_t _buflen_); 130 int *tep_event_filtered*(struct tep_event_filter pass:[*]_filter_, int _event_id_); 131 void *tep_filter_reset*(struct tep_event_filter pass:[*]_filter_); 132 void *tep_filter_free*(struct tep_event_filter pass:[*]_filter_); 133 char pass:[*]*tep_filter_make_string*(struct tep_event_filter pass:[*]_filter_, int _event_id_); 134 int *tep_filter_remove_event*(struct tep_event_filter pass:[*]_filter_, int _event_id_); 135 int *tep_filter_copy*(struct tep_event_filter pass:[*]_dest_, struct tep_event_filter pass:[*]_source_); 136 int *tep_filter_compare*(struct tep_event_filter pass:[*]_filter1_, struct tep_event_filter pass:[*]_filter2_); 137 138Parsing various data from the records: 139 int *tep_data_type*(struct tep_handle pass:[*]_tep_, struct tep_record pass:[*]_rec_); 140 int *tep_data_pid*(struct tep_handle pass:[*]_tep_, struct tep_record pass:[*]_rec_); 141 int *tep_data_preempt_count*(struct tep_handle pass:[*]_tep_, struct tep_record pass:[*]_rec_); 142 int *tep_data_flags*(struct tep_handle pass:[*]_tep_, struct tep_record pass:[*]_rec_); 143 144Command and task related APIs: 145 const char pass:[*]*tep_data_comm_from_pid*(struct tep_handle pass:[*]_tep_, int _pid_); 146 struct cmdline pass:[*]*tep_data_pid_from_comm*(struct tep_handle pass:[*]_tep_, const char pass:[*]_comm_, struct cmdline pass:[*]_next_); 147 int *tep_register_comm*(struct tep_handle pass:[*]_tep_, const char pass:[*]_comm_, int _pid_); 148 int *tep_override_comm*(struct tep_handle pass:[*]_tep_, const char pass:[*]_comm_, int _pid_); 149 bool *tep_is_pid_registered*(struct tep_handle pass:[*]_tep_, int _pid_); 150 int *tep_cmdline_pid*(struct tep_handle pass:[*]_tep_, struct cmdline pass:[*]_cmdline_); 151 152Endian related APIs: 153 int *tep_is_bigendian*(void); 154 unsigned long long *tep_read_number*(struct tep_handle pass:[*]_tep_, const void pass:[*]_ptr_, int _size_); 155 bool *tep_is_file_bigendian*(struct tep_handle pass:[*]_tep_); 156 void *tep_set_file_bigendian*(struct tep_handle pass:[*]_tep_, enum tep_endian _endian_); 157 bool *tep_is_local_bigendian*(struct tep_handle pass:[*]_tep_); 158 void *tep_set_local_bigendian*(struct tep_handle pass:[*]_tep_, enum tep_endian _endian_); 159 160Control library logs: 161 int *tep_set_loglevel*(enum tep_loglevel _level_); 162 163KVM plugin calllbacks: (Defined by the application and complied with -rdynamic) 164 const char pass:[*]*tep_plugin_kvm_get_func*(struct tep_event pass:[*]event, 165 struct tep_record pass:[*]record, 166 unsigned long long pass:[*]paddr); 167 void *tep_plugin_kvm_put_func*(const char pass:[*]func); 168 169Trace sequences: 170*#include <trace-seq.h>* 171 void *trace_seq_init*(struct trace_seq pass:[*]_s_); 172 void *trace_seq_reset*(struct trace_seq pass:[*]_s_); 173 void *trace_seq_destroy*(struct trace_seq pass:[*]_s_); 174 int *trace_seq_printf*(struct trace_seq pass:[*]_s_, const char pass:[*]_fmt_, ...); 175 int *trace_seq_vprintf*(struct trace_seq pass:[*]_s_, const char pass:[*]_fmt_, va_list _args_); 176 int *trace_seq_puts*(struct trace_seq pass:[*]_s_, const char pass:[*]_str_); 177 int *trace_seq_putc*(struct trace_seq pass:[*]_s_, unsigned char _c_); 178 void *trace_seq_terminate*(struct trace_seq pass:[*]_s_); 179 int *trace_seq_do_fprintf*(struct trace_seq pass:[*]_s_, FILE pass:[*]_fp_); 180 int *trace_seq_do_printf*(struct trace_seq pass:[*]_s_); 181 182kbuffer parsing: 183#include <kbuffer.h> 184 struct kbuffer pass:[*]*kbuffer_alloc*(enum kbuffer_long_size _size_, enum kbuffer_endian _endian_); 185 struct kbuffer pass:[*]*kbuffer_dup*(struct kbuffer pass:[*]_kbuf_); 186 void *kbuffer_free*(struct kbuffer pass:[*]_kbuf_); 187 int *kbuffer_load_subbuffer*(struct kbuffer pass:[*]_kbuf_, void pass:[*]_subbuffer_); 188 int *kbuffer_subbuffer_size*(struct kbuffer pass:[*]_kbuf); 189 void pass:[*]*kbuffer_subbuffer*(struct kbuffer pass:[*]_kbuf); 190 int *kbuffer_refresh*(struct kbuffer pass:[*]_kbuf_); 191 int *kbuffer_start_of_data*(struct kbuffer pass:[*]_kbuf_); 192 unsigned long long *kbuffer_timestamp*(struct kbuffer pass:[*]_kbuf_); 193 unsigned long long *kbuffer_subbuf_timestamp*(struct kbuffer pass:[*]_kbuf_, void pass:[*]_subbuf_); 194 void pass:[*]*kbuffer_read_event*(struct kbuffer pass:[*]_kbuf_, unsigned long long pass:[*]_ts_); 195 void pass:[*]*kbuffer_next_event*(struct kbuffer pass:[*]_kbuf_, unsigned long long pass:[*]_ts_); 196 void pass:[*]*kbuffer_read_at_offset*(struct kbuffer pass:[*]_kbuf_, int _offset_, unsigned long long pass:[*]_ts_); 197 int *kbuffer_missed_events*(struct kbuffer pass:[*]_kbuf_); 198 int *kbuffer_event_size*(struct kbuffer pass:[*]_kbuf_); 199 int *kbuffer_curr_size*(struct kbuffer pass:[*]_kbuf_); 200 int *kbuffer_curr_offset*(struct kbuffer pass:[*]_kbuf_); 201 int *kbuffer_curr_index*(struct kbuffer pass:[*]_kbuf_); 202 int *kbuffer_read_buffer*(struct kbuffer pass:[*]_kbuf_, void pass:[*]_buffer_, int _start_, int _len_); 203-- 204 205DESCRIPTION 206----------- 207The libtraceevent(3) library provides APIs to access kernel tracepoint events, 208located in the tracefs file system under the events directory. 209 210ENVIRONMENT 211----------- 212[verse] 213-- 214TRACEEVENT_PLUGIN_DIR 215 Additional plugin directory. All shared object files, located in this directory will be loaded as traceevent plugins. 216-- 217 218FILES 219----- 220[verse] 221-- 222*event-parse.h* 223 Header file to include in order to have access to the library APIs. 224*trace-seq.h* 225 Header file to include in order to have access to trace sequences related APIs. 226 Trace sequences are used to allow a function to call several other functions 227 to create a string of data to use. 228*-ltraceevent* 229 Linker switch to add when building a program that uses the library. 230-- 231 232SEE ALSO 233-------- 234*trace-cmd*(1) 235 236AUTHOR 237------ 238[verse] 239-- 240*Steven Rostedt* <rostedt@goodmis.org>, author of *libtraceevent*. 241*Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>, author of this man page. 242-- 243REPORTING BUGS 244-------------- 245Report bugs to <linux-trace-devel@vger.kernel.org> 246 247LICENSE 248------- 249libtraceevent is Free Software licensed under the GNU LGPL 2.1 250 251RESOURCES 252--------- 253https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/ 254