Revision 94a420b1

b/.gitignore
2 2
config-all-devices.*
3 3
config-host.*
4 4
config-target.*
5
trace.h
6
trace.c
5 7
*-softmmu
6 8
*-darwin-user
7 9
*-linux-user
b/Makefile
1 1
# Makefile for QEMU.
2 2

  
3
GENERATED_HEADERS = config-host.h
3
GENERATED_HEADERS = config-host.h trace.h
4 4

  
5 5
ifneq ($(wildcard config-host.mak),)
6 6
# Put the all: rule here so that config-host.mak can contain dependencies.
......
104 104

  
105 105
bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)
106 106

  
107
trace.h: $(SRC_PATH)/trace-events config-host.mak
108
	$(call quiet-command,sh $(SRC_PATH)/tracetool --$(TRACE_BACKEND) -h < $< > $@,"  GEN   $@")
109

  
110
trace.c: $(SRC_PATH)/trace-events config-host.mak
111
	$(call quiet-command,sh $(SRC_PATH)/tracetool --$(TRACE_BACKEND) -c < $< > $@,"  GEN   $@")
112

  
113
trace.o: trace.c $(GENERATED_HEADERS)
114

  
107 115
######################################################################
108 116

  
109 117
qemu-img.o: qemu-img-cmds.h
110 118
qemu-img.o qemu-tool.o qemu-nbd.o qemu-io.o: $(GENERATED_HEADERS)
111 119

  
112
qemu-img$(EXESUF): qemu-img.o qemu-tool.o qemu-error.o $(block-obj-y) $(qobject-obj-y)
120
qemu-img$(EXESUF): qemu-img.o qemu-tool.o qemu-error.o $(trace-obj-y) $(block-obj-y) $(qobject-obj-y)
113 121

  
114
qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o qemu-error.o $(block-obj-y) $(qobject-obj-y)
122
qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o qemu-error.o $(trace-obj-y) $(block-obj-y) $(qobject-obj-y)
115 123

  
116
qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o $(block-obj-y) $(qobject-obj-y)
124
qemu-io$(EXESUF): qemu-io.o cmd.o qemu-tool.o qemu-error.o $(trace-obj-y) $(block-obj-y) $(qobject-obj-y)
117 125

  
118 126
qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
119 127
	$(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@,"  GEN   $@")
