1*4882a593Smuzhiyunlibtraceevent(3) 2*4882a593Smuzhiyun================ 3*4882a593Smuzhiyun 4*4882a593SmuzhiyunNAME 5*4882a593Smuzhiyun---- 6*4882a593Smuzhiyuntep_print_field, tep_print_fields, tep_print_num_field, tep_print_func_field - 7*4882a593SmuzhiyunPrint the field content. 8*4882a593Smuzhiyun 9*4882a593SmuzhiyunSYNOPSIS 10*4882a593Smuzhiyun-------- 11*4882a593Smuzhiyun[verse] 12*4882a593Smuzhiyun-- 13*4882a593Smuzhiyun*#include <event-parse.h>* 14*4882a593Smuzhiyun*#include <trace-seq.h>* 15*4882a593Smuzhiyun 16*4882a593Smuzhiyunvoid *tep_print_field*(struct trace_seq pass:[*]_s_, void pass:[*]_data_, struct tep_format_field pass:[*]_field_); 17*4882a593Smuzhiyunvoid *tep_print_fields*(struct trace_seq pass:[*]_s_, void pass:[*]_data_, int _size_, struct tep_event pass:[*]_event_); 18*4882a593Smuzhiyunint *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_); 19*4882a593Smuzhiyunint *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_); 20*4882a593Smuzhiyun-- 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunDESCRIPTION 23*4882a593Smuzhiyun----------- 24*4882a593SmuzhiyunThese functions print recorded field's data, according to the field's type. 25*4882a593Smuzhiyun 26*4882a593SmuzhiyunThe _tep_print_field()_ function extracts from the recorded raw _data_ value of 27*4882a593Smuzhiyunthe _field_ and prints it into _s_, according to the field type. 28*4882a593Smuzhiyun 29*4882a593SmuzhiyunThe _tep_print_fields()_ prints each field name followed by the record's field 30*4882a593Smuzhiyunvalue according to the field's type: 31*4882a593Smuzhiyun[verse] 32*4882a593Smuzhiyun-- 33*4882a593Smuzhiyun"field1_name=field1_value field2_name=field2_value ..." 34*4882a593Smuzhiyun-- 35*4882a593SmuzhiyunIt iterates all fields of the _event_, and calls _tep_print_field()_ for each of 36*4882a593Smuzhiyunthem. 37*4882a593Smuzhiyun 38*4882a593SmuzhiyunThe _tep_print_num_field()_ function prints a numeric field with given format 39*4882a593Smuzhiyunstring. A search is performed in the _event_ for a field with _name_. If such 40*4882a593Smuzhiyunfield is found, its value is extracted from the _record_ and is printed in the 41*4882a593Smuzhiyun_s_, according to the given format string _fmt_. If the argument _err_ is 42*4882a593Smuzhiyunnon-zero, and an error occures - it is printed in the _s_. 43*4882a593Smuzhiyun 44*4882a593SmuzhiyunThe _tep_print_func_field()_ function prints a function field with given format 45*4882a593Smuzhiyunstring. A search is performed in the _event_ for a field with _name_. If such 46*4882a593Smuzhiyunfield is found, its value is extracted from the _record_. The value is assumed 47*4882a593Smuzhiyunto be a function address, and a search is perform to find the name of this 48*4882a593Smuzhiyunfunction. The function name (if found) and its address are printed in the _s_, 49*4882a593Smuzhiyunaccording to the given format string _fmt_. If the argument _err_ is non-zero, 50*4882a593Smuzhiyunand an error occures - it is printed in _s_. 51*4882a593Smuzhiyun 52*4882a593SmuzhiyunRETURN VALUE 53*4882a593Smuzhiyun------------ 54*4882a593SmuzhiyunThe _tep_print_num_field()_ and _tep_print_func_field()_ functions return 1 55*4882a593Smuzhiyunon success, -1 in case of an error or 0 if the print buffer _s_ is full. 56*4882a593Smuzhiyun 57*4882a593SmuzhiyunEXAMPLE 58*4882a593Smuzhiyun------- 59*4882a593Smuzhiyun[source,c] 60*4882a593Smuzhiyun-- 61*4882a593Smuzhiyun#include <event-parse.h> 62*4882a593Smuzhiyun#include <trace-seq.h> 63*4882a593Smuzhiyun... 64*4882a593Smuzhiyunstruct tep_handle *tep = tep_alloc(); 65*4882a593Smuzhiyun... 66*4882a593Smuzhiyunstruct trace_seq seq; 67*4882a593Smuzhiyuntrace_seq_init(&seq); 68*4882a593Smuzhiyunstruct tep_event *event = tep_find_event_by_name(tep, "timer", "hrtimer_start"); 69*4882a593Smuzhiyun... 70*4882a593Smuzhiyunvoid process_record(struct tep_record *record) 71*4882a593Smuzhiyun{ 72*4882a593Smuzhiyun struct tep_format_field *field_pid = tep_find_common_field(event, "common_pid"); 73*4882a593Smuzhiyun 74*4882a593Smuzhiyun trace_seq_reset(&seq); 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun /* Print the value of "common_pid" */ 77*4882a593Smuzhiyun tep_print_field(&seq, record->data, field_pid); 78*4882a593Smuzhiyun 79*4882a593Smuzhiyun /* Print all fields of the "hrtimer_start" event */ 80*4882a593Smuzhiyun tep_print_fields(&seq, record->data, record->size, event); 81*4882a593Smuzhiyun 82*4882a593Smuzhiyun /* Print the value of "expires" field with custom format string */ 83*4882a593Smuzhiyun tep_print_num_field(&seq, " timer expires in %llu ", event, "expires", record, 0); 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun /* Print the address and the name of "function" field with custom format string */ 86*4882a593Smuzhiyun tep_print_func_field(&seq, " timer function is %s ", event, "function", record, 0); 87*4882a593Smuzhiyun } 88*4882a593Smuzhiyun ... 89*4882a593Smuzhiyun-- 90*4882a593Smuzhiyun 91*4882a593SmuzhiyunFILES 92*4882a593Smuzhiyun----- 93*4882a593Smuzhiyun[verse] 94*4882a593Smuzhiyun-- 95*4882a593Smuzhiyun*event-parse.h* 96*4882a593Smuzhiyun Header file to include in order to have access to the library APIs. 97*4882a593Smuzhiyun*trace-seq.h* 98*4882a593Smuzhiyun Header file to include in order to have access to trace sequences related APIs. 99*4882a593Smuzhiyun Trace sequences are used to allow a function to call several other functions 100*4882a593Smuzhiyun to create a string of data to use. 101*4882a593Smuzhiyun*-ltraceevent* 102*4882a593Smuzhiyun Linker switch to add when building a program that uses the library. 103*4882a593Smuzhiyun-- 104*4882a593Smuzhiyun 105*4882a593SmuzhiyunSEE ALSO 106*4882a593Smuzhiyun-------- 107*4882a593Smuzhiyun_libtraceevent(3)_, _trace-cmd(1)_ 108*4882a593Smuzhiyun 109*4882a593SmuzhiyunAUTHOR 110*4882a593Smuzhiyun------ 111*4882a593Smuzhiyun[verse] 112*4882a593Smuzhiyun-- 113*4882a593Smuzhiyun*Steven Rostedt* <rostedt@goodmis.org>, author of *libtraceevent*. 114*4882a593Smuzhiyun*Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>, author of this man page. 115*4882a593Smuzhiyun-- 116*4882a593SmuzhiyunREPORTING BUGS 117*4882a593Smuzhiyun-------------- 118*4882a593SmuzhiyunReport bugs to <linux-trace-devel@vger.kernel.org> 119*4882a593Smuzhiyun 120*4882a593SmuzhiyunLICENSE 121*4882a593Smuzhiyun------- 122*4882a593Smuzhiyunlibtraceevent is Free Software licensed under the GNU LGPL 2.1 123*4882a593Smuzhiyun 124*4882a593SmuzhiyunRESOURCES 125*4882a593Smuzhiyun--------- 126*4882a593Smuzhiyunhttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 127