Revision b3d08c02 tracetool
b/tracetool | ||
---|---|---|
20 | 20 |
--nop Tracing disabled |
21 | 21 |
--simple Simple built-in backend |
22 | 22 |
--ust LTTng User Space Tracing backend |
23 |
--dtrace DTrace/SystemTAP backend |
|
23 | 24 |
|
24 | 25 |
Output formats: |
25 | 26 |
-h Generate .h file |
26 | 27 |
-c Generate .c file |
28 |
-d Generate .d file (DTrace only) |
|
27 | 29 |
EOF |
28 | 30 |
exit 1 |
29 | 31 |
} |
... | ... | |
46 | 48 |
# Get the argument name list of a trace event |
47 | 49 |
get_argnames() |
48 | 50 |
{ |
49 |
local nfields field name |
|
51 |
local nfields field name sep
|
|
50 | 52 |
nfields=0 |
53 |
sep="$2" |
|
51 | 54 |
for field in $(get_args "$1"); do |
52 | 55 |
nfields=$((nfields + 1)) |
53 | 56 |
|
... | ... | |
58 | 61 |
name=${field%,} |
59 | 62 |
test "$field" = "$name" && continue |
60 | 63 |
|
61 |
printf "%s" "$name, "
|
|
64 |
printf "%s%s " $name $sep
|
|
62 | 65 |
done |
63 | 66 |
|
64 | 67 |
# Last argument name |
... | ... | |
73 | 76 |
{ |
74 | 77 |
local name argc |
75 | 78 |
argc=0 |
76 |
for name in $(get_argnames "$1"); do |
|
79 |
for name in $(get_argnames "$1", ","); do
|
|
77 | 80 |
argc=$((argc + 1)) |
78 | 81 |
done |
79 | 82 |
echo $argc |
... | ... | |
154 | 157 |
cast_args_to_uint64_t() |
155 | 158 |
{ |
156 | 159 |
local arg |
157 |
for arg in $(get_argnames "$1"); do |
|
160 |
for arg in $(get_argnames "$1", ","); do
|
|
158 | 161 |
printf "%s" "(uint64_t)(uintptr_t)$arg" |
159 | 162 |
done |
160 | 163 |
} |
... | ... | |
247 | 250 |
local name args argnames |
248 | 251 |
name=$(get_name "$1") |
249 | 252 |
args=$(get_args "$1") |
250 |
argnames=$(get_argnames "$1") |
|
253 |
argnames=$(get_argnames "$1", ",")
|
|
251 | 254 |
|
252 | 255 |
cat <<EOF |
253 | 256 |
DECLARE_TRACE(ust_$name, TP_PROTO($args), TP_ARGS($argnames)); |
... | ... | |
274 | 277 |
local name args argnames fmt |
275 | 278 |
name=$(get_name "$1") |
276 | 279 |
args=$(get_args "$1") |
277 |
argnames=$(get_argnames "$1") |
|
280 |
argnames=$(get_argnames "$1", ",")
|
|
278 | 281 |
fmt=$(get_fmt "$1") |
279 | 282 |
|
280 | 283 |
cat <<EOF |
... | ... | |
306 | 309 |
echo "}" |
307 | 310 |
} |
308 | 311 |
|
312 |
linetoh_begin_dtrace() |
|
313 |
{ |
|
314 |
cat <<EOF |
|
315 |
#include "trace-dtrace.h" |
|
316 |
EOF |
|
317 |
} |
|
318 |
|
|
319 |
linetoh_dtrace() |
|
320 |
{ |
|
321 |
local name args argnames state nameupper |
|
322 |
name=$(get_name "$1") |
|
323 |
args=$(get_args "$1") |
|
324 |
argnames=$(get_argnames "$1", ",") |
|
325 |
state=$(get_state "$1") |
|
326 |
if [ "$state" = "0" ] ; then |
|
327 |
name=${name##disable } |
|
328 |
fi |
|
329 |
|
|
330 |
nameupper=`echo $name | tr '[:lower:]' '[:upper:]'` |
|
331 |
|
|
332 |
# Define an empty function for the trace event |
|
333 |
cat <<EOF |
|
334 |
static inline void trace_$name($args) { |
|
335 |
if (QEMU_${nameupper}_ENABLED()) { |
|
336 |
QEMU_${nameupper}($argnames); |
|
337 |
} |
|
338 |
} |
|
339 |
EOF |
|
340 |
} |
|
341 |
|
|
342 |
linetoh_end_dtrace() |
|
343 |
{ |
|
344 |
return |
|
345 |
} |
|
346 |
|
|
347 |
linetoc_begin_dtrace() |
|
348 |
{ |
|
349 |
return |
|
350 |
} |
|
351 |
|
|
352 |
linetoc_dtrace() |
|
353 |
{ |
|
354 |
# No need for function definitions in dtrace backend |
|
355 |
return |
|
356 |
} |
|
357 |
|
|
358 |
linetoc_end_dtrace() |
|
359 |
{ |
|
360 |
return |
|
361 |
} |
|
362 |
|
|
363 |
linetod_begin_dtrace() |
|
364 |
{ |
|
365 |
cat <<EOF |
|
366 |
provider qemu { |
|
367 |
EOF |
|
368 |
} |
|
369 |
|
|
370 |
linetod_dtrace() |
|
371 |
{ |
|
372 |
local name args state |
|
373 |
name=$(get_name "$1") |
|
374 |
args=$(get_args "$1") |
|
375 |
state=$(get_state "$1") |
|
376 |
if [ "$state" = "0" ] ; then |
|
377 |
name=${name##disable } |
|
378 |
fi |
|
379 |
|
|
380 |
# DTrace provider syntax expects foo() for empty |
|
381 |
# params, not foo(void) |
|
382 |
if [ "$args" = "void" ]; then |
|
383 |
args="" |
|
384 |
fi |
|
385 |
|
|
386 |
# Define prototype for probe arguments |
|
387 |
cat <<EOF |
|
388 |
probe $name($args); |
|
389 |
EOF |
|
390 |
} |
|
391 |
|
|
392 |
linetod_end_dtrace() |
|
393 |
{ |
|
394 |
cat <<EOF |
|
395 |
}; |
|
396 |
EOF |
|
397 |
} |
|
398 |
|
|
309 | 399 |
# Process stdin by calling begin, line, and end functions for the backend |
310 | 400 |
convert() |
311 | 401 |
{ |
... | ... | |
324 | 414 |
disable=${str%%disable *} |
325 | 415 |
echo |
326 | 416 |
if test -z "$disable"; then |
327 |
# Pass the disabled state as an arg to lineto$1_simple(). |
|
328 |
# For all other cases, call lineto$1_nop() |
|
329 |
if [ $backend = "simple" ]; then |
|
417 |
# Pass the disabled state as an arg for the simple |
|
418 |
# or DTrace backends which handle it dynamically. |
|
419 |
# For all other backends, call lineto$1_nop() |
|
420 |
if [ $backend = "simple" -o "$backend" = "dtrace" ]; then |
|
330 | 421 |
"$process_line" "$str" |
331 | 422 |
else |
332 | 423 |
"lineto$1_nop" "${str##disable }" |
... | ... | |
360 | 451 |
convert c |
361 | 452 |
} |
362 | 453 |
|
454 |
tracetod() |
|
455 |
{ |
|
456 |
if [ $backend != "dtrace" ]; then |
|
457 |
echo "DTrace probe generator not applicable to $backend backend" |
|
458 |
exit 1 |
|
459 |
fi |
|
460 |
echo "/* This file is autogenerated by tracetool, do not edit. */" |
|
461 |
convert d |
|
462 |
} |
|
463 |
|
|
363 | 464 |
# Choose backend |
364 | 465 |
case "$1" in |
365 |
"--nop" | "--simple" | "--ust") backend="${1#--}" ;; |
|
466 |
"--nop" | "--simple" | "--ust" | "--dtrace") backend="${1#--}" ;;
|
|
366 | 467 |
*) usage ;; |
367 | 468 |
esac |
368 | 469 |
shift |
... | ... | |
370 | 471 |
case "$1" in |
371 | 472 |
"-h") tracetoh ;; |
372 | 473 |
"-c") tracetoc ;; |
474 |
"-d") tracetod ;; |
|
373 | 475 |
"--check-backend") exit 0 ;; # used by ./configure to test for backend |
374 | 476 |
*) usage ;; |
375 | 477 |
esac |
Also available in: Unified diff