• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1libtraceevent(3)
2================
3
4NAME
5----
6tep_print_field, tep_print_fields, tep_print_num_field, tep_print_func_field -
7Print the field content.
8
9SYNOPSIS
10--------
11[verse]
12--
13*#include <event-parse.h>*
14*#include <trace-seq.h>*
15
16void *tep_print_field*(struct trace_seq pass:[*]_s_, void pass:[*]_data_, struct tep_format_field pass:[*]_field_);
17void *tep_print_fields*(struct trace_seq pass:[*]_s_, void pass:[*]_data_, int _size_, struct tep_event pass:[*]_event_);
18int *tep_print_num_field*(struct trace_seq pass:[*]_s_, const char pass:[*]_fmt_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, int _err_);
19int *tep_print_func_field*(struct trace_seq pass:[*]_s_, const char pass:[*]_fmt_, struct tep_event pass:[*]_event_, const char pass:[*]_name_, struct tep_record pass:[*]_record_, int _err_);
20--
21
22DESCRIPTION
23-----------
24These functions print recorded field's data, according to the field's type.
25
26The _tep_print_field()_ function extracts from the recorded raw _data_ value of
27the _field_ and prints it into _s_, according to the field type.
28
29The _tep_print_fields()_ prints each field name followed by the record's field
30value according to the field's type:
31[verse]
32--
33"field1_name=field1_value field2_name=field2_value ..."
34--
35It iterates all fields of the _event_, and calls _tep_print_field()_ for each of
36them.
37
38The _tep_print_num_field()_ function prints a numeric field with given format
39string. A search is performed in the _event_ for a field with _name_. If such
40field is found, its value is extracted from the _record_ and is printed in the
41_s_, according to the given format string _fmt_. If the argument _err_ is
42non-zero, and an error occures - it is printed in the _s_.
43
44The _tep_print_func_field()_ function prints a function field with given format
45string.  A search is performed in the _event_ for a field with _name_. If such
46field is found, its value is extracted from the _record_. The value is assumed
47to be a function address, and a search is perform to find the name of this
48function. The function name (if found) and its address are printed in the _s_,
49according to the given format string _fmt_. If the argument _err_ is non-zero,
50and an error occures - it is printed in _s_.
51
52RETURN VALUE
53------------
54The _tep_print_num_field()_ and _tep_print_func_field()_ functions return 1
55on success, -1 in case of an error or 0 if the print buffer _s_ is full.
56
57EXAMPLE
58-------
59[source,c]
60--
61#include <event-parse.h>
62#include <trace-seq.h>
63...
64struct tep_handle *tep = tep_alloc();
65...
66struct trace_seq seq;
67trace_seq_init(&seq);
68struct tep_event *event = tep_find_event_by_name(tep, "timer", "hrtimer_start");
69...
70void process_record(struct tep_record *record)
71{
72	struct tep_format_field *field_pid = tep_find_common_field(event, "common_pid");
73
74	trace_seq_reset(&seq);
75
76	/* Print the value of "common_pid" */
77	tep_print_field(&seq, record->data, field_pid);
78
79	/* Print all fields of the "hrtimer_start" event */
80	tep_print_fields(&seq, record->data, record->size, event);
81
82	/* Print the value of "expires" field with custom format string */
83	tep_print_num_field(&seq, " timer expires in %llu ", event, "expires", record, 0);
84
85	/* Print the address and the name of "function" field with custom format string */
86	tep_print_func_field(&seq, " timer function is %s ", event, "function", record, 0);
87 }
88 ...
89--
90
91FILES
92-----
93[verse]
94--
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--
104
105SEE ALSO
106--------
107_libtraceevent(3)_, _trace-cmd(1)_
108
109AUTHOR
110------
111[verse]
112--
113*Steven Rostedt* <rostedt@goodmis.org>, author of *libtraceevent*.
114*Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>, author of this man page.
115--
116REPORTING BUGS
117--------------
118Report bugs to  <linux-trace-devel@vger.kernel.org>
119
120LICENSE
121-------
122libtraceevent is Free Software licensed under the GNU LGPL 2.1
123
124RESOURCES
125---------
126https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
127