Back to home page

OSCL-LXR

 
 

    


0001 libtraceevent(3)
0002 ================
0003 
0004 NAME
0005 ----
0006 tep_get_any_field_val, tep_get_common_field_val, tep_get_field_val,
0007 tep_get_field_raw - Get value of a field.
0008 
0009 SYNOPSIS
0010 --------
0011 [verse]
0012 --
0013 *#include <event-parse.h>*
0014 *#include <trace-seq.h>*
0015 
0016 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_);
0017 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_);
0018 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_);
0019 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_);
0020 --
0021 
0022 DESCRIPTION
0023 -----------
0024 These functions can be used to find a field and retrieve its value.
0025 
0026 The _tep_get_any_field_val()_ function searches in the _record_ for a field
0027 with _name_, part of the _event_. If the field is found, its value is stored in
0028 _val_. If there is an error and _err_ is not zero, then an error string is
0029 written into _s_.
0030 
0031 The _tep_get_common_field_val()_ function does the same as
0032 _tep_get_any_field_val()_, but searches only in the common fields. This works
0033 for any event as all events include the common fields.
0034 
0035 The _tep_get_field_val()_ function does the same as _tep_get_any_field_val()_,
0036 but searches only in the event specific fields.
0037 
0038 The _tep_get_field_raw()_ function searches in the _record_ for a field with
0039 _name_, part of the _event_. If the field is found, a pointer to where the field
0040 exists in the record's raw data is returned. The size of the data is stored in
0041 _len_. If there is an error and _err_ is not zero, then an error string is
0042 written into _s_.
0043 
0044 RETURN VALUE
0045 ------------
0046 The _tep_get_any_field_val()_, _tep_get_common_field_val()_ and
0047 _tep_get_field_val()_ functions return 0 on success, or -1 in case of an error.
0048 
0049 The _tep_get_field_raw()_ function returns a pointer to field's raw data, and
0050 places the length of this data in _len_. In case of an error NULL is returned.
0051 
0052 EXAMPLE
0053 -------
0054 [source,c]
0055 --
0056 #include <event-parse.h>
0057 #include <trace-seq.h>
0058 ...
0059 struct tep_handle *tep = tep_alloc();
0060 ...
0061 struct tep_event *event = tep_find_event_by_name(tep, "kvm", "kvm_exit");
0062 ...
0063 void process_record(struct tep_record *record)
0064 {
0065         int len;
0066         char *comm;
0067         struct tep_event_format *event;
0068         unsigned long long val;
0069 
0070         event = tep_find_event_by_record(pevent, record);
0071         if (event != NULL) {
0072                 if (tep_get_common_field_val(NULL, event, "common_type",
0073                                              record, &val, 0) == 0) {
0074                         /* Got the value of common type field */
0075                 }
0076                 if (tep_get_field_val(NULL, event, "pid", record, &val, 0) == 0) {
0077                         /* Got the value of pid specific field */
0078                 }
0079                 comm = tep_get_field_raw(NULL, event, "comm", record, &len, 0);
0080                 if (comm != NULL) {
0081                         /* Got a pointer to the comm event specific field */
0082                 }
0083         }
0084 }
0085 --
0086 
0087 FILES
0088 -----
0089 [verse]
0090 --
0091 *event-parse.h*
0092         Header file to include in order to have access to the library APIs.
0093 *trace-seq.h*
0094         Header file to include in order to have access to trace sequences
0095         related APIs. Trace sequences are used to allow a function to call
0096         several other functions to create a string of data to use.
0097 *-ltraceevent*
0098         Linker switch to add when building a program that uses the library.
0099 --
0100 
0101 SEE ALSO
0102 --------
0103 _libtraceevent(3)_, _trace-cmd(1)_
0104 
0105 AUTHOR
0106 ------
0107 [verse]
0108 --
0109 *Steven Rostedt* <rostedt@goodmis.org>, author of *libtraceevent*.
0110 *Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>, author of this man page.
0111 --
0112 REPORTING BUGS
0113 --------------
0114 Report bugs to  <linux-trace-devel@vger.kernel.org>
0115 
0116 LICENSE
0117 -------
0118 libtraceevent is Free Software licensed under the GNU LGPL 2.1
0119 
0120 RESOURCES
0121 ---------
0122 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git