1*4882a593Smuzhiyunlibtraceevent(3) 2*4882a593Smuzhiyun================ 3*4882a593Smuzhiyun 4*4882a593SmuzhiyunNAME 5*4882a593Smuzhiyun---- 6*4882a593Smuzhiyuntep_get_any_field_val, tep_get_common_field_val, tep_get_field_val, 7*4882a593Smuzhiyuntep_get_field_raw - Get value of a field. 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*4882a593Smuzhiyunint *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_); 17*4882a593Smuzhiyunint *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_); 18*4882a593Smuzhiyunint *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_); 19*4882a593Smuzhiyunvoid 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_); 20*4882a593Smuzhiyun-- 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunDESCRIPTION 23*4882a593Smuzhiyun----------- 24*4882a593SmuzhiyunThese functions can be used to find a field and retrieve its value. 25*4882a593Smuzhiyun 26*4882a593SmuzhiyunThe _tep_get_any_field_val()_ function searches in the _record_ for a field 27*4882a593Smuzhiyunwith _name_, part of the _event_. If the field is found, its value is stored in 28*4882a593Smuzhiyun_val_. If there is an error and _err_ is not zero, then an error string is 29*4882a593Smuzhiyunwritten into _s_. 30*4882a593Smuzhiyun 31*4882a593SmuzhiyunThe _tep_get_common_field_val()_ function does the same as 32*4882a593Smuzhiyun_tep_get_any_field_val()_, but searches only in the common fields. This works 33*4882a593Smuzhiyunfor any event as all events include the common fields. 34*4882a593Smuzhiyun 35*4882a593SmuzhiyunThe _tep_get_field_val()_ function does the same as _tep_get_any_field_val()_, 36*4882a593Smuzhiyunbut searches only in the event specific fields. 37*4882a593Smuzhiyun 38*4882a593SmuzhiyunThe _tep_get_field_raw()_ function searches in the _record_ for a field with 39*4882a593Smuzhiyun_name_, part of the _event_. If the field is found, a pointer to where the field 40*4882a593Smuzhiyunexists in the record's raw data is returned. The size of the data is stored in 41*4882a593Smuzhiyun_len_. If there is an error and _err_ is not zero, then an error string is 42*4882a593Smuzhiyunwritten into _s_. 43*4882a593Smuzhiyun 44*4882a593SmuzhiyunRETURN VALUE 45*4882a593Smuzhiyun------------ 46*4882a593SmuzhiyunThe _tep_get_any_field_val()_, _tep_get_common_field_val()_ and 47*4882a593Smuzhiyun_tep_get_field_val()_ functions return 0 on success, or -1 in case of an error. 48*4882a593Smuzhiyun 49*4882a593SmuzhiyunThe _tep_get_field_raw()_ function returns a pointer to field's raw data, and 50*4882a593Smuzhiyunplaces the length of this data in _len_. In case of an error NULL is returned. 51*4882a593Smuzhiyun 52*4882a593SmuzhiyunEXAMPLE 53*4882a593Smuzhiyun------- 54*4882a593Smuzhiyun[source,c] 55*4882a593Smuzhiyun-- 56*4882a593Smuzhiyun#include <event-parse.h> 57*4882a593Smuzhiyun#include <trace-seq.h> 58*4882a593Smuzhiyun... 59*4882a593Smuzhiyunstruct tep_handle *tep = tep_alloc(); 60*4882a593Smuzhiyun... 61*4882a593Smuzhiyunstruct tep_event *event = tep_find_event_by_name(tep, "kvm", "kvm_exit"); 62*4882a593Smuzhiyun... 63*4882a593Smuzhiyunvoid process_record(struct tep_record *record) 64*4882a593Smuzhiyun{ 65*4882a593Smuzhiyun int len; 66*4882a593Smuzhiyun char *comm; 67*4882a593Smuzhiyun struct tep_event_format *event; 68*4882a593Smuzhiyun unsigned long long val; 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun event = tep_find_event_by_record(pevent, record); 71*4882a593Smuzhiyun if (event != NULL) { 72*4882a593Smuzhiyun if (tep_get_common_field_val(NULL, event, "common_type", 73*4882a593Smuzhiyun record, &val, 0) == 0) { 74*4882a593Smuzhiyun /* Got the value of common type field */ 75*4882a593Smuzhiyun } 76*4882a593Smuzhiyun if (tep_get_field_val(NULL, event, "pid", record, &val, 0) == 0) { 77*4882a593Smuzhiyun /* Got the value of pid specific field */ 78*4882a593Smuzhiyun } 79*4882a593Smuzhiyun comm = tep_get_field_raw(NULL, event, "comm", record, &len, 0); 80*4882a593Smuzhiyun if (comm != NULL) { 81*4882a593Smuzhiyun /* Got a pointer to the comm event specific field */ 82*4882a593Smuzhiyun } 83*4882a593Smuzhiyun } 84*4882a593Smuzhiyun} 85*4882a593Smuzhiyun-- 86*4882a593Smuzhiyun 87*4882a593SmuzhiyunFILES 88*4882a593Smuzhiyun----- 89*4882a593Smuzhiyun[verse] 90*4882a593Smuzhiyun-- 91*4882a593Smuzhiyun*event-parse.h* 92*4882a593Smuzhiyun Header file to include in order to have access to the library APIs. 93*4882a593Smuzhiyun*trace-seq.h* 94*4882a593Smuzhiyun Header file to include in order to have access to trace sequences 95*4882a593Smuzhiyun related APIs. Trace sequences are used to allow a function to call 96*4882a593Smuzhiyun several other functions to create a string of data to use. 97*4882a593Smuzhiyun*-ltraceevent* 98*4882a593Smuzhiyun Linker switch to add when building a program that uses the library. 99*4882a593Smuzhiyun-- 100*4882a593Smuzhiyun 101*4882a593SmuzhiyunSEE ALSO 102*4882a593Smuzhiyun-------- 103*4882a593Smuzhiyun_libtraceevent(3)_, _trace-cmd(1)_ 104*4882a593Smuzhiyun 105*4882a593SmuzhiyunAUTHOR 106*4882a593Smuzhiyun------ 107*4882a593Smuzhiyun[verse] 108*4882a593Smuzhiyun-- 109*4882a593Smuzhiyun*Steven Rostedt* <rostedt@goodmis.org>, author of *libtraceevent*. 110*4882a593Smuzhiyun*Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>, author of this man page. 111*4882a593Smuzhiyun-- 112*4882a593SmuzhiyunREPORTING BUGS 113*4882a593Smuzhiyun-------------- 114*4882a593SmuzhiyunReport bugs to <linux-trace-devel@vger.kernel.org> 115*4882a593Smuzhiyun 116*4882a593SmuzhiyunLICENSE 117*4882a593Smuzhiyun------- 118*4882a593Smuzhiyunlibtraceevent is Free Software licensed under the GNU LGPL 2.1 119*4882a593Smuzhiyun 120*4882a593SmuzhiyunRESOURCES 121*4882a593Smuzhiyun--------- 122*4882a593Smuzhiyunhttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 123