From patchwork Thu Nov 4 22:36:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?Q?Llu=C3=ADs?= X-Patchwork-Id: 70179 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9382AB70D5 for ; Fri, 5 Nov 2010 09:43:21 +1100 (EST) Received: from localhost ([127.0.0.1]:37952 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PE8Vs-00089r-AX for incoming@patchwork.ozlabs.org; Thu, 04 Nov 2010 18:42:32 -0400 Received: from [140.186.70.92] (port=41522 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PE8PV-0005EM-3d for qemu-devel@nongnu.org; Thu, 04 Nov 2010 18:36:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PE8PM-0002bz-Hz for qemu-devel@nongnu.org; Thu, 04 Nov 2010 18:35:50 -0400 Received: from mailout-de.gmx.net ([213.165.64.23]:59904 helo=mail.gmx.net) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PE8PM-0002bo-38 for qemu-devel@nongnu.org; Thu, 04 Nov 2010 18:35:48 -0400 Received: (qmail invoked by alias); 04 Nov 2010 22:35:46 -0000 Received: from unknown (EHLO localhost) [84.88.53.92] by mail.gmx.net (mp019) with SMTP; 04 Nov 2010 23:35:46 +0100 X-Authenticated: #12333383 X-Provags-ID: V01U2FsdGVkX1+vKDEziUevFPEJl0cK4SLXsDQxU5Uq1xNaICnpF9 zjY/gZxv9hjgAt To: qemu-devel@nongnu.org From: =?utf-8?b?TGx1w61z?= Date: Thu, 04 Nov 2010 23:36:08 +0100 Message-ID: <20101104223608.16785.31765.stgit@ginnungagap.bsc.es> In-Reply-To: <20101104223552.16785.84410.stgit@ginnungagap.bsc.es> References: <20101104223552.16785.84410.stgit@ginnungagap.bsc.es> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH v2 1/3] trace: rewrite 'tracetool' to facilitate future extensions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: LluĂ­s Vilanova --- Makefile | 4 - tracetool | 313 +++++++++++++++++++++++++++++++++++++------------------------ 2 files changed, 192 insertions(+), 125 deletions(-) diff --git a/Makefile b/Makefile index 02698e9..2ba52aa 100644 --- a/Makefile +++ b/Makefile @@ -110,12 +110,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..c5ae6a7 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