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