......
133 141
	rm -f *.o *.d *.a $(TOOLS) TAGS cscope.* *.pod *~ */*~
134 142
	rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d net/*.o net/*.d fsdev/*.o fsdev/*.d ui/*.o ui/*.d
135 143
	rm -f qemu-img-cmds.h
144
	rm -f trace.c trace.h
136 145
	$(MAKE) -C tests clean
137 146
	for d in $(ALL_SUBDIRS) libhw32 libhw64 libuser libdis libdis-user; do \
138 147
	if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \
b/Makefile.objs
265 265
libdis-$(CONFIG_SH4_DIS) += sh4-dis.o
266 266
libdis-$(CONFIG_SPARC_DIS) += sparc-dis.o
267 267

  
268
######################################################################
269
# trace
270

  
271
trace-obj-y = trace.o
272

  
268 273
vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
269 274

  
270 275
vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS)
b/Makefile.target
310 310

  
311 311
endif # CONFIG_SOFTMMU
312 312

  
313
obj-y += $(addprefix ../, $(trace-obj-y))
313 314
obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o
314 315

  
315 316
$(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y)
b/configure
317 317
check_utests="no"
318 318
user_pie="no"
319 319
zero_malloc=""
320
trace_backend="nop"
320 321

  
321 322
# OS specific
322 323
if check_define __linux__ ; then
......
519 520
  ;;
520 521
  --target-list=*) target_list="$optarg"
521 522
  ;;
523
  --trace-backend=*) trace_backend="$optarg"
524
  ;;
522 525
  --enable-gprof) gprof="yes"
523 526
  ;;
524 527
  --static)
......
897 900
echo "  --disable-docs           disable documentation build"
898 901
echo "  --disable-vhost-net      disable vhost-net acceleration support"
899 902
echo "  --enable-vhost-net       enable vhost-net acceleration support"
903
echo "  --trace-backend=B        Trace backend nop"
900 904
echo ""
901 905
echo "NOTE: The object files are built at the place where configure is launched"
902 906
exit 1
......
2059 2063
    fdatasync=yes
2060 2064
fi
2061 2065

  
2066
##########################################
2067
# check if trace backend exists
2068

  
2069
sh "$source_path/tracetool" "--$trace_backend" --check-backend > /dev/null 2> /dev/null
2070
if test "$?" -ne 0 ; then
2071
  echo
2072
  echo "Error: invalid trace backend"
2073
  echo "Please choose a supported trace backend."
2074
  echo
2075
  exit 1
2076
fi
2077

  
2062 2078
# End of CC checks
2063 2079
# After here, no more $cc or $ld runs
2064 2080

  
......
2189 2205
echo "fdatasync         $fdatasync"
2190 2206
echo "uuid support      $uuid"
2191 2207
echo "vhost-net support $vhost_net"
2208
echo "Trace backend     $trace_backend"
2192 2209

  
2193 2210
if test $sdl_too_old = "yes"; then
2194 2211
echo "-> Your SDL version is too old - please upgrade to have SDL support"
......
2450 2467
;;
2451 2468
esac
2452 2469

  
2470
echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak
2453 2471
echo "TOOLS=$tools" >> $config_host_mak
2454 2472
echo "ROMS=$roms" >> $config_host_mak
2455 2473
echo "MAKE=$make" >> $config_host_mak
b/trace-events
1
# Trace events for debugging and performance instrumentation
2
#
3
# This file is processed by the tracetool script during the build.
4
#
5
# To add a new trace event:
6
#
7
# 1. Choose a name for the trace event.  Declare its arguments and format
8
#    string.
9
#
10
# 2. Call the trace event from code using trace_##name, e.g. multiwrite_cb() ->
11
#    trace_multiwrite_cb().  The source file must #include "trace.h".
12
#
13
# Format of a trace event:
14
#
15
# <name>(<type1> <arg1>[, <type2> <arg2>] ...) "<format-string>"
16
#
17
# Example: qemu_malloc(size_t size) "size %zu"
18
#
19
# The <name> must be a valid as a C function name.
20
#
21
# Types should be standard C types.  Use void * for pointers because the trace
22
# system may not have the necessary headers included.
23
#
24
# The <format-string> should be a sprintf()-compatible format string.
b/tracetool
1
#!/bin/sh
2
#
3
# Code generator for trace events
4
#
5
# Copyright IBM, Corp. 2010
6
#
7
# This work is licensed under the terms of the GNU GPL, version 2.  See
8
# the COPYING file in the top-level directory.
9

  
10
# Disable pathname expansion, makes processing text with '*' characters simpler
11
set -f
12

  
13
usage()
14
{
15
    cat >&2 <<EOF
16
usage: $0 --nop [-h | -c]
17
Generate tracing code for a file on stdin.
18

  
19
Backends:
20
  --nop Tracing disabled
21

  
22
Output formats:
23
  -h    Generate .h file
24
  -c    Generate .c file
25
EOF
26
    exit 1
27
}
28

  
29
# Get the name of a trace event
30
get_name()
31
{
32
    echo ${1%%\(*}
33
}
34

  
35
# Get the argument list of a trace event, including types and names
36
get_args()
37
{
38
    local args
39
    args=${1#*\(}
40
    args=${args%)*}
41
    echo "$args"
42
}
43

  
44
# Get the argument name list of a trace event
45
get_argnames()
46
{
47
    local nfields field name
48
    nfields=0
49
    for field in $(get_args "$1"); do
50
        nfields=$((nfields + 1))
51

  
52
        # Drop pointer star
53
        field=${field#\*}
54

  
55
        # Only argument names have commas at the end
56
        name=${field%,}
57
        test "$field" = "$name" && continue
58

  
59
        printf "%s" "$name, "
60
    done
61

  
62
    # Last argument name
63
    if [ "$nfields" -gt 1 ]
64
    then
65
        printf "%s" "$name"
66
    fi
67
}
68

  
69
# Get the format string for a trace event
70
get_fmt()
71
{
72
    local fmt
73
    fmt=${1#*\"}
74
    fmt=${fmt%\"*}
75
    echo "$fmt"
76
}
77

  
78
linetoh_begin_nop()
79
{
80
    return
81
}
82

  
83
linetoh_nop()
84
{
85
    local name args
86
    name=$(get_name "$1")
87
    args=$(get_args "$1")
88

  
89
    # Define an empty function for the trace event
90
    cat <<EOF
91
static inline void trace_$name($args)
92
{
93
}
94
EOF
95
}
96

  
97
linetoh_end_nop()
98
{
99
    return
100
}
101

  
102
linetoc_begin_nop()
103
{
104
    return
105
}
106

  
107
linetoc_nop()
108
{
109
    # No need for function definitions in nop backend
110
    return
111
}
112

  
113
linetoc_end_nop()
114
{
115
    return
116
}
117

  
118
# Process stdin by calling begin, line, and end functions for the backend
119
convert()
120
{
121
    local begin process_line end
122
    begin="lineto$1_begin_$backend"
123
    process_line="lineto$1_$backend"
124
    end="lineto$1_end_$backend"
125

  
126
    "$begin"
127

  
128
    while read -r str; do
129
        # Skip comments and empty lines
130
        str=${str%%#*}
131
        test -z "$str" && continue
132

  
133
        echo
134
        "$process_line" "$str"
135
    done
136

  
137
    echo
138
    "$end"
139
}
140

  
141
tracetoh()
142
{
143
    cat <<EOF
144
#ifndef TRACE_H
145
#define TRACE_H
146

  
147
/* This file is autogenerated by tracetool, do not edit. */
148

  
149
#include "qemu-common.h"
150
EOF
151
    convert h
152
    echo "#endif /* TRACE_H */"
153
}
154

  
155
tracetoc()
156
{
157
    echo "/* This file is autogenerated by tracetool, do not edit. */"
158
    convert c
159
}
160

  
161
# Choose backend
162
case "$1" in
163
"--nop") backend="${1#--}" ;;
164
*) usage ;;
165
esac
166
shift
167

  
168
case "$1" in
169
"-h") tracetoh ;;
170
"-c") tracetoc ;;
171
"--check-backend") exit 0 ;; # used by ./configure to test for backend
172
*) usage ;;
173
esac
174

  
175
exit 0

Also available in: Unified diff