1LIBTRACEEVENT(3) libtraceevent Manual LIBTRACEEVENT(3)
2
3
4
6 tep_print_field, tep_print_fields, tep_print_num_field,
7 tep_print_func_field - Print the field content.
8
10 #include <event-parse.h>
11 #include <trace-seq.h>
12
13 void tep_print_field(struct trace_seq *s, void *data, struct tep_format_field *field);
14 void tep_print_fields(struct trace_seq *s, void *data, int size, struct tep_event *event);
15 int tep_print_num_field(struct trace_seq *s, const char *fmt, struct tep_event *event, const char *name, struct tep_record *record, int err);
16 int tep_print_func_field(struct trace_seq *s, const char *fmt, struct tep_event *event, const char *name, struct tep_record *record, int err);
17
19 These functions print recorded field’s data, according to the field’s
20 type.
21
22 The tep_print_field() function extracts from the recorded raw data
23 value of the field and prints it into s, according to the field type.
24
25 The tep_print_fields() prints each field name followed by the record’s
26 field value according to the field’s type:
27
28 "field1_name=field1_value field2_name=field2_value ..."
29
30 It iterates all fields of the event, and calls tep_print_field() for
31 each of them.
32
33 The tep_print_num_field() function prints a numeric field with given
34 format string. A search is performed in the event for a field with
35 name. If such field is found, its value is extracted from the record
36 and is printed in the s, according to the given format string fmt. If
37 the argument err is non-zero, and an error occures - it is printed in
38 the s.
39
40 The tep_print_func_field() function prints a function field with given
41 format string. A search is performed in the event for a field with
42 name. If such field is found, its value is extracted from the record.
43 The value is assumed to be a function address, and a search is perform
44 to find the name of this function. The function name (if found) and its
45 address are printed in the s, according to the given format string fmt.
46 If the argument err is non-zero, and an error occures - it is printed
47 in s.
48
50 The tep_print_num_field() and tep_print_func_field() functions return 1
51 on success, -1 in case of an error or 0 if the print buffer s is full.
52
54 #include <event-parse.h>
55 #include <trace-seq.h>
56 ...
57 struct tep_handle *tep = tep_alloc();
58 ...
59 struct trace_seq seq;
60 trace_seq_init(&seq);
61 struct tep_event *event = tep_find_event_by_name(tep, "timer", "hrtimer_start");
62 ...
63 void process_record(struct tep_record *record)
64 {
65 struct tep_format_field *field_pid = tep_find_common_field(event, "common_pid");
66
67 trace_seq_reset(&seq);
68
69 /* Print the value of "common_pid" */
70 tep_print_field(&seq, record->data, field_pid);
71
72 /* Print all fields of the "hrtimer_start" event */
73 tep_print_fields(&seq, record->data, record->size, event);
74
75 /* Print the value of "expires" field with custom format string */
76 tep_print_num_field(&seq, " timer expires in %llu ", event, "expires", record, 0);
77
78 /* Print the address and the name of "function" field with custom format string */
79 tep_print_func_field(&seq, " timer function is %s ", event, "function", record, 0);
80 }
81 ...
82
84 event-parse.h
85 Header file to include in order to have access to the library APIs.
86 trace-seq.h
87 Header file to include in order to have access to trace sequences related APIs.
88 Trace sequences are used to allow a function to call several other functions
89 to create a string of data to use.
90 -ltraceevent
91 Linker switch to add when building a program that uses the library.
92
94 libtraceevent(3), trace-cmd(1)
95
97 Steven Rostedt <rostedt@goodmis.org[1]>, author of libtraceevent.
98 Tzvetomir Stoyanov <tz.stoyanov@gmail.com[2]>, author of this man page.
99
101 Report bugs to <linux-trace-devel@vger.kernel.org[3]>
102
104 libtraceevent is Free Software licensed under the GNU LGPL 2.1
105
107 https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
108
110 1. rostedt@goodmis.org
111 mailto:rostedt@goodmis.org
112
113 2. tz.stoyanov@gmail.com
114 mailto:tz.stoyanov@gmail.com
115
116 3. linux-trace-devel@vger.kernel.org
117 mailto:linux-trace-devel@vger.kernel.org
118
119
120
121libtraceevent 1.2.1 07/22/2021 LIBTRACEEVENT(3)