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

NAME

6       tep_print_field_content, tep_print_fields, tep_print_num_field,
7       tep_print_func_field, tep_record_print_fields,
8       tep_record_print_selected_fields - Print the field content.
9

SYNOPSIS

11       #include <event-parse.h>
12       #include <trace-seq.h>
13
14       void tep_print_field_content(struct trace_seq *s, void *data, int size, struct tep_format_field *field);
15       void tep_print_fields(struct trace_seq *s, void *data, int size, struct tep_event *event);
16       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);
17       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);
18       void tep_record_print_fields(struct trace_seq *s, struct tep_record *record, struct tep_event *event);
19       void tep_record_print_selected_fields(struct trace_seq *s, struct tep_record *record, struct tep_event *event, int select_mask);
20

DESCRIPTION

22       These functions print recorded field’s data, according to the field’s
23       type.
24
25       The tep_print_field_content() function extracts from the recorded raw
26       data value of the field and prints it into s, according to the field
27       type.
28
29       The tep_print_fields() prints each field name followed by the record’s
30       field value according to the field’s type:
31
32           "field1_name=field1_value field2_name=field2_value ..."
33
34       It iterates all fields of the event, and calls
35       tep_print_field_content() for each of them.
36
37       The tep_print_num_field() function prints a numeric field with given
38       format string. A search is performed in the event for a field with
39       name. If such field is found, its value is extracted from the record
40       and is printed in the s, according to the given format string fmt. If
41       the argument err is non-zero, and an error occures - it is printed in
42       the s.
43
44       The tep_print_func_field() function prints a function field with given
45       format string. A search is performed in the event for a field with
46       name. If such field is found, its value is extracted from the record.
47       The value is assumed to be a function address, and a search is perform
48       to find the name of this function. The function name (if found) and its
49       address are printed in the s, according to the given format string fmt.
50       If the argument err is non-zero, and an error occures - it is printed
51       in s.
52
53       The tep_record_print_fields() prints the field’s name followed by its
54       value for all record’s field.
55
56       The tep_record_print_selected_fields() prints the field’s name followed
57       by its value for selected subset of record field. The fields to be
58       printed are defined by the select_mask bit mask.
59

RETURN VALUE

61       The tep_print_num_field() and tep_print_func_field() functions return 1
62       on success, -1 in case of an error or 0 if the print buffer s is full.
63

EXAMPLE

65           #include <event-parse.h>
66           #include <trace-seq.h>
67           ...
68           struct tep_handle *tep = tep_alloc();
69           ...
70           struct trace_seq seq;
71           trace_seq_init(&seq);
72           struct tep_event *event = tep_find_event_by_name(tep, "timer", "hrtimer_start");
73           ...
74           void process_record(struct tep_record *record)
75           {
76                   struct tep_format_field *field_pid = tep_find_common_field(event, "common_pid");
77
78                   trace_seq_reset(&seq);
79
80                   /* Print the value of "common_pid" */
81                   tep_print_field_content(&seq, record->data, record->size, field_pid);
82
83                   /* Print all fields of the "hrtimer_start" event */
84                   tep_print_fields(&seq, record->data, record->size, event);
85
86                   /* Print the value of "expires" field with custom format string */
87                   tep_print_num_field(&seq, " timer expires in %llu ", event, "expires", record, 0);
88
89                   /* Print the address and the name of "function" field with custom format string */
90                   tep_print_func_field(&seq, " timer function is %s ", event, "function", record, 0);
91            }
92            ...
93

FILES

95           event-parse.h
96                   Header file to include in order to have access to the library APIs.
97           trace-seq.h
98                   Header file to include in order to have access to trace sequences related APIs.
99                   Trace sequences are used to allow a function to call several other functions
100                   to create a string of data to use.
101           -ltraceevent
102                   Linker switch to add when building a program that uses the library.
103

SEE ALSO

105       libtraceevent(3), trace-cmd(1)
106

AUTHOR

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

REPORTING BUGS

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

LICENSE

115       libtraceevent is Free Software licensed under the GNU LGPL 2.1
116

RESOURCES

118       https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
119

NOTES

121        1. rostedt@goodmis.org
122           mailto:rostedt@goodmis.org
123
124        2. tz.stoyanov@gmail.com
125           mailto:tz.stoyanov@gmail.com
126
127        3. linux-trace-devel@vger.kernel.org
128           mailto:linux-trace-devel@vger.kernel.org
129
130
131
132libtraceevent 1.5.3               04/15/2022                  LIBTRACEEVENT(3)
Impressum