Received: from [140.186.70.92] (port=56614 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PDjTW-0007Ab-DI for qemu-devel@nongnu.org; Wed, 03 Nov 2010 15:58:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PDjTQ-0005Nz-M3 for qemu-devel@nongnu.org; Wed, 03 Nov 2010 15:58:22 -0400 Received: from mailout-de.gmx.net ([213.165.64.22]:46217 helo=mail.gmx.net) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PDjTQ-0005Ng-9W for qemu-devel@nongnu.org; Wed, 03 Nov 2010 15:58:20 -0400 From: =?utf-8?b?TGx1w61z?= Date: Wed, 03 Nov 2010 20:58:27 +0100 Message-ID: <20101103195827.6430.42020.stgit@ginnungagap.bsc.es> In-Reply-To: <20101103195814.6430.3786.stgit@ginnungagap.bsc.es> References: <20101103195814.6430.3786.stgit@ginnungagap.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v1 1/3] trace: rewrite 'tracetool' to facilitate future extensions List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Signed-off-by: LluĂ­s Vilanova --- Makefile | 4 - tracetool | 315 +++++++++++++++++++++++++++++++++++++------------------------ 2 files changed, 194 insertions(+), 125 deletions(-) diff --git a/Makefile b/Makefile index 252c817..fec086b 100644 --- a/Makefile +++ b/Makefile @@ -108,12 +108,12 @@ bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS) trace.h: trace.h-timestamp trace.h-timestamp: $(SRC_PATH)/trace-events config-host.mak - $(call quiet-command,sh $(SRC_PATH)/tracetool --$(TRACE_BACKEND) -h < $< > $@," GEN trace.h") + $(call quiet-command,sh $(SRC_PATH)/tracetool --regular --$(TRACE_BACKEND) -h < $< > $@," GEN trace.h") @cmp -s $@ trace.h || cp $@ trace.h trace.c: trace.c-timestamp trace.c-timestamp: $(SRC_PATH)/trace-events config-host.mak - $(call quiet-command,sh $(SRC_PATH)/tracetool --$(TRACE_BACKEND) -c < $< > $@," GEN trace.c") + $(call quiet-command,sh $(SRC_PATH)/tracetool --regular --$(TRACE_BACKEND) -c < $< > $@," GEN trace.c") @cmp -s $@ trace.c || cp $@ trace.c trace.o: trace.c $(GENERATED_HEADERS) diff --git a/tracetool b/tracetool index 7010858..4bd264f 100755 --- a/tracetool +++ b/tracetool @@ -10,28 +10,32 @@ # Disable pathname expansion, makes processing text with '*' characters simpler set -f -usage() -{ - cat >&2 <" ust_clean_namespace } -linetoh_ust() +line_h_ust() { - local name args argnames - name=$(get_name "$1") + local disable + disable=$(get_property "$1" "disable") + if [ "$disable" = "1" ]; then + line_h_nop "$1" + return + fi + + local name func args argnames + name=$(get_event_name "$1") + func=$(get_func_name "$1") args=$(get_args "$1") argnames=$(get_argnames "$1") cat < @@ -269,17 +291,23 @@ $(ust_clean_namespace) EOF } -linetoc_ust() +line_c_ust() { + local disable + disable=$(get_property "$1" "disable") + if [ "$disable" = "1" ]; then + line_c_nop "$1" + return + fi + local name args argnames fmt - name=$(get_name "$1") + name=$(get_event_name "$1") args=$(get_args "$1") argnames=$(get_argnames "$1") fmt=$(get_fmt "$1") cat <&2 < +Generate tracing code for a file on stdin. -/* This file is autogenerated by tracetool, do not edit. */ +Frontends: + --regular Regular frontend -#include "qemu-common.h" +Backends: + --nop Tracing disabled + --simple Simple built-in backend + --ust LTTng User Space Tracing backend + +Output formats: + -h Generate .h file + -c Generate .c file EOF - convert h - echo "#endif /* TRACE_H */" + exit 1 } -tracetoc() -{ - echo "/* This file is autogenerated by tracetool, do not edit. */" - convert c -} - -# Choose backend -case "$1" in -"--nop" | "--simple" | "--ust") backend="${1#--}" ;; -*) usage ;; -esac -shift - -case "$1" in -"-h") tracetoh ;; -"-c") tracetoc ;; -"--check-backend") exit 0 ;; # used by ./configure to test for backend -*) usage ;; -esac +while [ $# -gt 0 ]; do + case $1 in + "--regular") frontend="${1#--}" ;; + "--nop"|"--simple"|"--ust") backend="${1#--}" ;; + "-h"|"-c") output="${1#-}" ;; + "--check-backend") check=1 ;; # used by ./configure to test for backend + *) usage ;; + esac + shift +done + +if [ "$check" = "1" ]; then + [ "$backend" != "nil" ] || exit 1 + exit 0 +fi + +traceto_${output}_$frontend $frontend $backend exit 0