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