Back to home page

OSCL-LXR

 
 

    


0001 libtraceevent(3)
0002 ================
0003 
0004 NAME
0005 ----
0006 tep_find_common_field, tep_find_field, tep_find_any_field -
0007 Search for a field in an event.
0008 
0009 SYNOPSIS
0010 --------
0011 [verse]
0012 --
0013 *#include <event-parse.h>*
0014 
0015 struct tep_format_field pass:[*]*tep_find_common_field*(struct tep_event pass:[*]_event_, const char pass:[*]_name_);
0016 struct tep_format_field pass:[*]*tep_find_field*(struct tep_event_ormat pass:[*]_event_, const char pass:[*]_name_);
0017 struct tep_format_field pass:[*]*tep_find_any_field*(struct tep_event pass:[*]_event_, const char pass:[*]_name_);
0018 --
0019 
0020 DESCRIPTION
0021 -----------
0022 These functions search for a field with given name in an event. The field
0023 returned can be used to find the field content from within a data record.
0024 
0025 The _tep_find_common_field()_ function searches for a common field with _name_
0026 in the _event_.
0027 
0028 The _tep_find_field()_ function searches for an event specific field with
0029 _name_ in the _event_.
0030 
0031 The _tep_find_any_field()_ function searches for any field with _name_ in the
0032 _event_.
0033 
0034 RETURN VALUE
0035 ------------
0036 The _tep_find_common_field(), _tep_find_field()_ and _tep_find_any_field()_
0037 functions return a pointer to the found field, or NULL in case there is no field
0038 with the requested name.
0039 
0040 EXAMPLE
0041 -------
0042 [source,c]
0043 --
0044 #include <event-parse.h>
0045 ...
0046 void get_htimer_info(struct tep_handle *tep, struct tep_record *record)
0047 {
0048         struct tep_format_field *field;
0049         struct tep_event *event;
0050         long long softexpires;
0051         int mode;
0052         int pid;
0053 
0054         event = tep_find_event_by_name(tep, "timer", "hrtimer_start");
0055 
0056         field = tep_find_common_field(event, "common_pid");
0057         if (field == NULL) {
0058                 /* Cannot find "common_pid" field in the event */
0059         } else {
0060                 /* Get pid from the data record */
0061                 pid = tep_read_number(tep, record->data + field->offset,
0062                                       field->size);
0063         }
0064 
0065         field = tep_find_field(event, "softexpires");
0066         if (field == NULL) {
0067                 /* Cannot find "softexpires" event specific field in the event */
0068         } else {
0069                 /* Get softexpires parameter from the data record */
0070                 softexpires = tep_read_number(tep, record->data + field->offset,
0071                                               field->size);
0072         }
0073 
0074         field = tep_find_any_field(event, "mode");
0075         if (field == NULL) {
0076                 /* Cannot find "mode" field in the event */
0077         } else
0078         {
0079                 /* Get mode parameter from the data record */
0080                 mode = tep_read_number(tep, record->data + field->offset,
0081                                        field->size);
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 *-ltraceevent*
0094         Linker switch to add when building a program that uses the library.
0095 --
0096 
0097 SEE ALSO
0098 --------
0099 _libtraceevent(3)_, _trace-cmd(1)_
0100 
0101 AUTHOR
0102 ------
0103 [verse]
0104 --
0105 *Steven Rostedt* <rostedt@goodmis.org>, author of *libtraceevent*.
0106 *Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>, author of this man page.
0107 --
0108 REPORTING BUGS
0109 --------------
0110 Report bugs to  <linux-trace-devel@vger.kernel.org>
0111 
0112 LICENSE
0113 -------
0114 libtraceevent is Free Software licensed under the GNU LGPL 2.1
0115 
0116 RESOURCES
0117 ---------
0118 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git