Revision 7e24e92a tracetool
b/tracetool | ||
---|---|---|
13 | 13 |
usage() |
14 | 14 |
{ |
15 | 15 |
cat >&2 <<EOF |
16 |
usage: $0 [--nop | --simple] [-h | -c] |
|
16 |
usage: $0 [--nop | --simple | --ust] [-h | -c]
|
|
17 | 17 |
Generate tracing code for a file on stdin. |
18 | 18 |
|
19 | 19 |
Backends: |
20 | 20 |
--nop Tracing disabled |
21 | 21 |
--simple Simple built-in backend |
22 |
--ust LTTng User Space Tracing backend |
|
22 | 23 |
|
23 | 24 |
Output formats: |
24 | 25 |
-h Generate .h file |
... | ... | |
225 | 226 |
EOF |
226 | 227 |
} |
227 | 228 |
|
229 |
# Clean up after UST headers which pollute the namespace |
|
230 |
ust_clean_namespace() { |
|
231 |
cat <<EOF |
|
232 |
#undef mutex_lock |
|
233 |
#undef mutex_unlock |
|
234 |
#undef inline |
|
235 |
#undef wmb |
|
236 |
EOF |
|
237 |
} |
|
238 |
|
|
239 |
linetoh_begin_ust() |
|
240 |
{ |
|
241 |
echo "#include <ust/tracepoint.h>" |
|
242 |
ust_clean_namespace |
|
243 |
} |
|
244 |
|
|
245 |
linetoh_ust() |
|
246 |
{ |
|
247 |
local name args argnames |
|
248 |
name=$(get_name "$1") |
|
249 |
args=$(get_args "$1") |
|
250 |
argnames=$(get_argnames "$1") |
|
251 |
|
|
252 |
cat <<EOF |
|
253 |
DECLARE_TRACE(ust_$name, TPPROTO($args), TPARGS($argnames)); |
|
254 |
#define trace_$name trace_ust_$name |
|
255 |
EOF |
|
256 |
} |
|
257 |
|
|
258 |
linetoh_end_ust() |
|
259 |
{ |
|
260 |
return |
|
261 |
} |
|
262 |
|
|
263 |
linetoc_begin_ust() |
|
264 |
{ |
|
265 |
cat <<EOF |
|
266 |
#include <ust/marker.h> |
|
267 |
$(ust_clean_namespace) |
|
268 |
#include "trace.h" |
|
269 |
EOF |
|
270 |
} |
|
271 |
|
|
272 |
linetoc_ust() |
|
273 |
{ |
|
274 |
local name args argnames fmt |
|
275 |
name=$(get_name "$1") |
|
276 |
args=$(get_args "$1") |
|
277 |
argnames=$(get_argnames "$1") |
|
278 |
fmt=$(get_fmt "$1") |
|
279 |
|
|
280 |
cat <<EOF |
|
281 |
DEFINE_TRACE(ust_$name); |
|
282 |
|
|
283 |
static void ust_${name}_probe($args) |
|
284 |
{ |
|
285 |
trace_mark(ust, $name, "$fmt", $argnames); |
|
286 |
} |
|
287 |
EOF |
|
288 |
|
|
289 |
# Collect names for later |
|
290 |
names="$names $name" |
|
291 |
} |
|
292 |
|
|
293 |
linetoc_end_ust() |
|
294 |
{ |
|
295 |
cat <<EOF |
|
296 |
static void __attribute__((constructor)) trace_init(void) |
|
297 |
{ |
|
298 |
EOF |
|
299 |
|
|
300 |
for name in $names; do |
|
301 |
cat <<EOF |
|
302 |
register_trace_ust_$name(ust_${name}_probe); |
|
303 |
EOF |
|
304 |
done |
|
305 |
|
|
306 |
echo "}" |
|
307 |
} |
|
308 |
|
|
228 | 309 |
# Process stdin by calling begin, line, and end functions for the backend |
229 | 310 |
convert() |
230 | 311 |
{ |
... | ... | |
282 | 363 |
|
283 | 364 |
# Choose backend |
284 | 365 |
case "$1" in |
285 |
"--nop" | "--simple") backend="${1#--}" ;; |
|
366 |
"--nop" | "--simple" | "--ust") backend="${1#--}" ;;
|
|
286 | 367 |
*) usage ;; |
287 | 368 |
esac |
288 | 369 |
shift |
Also available in: Unified diff