Project

General

Profile

Wiki » History » Version 3

David Goulet, 02/17/2012 10:57 AM

1 1 David Goulet
h1. LTTng-tools Wiki
2
3
h2. Quickstart
4
5
This is a quick start guide for the complete LTTng tool chain. This is divided
6
in three sections respectively kernel tracing, user-space tracing and reading a
7
trace.
8
9
See the README file for installation procedure or use the various Linux
10
distribution packages.
11
12
In order to trace the kernel, you''ll need the lttng-modules 2.0 compiled and
13
installed. See http://lttng.org/lttng2.0 for more instructions for that part.
14
For user-space tracing, you''ll need an instrumented application with lttng-ust
15
2.0.
16
17
lttng-tools provide a session daemon (lttng-sessiond) that acts as a tracing
18
registry. To trace any instrumented applications or the kernel, a registered
19
tracing session is needed beforehand. To interact with the session daemon and a
20
tracing session, you should use the lttng command line UI (lttng). It is also
21
possible to use the liblttngctl library for tracing control (lttng.h).
22
23
Here is a list of some powerful features the LTTng 2.0 kernel tracer offers:
24
25
	* Kprobes support
26
	* Function Tracer support
27
	* Context information support (add context data to an event)
28
	* Perf counter support
29
	* Tracepoint support
30
31
And for the LTTng UST 2.0 tracer:
32
33
	* Applications registration
34
	* Automatic tracepoints activation upon app. registration
35
	* Context information support
36
	* Safe buffers after application crash
37
	* Per-user tracing (root access *not* mandatory)
