Revision c276b17d

b/Makefile.target
41 41
config-target.h: config-target.h-timestamp
42 42
config-target.h-timestamp: config-target.mak
43 43

  
44
all: $(PROGS)
44
ifdef CONFIG_SYSTEMTAP_TRACE
45
stap: $(QEMU_PROG).stp
46

  
47
ifdef CONFIG_USER_ONLY
48
TARGET_TYPE=user
49
else
50
TARGET_TYPE=system
51
endif
52

  
53
$(QEMU_PROG).stp:
54
	$(call quiet-command,sh $(SRC_PATH)/tracetool \
55
		--$(TRACE_BACKEND) \
56
		--binary $(bindir)/$(QEMU_PROG) \
57
		--target-arch $(TARGET_ARCH) \
58
		--target-type $(TARGET_TYPE) \
59
		--stap < $(SRC_PATH)/trace-events > $(QEMU_PROG).stp,"  GEN   $(QEMU_PROG).stp")
60
else
61
stap:
62
endif
63

  
64
all: $(PROGS) stap
45 65

  
46 66
# Dummy command so that make thinks it has done something
47 67
	@true
......
341 361
	rm -f *.o *.a *~ $(PROGS) nwfpe/*.o fpu/*.o
342 362
	rm -f *.d */*.d tcg/*.o ide/*.o
343 363
	rm -f hmp-commands.h qmp-commands.h gdbstub-xml.c
364
ifdef CONFIG_SYSTEMTAP_TRACE
365
	rm -f *.stp
366
endif
344 367

  
345 368
install: all
346 369
ifneq ($(PROGS),)
......
349 372
	$(STRIP) $(patsubst %,"$(DESTDIR)$(bindir)/%",$(PROGS))
350 373
endif
351 374
endif
375
ifdef CONFIG_SYSTEMTAP_TRACE
376
	$(INSTALL_DIR) "$(DESTDIR)$(datadir)/../systemtap/tapset"
377
	$(INSTALL_DATA) $(QEMU_PROG).stp "$(DESTDIR)$(datadir)/../systemtap/tapset"
378
endif
352 379

  
353 380
# Include automatically generated dependency files
354 381
-include $(wildcard *.d */*.d)
b/configure
2203 2203
    echo
2204 2204
    exit 1
2205 2205
  fi
2206
  trace_backend_stap="no"
2207
  if has 'stap' ; then
2208
    trace_backend_stap="yes"
2209
  fi
2206 2210
fi
2207 2211

  
2208 2212
##########################################
......
2645 2649
if test "$trace_backend" = "simple"; then
2646 2650
  trace_file="\"$trace_file-%u\""
2647 2651
fi
2652
if test "$trace_backend" = "dtrace" -a "$trace_backend_stap" = "yes" ; then
2653
  echo "CONFIG_SYSTEMTAP_TRACE=y" >> $config_host_mak
2654
fi
2648 2655
echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
2649 2656

  
2650 2657
echo "TOOLS=$tools" >> $config_host_mak
b/tracetool
23 23
  --dtrace  DTrace/SystemTAP backend
24 24

  
25 25
Output formats:
26
  -h    Generate .h file
27
  -c    Generate .c file
28
  -d    Generate .d file (DTrace only)
26
  -h     Generate .h file
27
  -c     Generate .c file
28
  -d     Generate .d file (DTrace only)
29
  --stap Generate .stp file (DTrace with SystemTAP only)
30

  
31
Options:
32
  --binary      [path]  Full path to QEMU binary
33
  --target-arch [arch]  QEMU emulator target arch
34
  --target-type [type]  QEMU emulator target type ('system' or 'user')
35

  
29 36
EOF
30 37
    exit 1
31 38
}
......
396 403
EOF
397 404
}
398 405

  
406
linetostap_begin_dtrace()
407
{
408
    return
409
}
410

  
411
linetostap_dtrace()
412
{
413
    local i arg name args arglist state
414
    name=$(get_name "$1")
415
    args=$(get_args "$1")
416
    arglist=$(get_argnames "$1", "")
417
    state=$(get_state "$1")
418
    if [ "$state" = "0" ] ; then
419
        name=${name##disable }
420
    fi
421

  
422
    # Define prototype for probe arguments
423
    cat <<EOF
424
probe qemu.$targettype.$targetarch.$name = process("$binary").mark("$name")
425
{
426
EOF
427

  
428
    i=1
429
    for arg in $arglist
430
    do
431
        # 'limit' is a reserved keyword
432
        if [ "$arg" = "limit" ]; then
433
          arg="_limit"
434
        fi
435
        cat <<EOF
436
  $arg = \$arg$i;
437
EOF
438
	i="$((i+1))"
439
    done
440

  
441
    cat <<EOF
442
}
443
EOF
444
}
445

  
446
linetostap_end_dtrace()
447
{
448
    return
449
}
450

  
399 451
# Process stdin by calling begin, line, and end functions for the backend
400 452
convert()
401 453
{
......
461 513
    convert d
462 514
}
463 515

  
464
# Choose backend
465
case "$1" in
466
"--nop" | "--simple" | "--ust" | "--dtrace") backend="${1#--}" ;;
467
*) usage ;;
468
esac
469
shift
470

  
471
case "$1" in
472
"-h") tracetoh ;;
473
"-c") tracetoc ;;
474
"-d") tracetod ;;
475
"--check-backend") exit 0 ;; # used by ./configure to test for backend
476
*) usage ;;
477
esac
516
tracetostap()
517
{
518
    if [ $backend != "dtrace" ]; then
519
       echo "SystemTAP tapset generator not applicable to $backend backend"
520
       exit 1
521
    fi
522
    if [ -z "$binary" ]; then
523
       echo "--binary is required for SystemTAP tapset generator"
524
       exit 1
525
    fi
526
    if [ -z "$targettype" ]; then
527
       echo "--target-type is required for SystemTAP tapset generator"
528
       exit 1
529
    fi
530
    if [ -z "$targetarch" ]; then
531
       echo "--target-arch is required for SystemTAP tapset generator"
532
       exit 1
533
    fi
534
    echo "/* This file is autogenerated by tracetool, do not edit. */"
535
    convert stap
536
}
537

  
538

  
539
backend=
540
output=
541
binary=
542
targettype=
543
targetarch=
544

  
545

  
546
until [ -z "$1" ]
547
do
548
  case "$1" in
549
    "--nop" | "--simple" | "--ust" | "--dtrace") backend="${1#--}" ;;
550

  
551
    "--binary") shift ; binary="$1" ;;
552
    "--target-arch") shift ; targetarch="$1" ;;
553
    "--target-type") shift ; targettype="$1" ;;
554

  
555
    "-h" | "-c" | "-d") output="${1#-}" ;;
556
    "--stap") output="${1#--}" ;;
557

  
558
    "--check-backend") exit 0 ;; # used by ./configure to test for backend
559

  
560
    *)
561
      usage;;
562
  esac
563
  shift
564
done
565

  
566
if [ "$backend" = "" -o "$output" = "" ]; then
567
  usage
568
fi
569

  
570
gen="traceto$output"
571
"$gen"
478 572

  
479 573
exit 0

Also available in: Unified diff