From patchwork Mon Nov 8 19:33:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 70450 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 98339B70FB for ; Tue, 9 Nov 2010 06:34:48 +1100 (EST) Received: from localhost ([127.0.0.1]:48538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFXUL-0008O7-N8 for incoming@patchwork.ozlabs.org; Mon, 08 Nov 2010 14:34:45 -0500 Received: from [140.186.70.92] (port=33801 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PFXT3-0008N0-Uw for qemu-devel@nongnu.org; Mon, 08 Nov 2010 14:33:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PFXT1-0000co-6i for qemu-devel@nongnu.org; Mon, 08 Nov 2010 14:33:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:10509) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PFXT0-0000cX-Vx for qemu-devel@nongnu.org; Mon, 08 Nov 2010 14:33:23 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA8JXMQK024661 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 8 Nov 2010 14:33:22 -0500 Received: from t500wlan.home.berrange.com.com (vpn1-4-250.ams2.redhat.com [10.36.4.250]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oA8JXIsa019783; Mon, 8 Nov 2010 14:33:21 -0500 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Mon, 8 Nov 2010 19:33:08 +0000 Message-Id: <1289244788-19961-3-git-send-email-berrange@redhat.com> In-Reply-To: <1289244788-19961-1-git-send-email-berrange@redhat.com> References: <1289244788-19961-1-git-send-email-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH 2/2] Add support for generating a systemtap tapset static probes 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 This introduces generation of a qemu.stp/qemu-system-XXX.stp files which provides tapsets with friendly names for static probes & their arguments. Instead of probe process("qemu").mark("qemu_malloc") { printf("Malloc %d %p\n", $arg1, $arg2); } It is now possible todo probe qemu.system.i386.qemu_malloc { printf("Malloc %d %p\n", size, ptr); } There is one tapset defined per target arch. * Makefile: Generate a qemu.stp file for systemtap * tracetool: Support for generating systemtap tapsets Signed-off-by: Daniel P. Berrange --- Makefile.target | 19 +++++++++++- configure | 7 ++++ tracetool | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 1 deletions(-) diff --git a/Makefile.target b/Makefile.target index 91e6e74..a5e6410 100644 --- a/Makefile.target +++ b/Makefile.target @@ -40,7 +40,20 @@ kvm.o kvm-all.o vhost.o vhost_net.o: QEMU_CFLAGS+=$(KVM_CFLAGS) config-target.h: config-target.h-timestamp config-target.h-timestamp: config-target.mak -all: $(PROGS) +ifdef CONFIG_SYSTEMTAP_TRACE +trace: $(QEMU_PROG).stp + +$(QEMU_PROG).stp: + $(call quiet-command,sh $(SRC_PATH)/tracetool \ + --$(TRACE_BACKEND) \ + --bindir $(bindir) \ + --target $(TARGET_ARCH) \ + -s < $(SRC_PATH)/trace-events > $(QEMU_PROG).stp," GEN $(QEMU_PROG).stp") +else +trace: +endif + +all: $(PROGS) trace # Dummy command so that make thinks it has done something @true @@ -348,6 +361,10 @@ ifneq ($(STRIP),) $(STRIP) $(patsubst %,"$(DESTDIR)$(bindir)/%",$(PROGS)) endif endif +ifdef CONFIG_SYSTEMTAP_TRACE + $(INSTALL_DIR) "$(DESTDIR)$(datadir)/../systemtap/tapset" + $(INSTALL_DATA) $(QEMU_PROG).stp "$(DESTDIR)$(datadir)/../systemtap/tapset" +endif # Include automatically generated dependency files -include $(wildcard *.d */*.d) diff --git a/configure b/configure index f8dad3e..e560f87 100755 --- a/configure +++ b/configure @@ -2192,6 +2192,10 @@ EOF echo exit 1 fi + trace_backend_stap="no" + if has 'stap' ; then + trace_backend_stap="yes" + fi fi ########################################## @@ -2645,6 +2649,9 @@ fi if test "$trace_backend" = "simple"; then trace_file="\"$trace_file-%u\"" fi +if test "$trace_backend" = "dtrace" -a "$trace_backend_stap" = "yes" ; then + echo "CONFIG_SYSTEMTAP_TRACE=y" >> $config_host_mak +fi echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak echo "TOOLS=$tools" >> $config_host_mak diff --git a/tracetool b/tracetool index 5b6636a..d797ab7 100755 --- a/tracetool +++ b/tracetool @@ -26,6 +26,12 @@ Output formats: -h Generate .h file -c Generate .c file -d Generate .d file (DTrace only) + -s Generate .stp file (DTrace with SystemTAP only) + +Options: + --bindir [bindir] QEMU binary install location + --target [arch] QEMU target architecture + EOF exit 1 } @@ -390,6 +396,54 @@ linetod_end_dtrace() EOF } +linetos_begin_dtrace() +{ + return +} + +linetos_dtrace() +{ + local name args arglist state + name=$(get_name "$1") + args=$(get_args "$1") + arglist=$(get_argnames "$1", "") + state=$(get_state "$1") + if [ "$state" = "0" ] ; then + name=${name##disable } + fi + + if [ "$target" = "i386" ] + then + binary="qemu" + else + binary="qemu-system-$target" + fi + + # Define prototype for probe arguments + cat <