1LIBTRACEEVENT(3)             libtraceevent Manual             LIBTRACEEVENT(3)
2
3
4

NAME

6       tep_find_common_field, tep_find_field, tep_find_any_field - Search for
7       a field in an event.
8

SYNOPSIS

10       #include <event-parse.h>
11
12       struct tep_format_field *tep_find_common_field(struct tep_event *event, const char *name);
13       struct tep_format_field *tep_find_field(struct tep_event_ormat *event, const char *name);
14       struct tep_format_field *tep_find_any_field(struct tep_event *event, const char *name);
15

DESCRIPTION

17       These functions search for a field with given name in an event. The
18       field returned can be used to find the field content from within a data
19       record.
20
21       The tep_find_common_field() function searches for a common field with
22       name in the event.
23
24       The tep_find_field() function searches for an event specific field with
25       name in the event.
26
27       The tep_find_any_field() function searches for any field with name in
28       the event.
29

RETURN VALUE

31       The tep_find_common_field(), tep_find_field() and _tep_find_any_field()
32       functions return a pointer to the found field, or NULL in case there is
33       no field with the requested name.
34

EXAMPLE

36           #include <event-parse.h>
37           ...
38           void get_htimer_info(struct tep_handle *tep, struct tep_record *record)
39           {
40                   struct tep_format_field *field;
41                   struct tep_event *event;
42                   long long softexpires;
43                   int mode;
44                   int pid;
45
46                   event = tep_find_event_by_name(tep, "timer", "hrtimer_start");
47
48                   field = tep_find_common_field(event, "common_pid");
49                   if (field == NULL) {
50                           /* Cannot find "common_pid" field in the event */
51                   } else {
52                           /* Get pid from the data record */
53                           pid = tep_read_number(tep, record->data + field->offset,
54                                                 field->size);
55                   }
56
57                   field = tep_find_field(event, "softexpires");
58                   if (field == NULL) {
59                           /* Cannot find "softexpires" event specific field in the event */
60                   } else {
61                           /* Get softexpires parameter from the data record */
62                           softexpires = tep_read_number(tep, record->data + field->offset,
63                                                         field->size);
64                   }
65
66                   field = tep_find_any_field(event, "mode");
67                   if (field == NULL) {
68                           /* Cannot find "mode" field in the event */
69                   } else
70                   {
71                           /* Get mode parameter from the data record */
72                           mode = tep_read_number(tep, record->data + field->offset,
73                                                  field->size);
74                   }
75           }
76           ...
77

FILES

79           event-parse.h
80                   Header file to include in order to have access to the library APIs.
81           -ltraceevent
82                   Linker switch to add when building a program that uses the library.
83

SEE ALSO

85       libtraceevent(3), trace-cmd(1)
86

AUTHOR

88           Steven Rostedt <rostedt@goodmis.org[1]>, author of libtraceevent.
89           Tzvetomir Stoyanov <tz.stoyanov@gmail.com[2]>, author of this man page.
90

REPORTING BUGS

92       Report bugs to <linux-trace-devel@vger.kernel.org[3]>
93

LICENSE

95       libtraceevent is Free Software licensed under the GNU LGPL 2.1
96

RESOURCES

98       https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
99

NOTES

101        1. rostedt@goodmis.org
102           mailto:rostedt@goodmis.org
103
104        2. tz.stoyanov@gmail.com
105           mailto:tz.stoyanov@gmail.com
106
107        3. linux-trace-devel@vger.kernel.org
108           mailto:linux-trace-devel@vger.kernel.org
109
110
111
112libtraceevent 1.5.3               07/21/2022                  LIBTRACEEVENT(3)
Impressum