3 # Code generator for trace events
5 # Copyright IBM, Corp. 2010
7 # This work is licensed under the terms of the GNU GPL, version 2. See
8 # the COPYING file in the top-level directory.
10 # Disable pathname expansion, makes processing text with '*' characters simpler
16 usage: $0 --nop [-h | -c]
17 Generate tracing code for a file on stdin.
20 --nop Tracing disabled
29 # Get the name of a trace event
35 # Get the argument list of a trace event, including types and names
44 # Get the argument name list of a trace event
47 local nfields field name
49 for field
in $
(get_args
"$1"); do
50 nfields
=$
((nfields
+ 1))
55 # Only argument names have commas at the end
57 test "$field" = "$name" && continue
63 if [ "$nfields" -gt 1 ]
69 # Get the format string for a trace event
89 # Define an empty function for the trace event
91 static inline void trace_$name($args)
109 # No need for function definitions in nop backend
118 # Process stdin by calling begin, line, and end functions for the backend
121 local begin process_line end
122 begin
="lineto$1_begin_$backend"
123 process_line
="lineto$1_$backend"
124 end
="lineto$1_end_$backend"
128 while read -r str
; do
129 # Skip comments and empty lines
131 test -z "$str" && continue
134 "$process_line" "$str"
147 /* This file is autogenerated by tracetool, do not edit. */
149 #include "qemu-common.h"
152 echo "#endif /* TRACE_H */"
157 echo "/* This file is autogenerated by tracetool, do not edit. */"
163 "--nop") backend
="${1#--}" ;;
171 "--check-backend") exit 0 ;; # used by ./configure to test for backend