xref: /OK3568_Linux_fs/kernel/tools/lib/traceevent/Documentation/libtraceevent-event_print.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyunlibtraceevent(3)
2*4882a593Smuzhiyun================
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunNAME
5*4882a593Smuzhiyun----
6*4882a593Smuzhiyuntep_print_event - Writes event information into a trace sequence.
7*4882a593Smuzhiyun
8*4882a593SmuzhiyunSYNOPSIS
9*4882a593Smuzhiyun--------
10*4882a593Smuzhiyun[verse]
11*4882a593Smuzhiyun--
12*4882a593Smuzhiyun*#include <event-parse.h>*
13*4882a593Smuzhiyun*#include <trace-seq.h>*
14*4882a593Smuzhiyun
15*4882a593Smuzhiyunvoid *tep_print_event*(struct tep_handle pass:[*]_tep_, struct trace_seqpass:[*]_s_, struct tep_record pass:[*]_record_, const char pass:[*]_fmt_, _..._)
16*4882a593Smuzhiyun--
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunDESCRIPTION
19*4882a593Smuzhiyun-----------
20*4882a593Smuzhiyun
21*4882a593SmuzhiyunThe _tep_print_event()_ function parses the event information of the given
22*4882a593Smuzhiyun_record_ and writes it into the trace sequence _s_, according to the format
23*4882a593Smuzhiyunstring _fmt_. The desired information is specified after the format string.
24*4882a593SmuzhiyunThe _fmt_ is printf-like format string, following arguments are supported:
25*4882a593Smuzhiyun[verse]
26*4882a593Smuzhiyun--
27*4882a593Smuzhiyun	TEP_PRINT_PID, "%d"  - PID of the event.
28*4882a593Smuzhiyun	TEP_PRINT_CPU, "%d"  - Event CPU.
29*4882a593Smuzhiyun	TEP_PRINT_COMM, "%s" - Event command string.
30*4882a593Smuzhiyun	TEP_PRINT_NAME, "%s" - Event name.
31*4882a593Smuzhiyun	TEP_PRINT_LATENCY, "%s" - Latency of the event. It prints 4 or more
32*4882a593Smuzhiyun			fields - interrupt state, scheduling state,
33*4882a593Smuzhiyun			current context, and preemption count.
34*4882a593Smuzhiyun			Field 1 is the interrupt enabled state:
35*4882a593Smuzhiyun				d : Interrupts are disabled
36*4882a593Smuzhiyun				. : Interrupts are enabled
37*4882a593Smuzhiyun				X : The architecture does not support this
38*4882a593Smuzhiyun				    information
39*4882a593Smuzhiyun			Field 2 is the "need resched" state.
40*4882a593Smuzhiyun				N : The task is set to call the scheduler when
41*4882a593Smuzhiyun				    possible, as another higher priority task
42*4882a593Smuzhiyun				    may need to be scheduled in.
43*4882a593Smuzhiyun				. : The task is not set to call the scheduler.
44*4882a593Smuzhiyun			Field 3 is the context state.
45*4882a593Smuzhiyun				. : Normal context
46*4882a593Smuzhiyun				s : Soft interrupt context
47*4882a593Smuzhiyun				h : Hard interrupt context
48*4882a593Smuzhiyun				H : Hard interrupt context which triggered
49*4882a593Smuzhiyun				    during soft interrupt context.
50*4882a593Smuzhiyun				z : NMI context
51*4882a593Smuzhiyun				Z : NMI context which triggered during hard
52*4882a593Smuzhiyun				    interrupt context
53*4882a593Smuzhiyun			Field 4 is the preemption count.
54*4882a593Smuzhiyun				. : The preempt count is zero.
55*4882a593Smuzhiyun			On preemptible kernels (where the task can be scheduled
56*4882a593Smuzhiyun			out in arbitrary locations while in kernel context), the
57*4882a593Smuzhiyun			preempt count, when non zero, will prevent the kernel
58*4882a593Smuzhiyun			from scheduling out the current task. The preempt count
59*4882a593Smuzhiyun			number is displayed when it is not zero.
60*4882a593Smuzhiyun			Depending on the kernel, it may show other fields
61*4882a593Smuzhiyun			(lock depth, or migration disabled, which are unique to
62*4882a593Smuzhiyun			specialized kernels).
63*4882a593Smuzhiyun	TEP_PRINT_TIME, %d - event time stamp. A divisor and precision can be
64*4882a593Smuzhiyun			specified as part of this format string:
65*4882a593Smuzhiyun			"%precision.divisord". Example:
66*4882a593Smuzhiyun			"%3.1000d" - divide the time by 1000 and print the first
67*4882a593Smuzhiyun			3 digits before the dot. Thus, the time stamp
68*4882a593Smuzhiyun			"123456000" will be printed as "123.456"
69*4882a593Smuzhiyun	TEP_PRINT_INFO, "%s" - event information.
70*4882a593Smuzhiyun	TEP_PRINT_INFO_RAW, "%s" - event information, in raw format.
71*4882a593Smuzhiyun
72*4882a593Smuzhiyun--
73*4882a593SmuzhiyunEXAMPLE
74*4882a593Smuzhiyun-------
75*4882a593Smuzhiyun[source,c]
76*4882a593Smuzhiyun--
77*4882a593Smuzhiyun#include <event-parse.h>
78*4882a593Smuzhiyun#include <trace-seq.h>
79*4882a593Smuzhiyun...
80*4882a593Smuzhiyunstruct trace_seq seq;
81*4882a593Smuzhiyuntrace_seq_init(&seq);
82*4882a593Smuzhiyunstruct tep_handle *tep = tep_alloc();
83*4882a593Smuzhiyun...
84*4882a593Smuzhiyunvoid print_my_event(struct tep_record *record)
85*4882a593Smuzhiyun{
86*4882a593Smuzhiyun	trace_seq_reset(&seq);
87*4882a593Smuzhiyun	tep_print_event(tep, s, record, "%16s-%-5d [%03d] %s %6.1000d %s %s",
88*4882a593Smuzhiyun			TEP_PRINT_COMM, TEP_PRINT_PID, TEP_PRINT_CPU,
89*4882a593Smuzhiyun			TEP_PRINT_LATENCY, TEP_PRINT_TIME, TEP_PRINT_NAME,
90*4882a593Smuzhiyun			TEP_PRINT_INFO);
91*4882a593Smuzhiyun}
92*4882a593Smuzhiyun...
93*4882a593Smuzhiyun--
94*4882a593Smuzhiyun
95*4882a593SmuzhiyunFILES
96*4882a593Smuzhiyun-----
97*4882a593Smuzhiyun[verse]
98*4882a593Smuzhiyun--
99*4882a593Smuzhiyun*event-parse.h*
100*4882a593Smuzhiyun	Header file to include in order to have access to the library APIs.
101*4882a593Smuzhiyun*trace-seq.h*
102*4882a593Smuzhiyun	Header file to include in order to have access to trace sequences related APIs.
103*4882a593Smuzhiyun	Trace sequences are used to allow a function to call several other functions
104*4882a593Smuzhiyun	to create a string of data to use.
105*4882a593Smuzhiyun*-ltraceevent*
106*4882a593Smuzhiyun	Linker switch to add when building a program that uses the library.
107*4882a593Smuzhiyun--
108*4882a593Smuzhiyun
109*4882a593SmuzhiyunSEE ALSO
110*4882a593Smuzhiyun--------
111*4882a593Smuzhiyun_libtraceevent(3)_, _trace-cmd(1)_
112*4882a593Smuzhiyun
113*4882a593SmuzhiyunAUTHOR
114*4882a593Smuzhiyun------
115*4882a593Smuzhiyun[verse]
116*4882a593Smuzhiyun--
117*4882a593Smuzhiyun*Steven Rostedt* <rostedt@goodmis.org>, author of *libtraceevent*.
118*4882a593Smuzhiyun*Tzvetomir Stoyanov* <tz.stoyanov@gmail.com>, author of this man page.
119*4882a593Smuzhiyun--
120*4882a593SmuzhiyunREPORTING BUGS
121*4882a593Smuzhiyun--------------
122*4882a593SmuzhiyunReport bugs to  <linux-trace-devel@vger.kernel.org>
123*4882a593Smuzhiyun
124*4882a593SmuzhiyunLICENSE
125*4882a593Smuzhiyun-------
126*4882a593Smuzhiyunlibtraceevent is Free Software licensed under the GNU LGPL 2.1
127*4882a593Smuzhiyun
128*4882a593SmuzhiyunRESOURCES
129*4882a593Smuzhiyun---------
130*4882a593Smuzhiyunhttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
131