38
39
The next sections explains how to do tracing :)
40
41
h3. Kernel Tracing
42
43
You can start the session daemon by invoking the command "lttng-sessiond", or
44
let the lttng command line tool do it for you. The session daemon loads the
45
LTTng tracer modules for you if those modules can be found on your system. If
46
they are not found, the kernel tracing feature will be unavailable.
47
48
List available kernel events:
49
50 3 David Goulet
<pre>
51 1 David Goulet
# lttng list -k
52 3 David Goulet
</pre>
53 1 David Goulet
54
1) Create a tracing session. The .lttng directory will be created with .lttngrc
55
file in $HOME containing the session name (here ''mysession'') you are working
56
on.
57
58 3 David Goulet
<pre>
59 1 David Goulet
# lttng create mysession
60 3 David Goulet
</pre>
61 1 David Goulet
62
If you have multiple sessions, you can change the current session by using
63
64 3 David Goulet
<pre>
65 1 David Goulet
# lttng set-session myothersession
66 3 David Goulet
</pre>
67 1 David Goulet
68
2) Enable all tracepoints and all system call events.
69
70 3 David Goulet
<pre>
71 1 David Goulet
# lttng enable-event -a -k
72 3 David Goulet
</pre>
73 1 David Goulet
74
3) Enable tracepoint event(s). Here for example, we want only
75
''sched_switch'' and ''sched_wakeup'' events for the kernel (-k/--kernel).
76
77 3 David Goulet
<pre>
78 1 David Goulet
# lttng enable-event sched_switch,sched_wakeup -k
79 3 David Goulet
</pre>
80 1 David Goulet
81
or enable ALL tracepoint events:
82
83 3 David Goulet
<pre>
84 1 David Goulet
# lttng enable-event -a -k --tracepoint
85 3 David Goulet
</pre>
86 1 David Goulet
87
4) Enable all system call event(s).
88
89 3 David Goulet
<pre>
90 1 David Goulet
# lttng enable-event -a -k --syscall
91 3 David Goulet
</pre>
92 1 David Goulet
93
5) Enable kprobes and/or the function tracer with lttng
94
95
This is a new feature made possible by the new LTTng 2.0 kernel tracer. You can
96
enable a dynamic probe and data will be output in the trace along side with
97
your tracing data.
98
99 3 David Goulet
<pre>
100 1 David Goulet
# lttng enable-event aname -k --probe symbol+0x0
101 3 David Goulet
</pre>
102 1 David Goulet
103
or
104
105 3 David Goulet
<pre>
106 1 David Goulet
# lttng enable-event aname -k --probe 0xffff7260695
107 3 David Goulet
</pre>
108 1 David Goulet
109
Either an <address> or a <symbol+offset> can be used for probes.
110
111
You can also enable function tracer, which uses the Ftrace API (by Steven
112
Rostedt). Again, data will be output in the trace.
113
114 3 David Goulet
<pre>
115 1 David Goulet
# lttng enable-event aname -k --function <symbol_name>
116 3 David Goulet
</pre>
117 1 David Goulet
118
6) Enable context information for an event:
119
120
This is also a new feature which allows you to add context information to an
121
event. For example, you can add the PID along with the event information:
122
123 3 David Goulet
<pre>
124 1 David Goulet
# lttng add-context -k -e sched_switch -t pid
125 3 David Goulet
</pre>
126 1 David Goulet
127
At this point, you will have to look at ''lttng add-context --help'' for all
128
possible context type.
129
130
You can on the same line activate multiple context:
131
132 3 David Goulet
<pre>
133 1 David Goulet
# lttng add-context -k -e sched_switch -t pid -t nice -t tid
134 3 David Goulet
</pre>
135 1 David Goulet
136
7) Enable perf counter for an event:
137
138
Again, a new powerful feature is the possibility to add perf counter data
139
(using the perf API by Ingo Molnar and Thomas Gleixner) to the trace on a per
140
event basis. Let say we want to get the CPU cycles at each event:
141
142 3 David Goulet
<pre>
143 1 David Goulet
# lttng add-context -k -e sched_switch -t perf:cpu-cycles
144 3 David Goulet
</pre>
145 1 David Goulet
146
You''ll have to use the add-context help for all possible perf counter values.
147
148
8) Start tracing:
149
150 3 David Goulet
<pre>
151 1 David Goulet
# lttng start
152 3 David Goulet
</pre>
153 1 David Goulet
154
Tracing is in progress at this point and traces will be written in
155
$HOME/lttng-traces/mysession-<date>-<time>
156
157
NOTE: It will start tracing for *all* domain(s).
158
159
9) Stop tracing:
160
161 3 David Goulet
<pre>
162 1 David Goulet
# lttng stop
163 3 David Goulet
</pre>
164 1 David Goulet
165
NOTE: At this point, you can restart the trace (lttng start), enable/disable
166
events or just go take a break and come back 3 days later to start it again :).
167
You can also read the trace since the buffers are flushed on stop command.
168
169
10) Destroy your session after you are done with tracing
170
171 3 David Goulet
<pre>
172 1 David Goulet
# lttng destroy
173 3 David Goulet
</pre>
174 1 David Goulet
175
See Reading a trace section below to read you trace(s).
176
177
h3. User-space Tracing
178
179
Like kernel tracing, you can start the session daemon by invoking the command
180
"lttng-sessiond", or let the lttng command line tool do it for you.
181
182
NOTE: You do *not* need root credentials in order to tracer user-space
183
applications. However, if you run the session daemon under non-root user
184
rights, only applications of that user will be traced.
185
186
So, after instrumenting you applications with LTTng-ust 2.0
187
(http://lttng.org/lttng2.0), upon startup, it will automatically register to
188
the session daemon. If there is none running, it will simply wait on a seperate
189
thread for a session daemon to appear and then register.
190
191
Start your instrumented application at any time but at least before starting
192
tracing :).
193
194
List available registered applications:
195
196 3 David Goulet
<pre>
197 1 David Goulet
$ lttng list -u
198 3 David Goulet
</pre>
199 1 David Goulet
200
1) Create a tracing session. The .lttng directory will be created with a
201
.lttngrc file in $HOME containing the session name (here ''mysession'') you are
202
working on.
203
204 3 David Goulet
<pre>
205 1 David Goulet
$ lttng create mysession
206 3 David Goulet
</pre>
207 1 David Goulet
208
If you have multiple sessions, you can change the current session by using:
209
210 3 David Goulet
<pre>
211 1 David Goulet
$ lttng set-session myothersession
212 3 David Goulet
</pre>
213 1 David Goulet
214
2) Enable all tracepoints for the global UST domain ("-u" alone).
215
216 3 David Goulet
<pre>
217 1 David Goulet
$ lttng enable-event -a -u
218 3 David Goulet
</pre>
219 1 David Goulet
220
or enable a single tracepoint event.
221
222 3 David Goulet
<pre>
223 1 David Goulet
$ lttng enable-event ust_tests_hello:tptest -u
224 3 David Goulet
</pre>
225 1 David Goulet
226
3) This is also a new feature which allows you to add context information to an
227
event. For example, you can add the PID along with the event information:
228
229 3 David Goulet
<pre>
230 1 David Goulet
$ lttng add-context -t pid -e ust_tests_hello:tptest -u
231 3 David Goulet
</pre>
232 1 David Goulet
233
At this point, you will have to look at ''lttng add-context --help'' for all
234
possible context type.
235
236
You can on the same line activate multiple context:
237
238 3 David Goulet
<pre>
239 1 David Goulet
$ lttng add-context -u -e ust_tests_hello:tptest -t pid -t nice -t tid
240 3 David Goulet
</pre>
241 1 David Goulet
242
4) Start tracing:
243
244 3 David Goulet
<pre>
245 1 David Goulet
$ lttng start
246 3 David Goulet
</pre>
247 1 David Goulet
248
Tracing is in progress at this point and traces will be written in
249
$HOME/lttng-traces/mysession-<date>-<time>/ust/<procname>-<pid>-<date>-<time>
250
251
NOTE: It will start tracing for *all* domain(s).
252
253
5) Stop tracing:
254
255 3 David Goulet
<pre>
256 1 David Goulet
$ lttng stop
257 3 David Goulet
</pre>
258 1 David Goulet
259
NOTE: At this point, you can restart the trace (lttng start), enable/disable
260
events or just go take a break and come back 3 days later to start it again :).
261
You can also read the trace since the buffers are flushed on stop command.
262
263
6) Destroy your session after you are done with tracing
264
265 3 David Goulet
<pre>
266 1 David Goulet
$ lttng destroy
267 3 David Goulet
</pre>
268 1 David Goulet
269
h3. Reading a trace
270
271
The tool "Babeltrace" can be used to dump your binary trace into a
272
human-readable text format. Please see http://www.efficios.com/babeltrace and
273
git tree http://git.efficios.com/?p=babeltrace.git
274
275 2 David Goulet
<pre>
276 1 David Goulet
# babeltrace $HOME/lttng-traces/mysession-<date>-<time> | less
277 2 David Goulet
</pre>
278 1 David Goulet
279
VoilĂ