From patchwork Thu Nov 4 22:36:41 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: 70200 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 77547B70D5 for ; Fri, 5 Nov 2010 10:16:22 +1100 (EST) Received: from localhost ([127.0.0.1]:37064 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PE8iF-0004k1-5i for incoming@patchwork.ozlabs.org; Thu, 04 Nov 2010 18:55:19 -0400 Received: from [140.186.70.92] (port=41695 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PE8Q1-0005cA-Fd for qemu-devel@nongnu.org; Thu, 04 Nov 2010 18:36:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PE8Pt-0002ge-Ni for qemu-devel@nongnu.org; Thu, 04 Nov 2010 18:36:22 -0400 Received: from mailout-de.gmx.net ([213.165.64.23]:36461 helo=mail.gmx.net) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PE8Pt-0002gU-AP for qemu-devel@nongnu.org; Thu, 04 Nov 2010 18:36:21 -0400 Received: (qmail invoked by alias); 04 Nov 2010 22:36:19 -0000 Received: from unknown (EHLO localhost) [84.88.53.92] by mail.gmx.net (mp037) with SMTP; 04 Nov 2010 23:36:19 +0100 X-Authenticated: #12333383 X-Provags-ID: V01U2FsdGVkX1/kAE1c3prkpEyaHSAMTmzs/JWq6KwPcwCp/49zrk iG/8geD4M+G/yf To: qemu-devel@nongnu.org From: =?utf-8?b?TGx1w61z?= Date: Thu, 04 Nov 2010 23:36:41 +0100 Message-ID: <20101104223641.16785.99787.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: GNU/Linux 2.6 (newer, 3) Subject: [Qemu-devel] [PATCH v2 3/3] trace-instrument: handle config-time activation 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 Add a '--with-instrument' configuration option pointing to user-provided instrumentation callbacks. Make is invoked on the user-provided directory, which must build a static library that might contain extra code needed by the user-provided instrumentation. Signed-off-by: LluĂ­s Vilanova --- Makefile.target | 29 ++++++++++++++++++++++++++--- configure | 30 ++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/Makefile.target b/Makefile.target index da6ee03..7a92e02 100644 --- a/Makefile.target +++ b/Makefile.target @@ -351,12 +351,35 @@ libbackdoor-clean: VPATH=$(VPATH) SRC_PATH=$(SRC_PATH) V="$(V)" clean || true endif +######################################################### +# static instrumentation +ifdef CONFIG_INSTRUMENT +VPATH := $(VPATH):$(INSTRUMENT_PATH) + +LIBINSTRUMENT_LIB = libinstrument/libinstrument.a +LIBINSTRUMENT_CLEAN = libinstrument-clean + +libinstrument/Makefile: + $(call quiet-command, mkdir -p libinstrument, " CREAT $(TARGET_DIR)$@") + $(call quiet-command, rm -f libinstrument/Makefile) + $(call quiet-command, ln -s $(INSTRUMENT_PATH)/Makefile libinstrument/Makefile) + +libinstrument/libinstrument.a: libinstrument/Makefile force + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libinstrument \ + QEMU_CFLAGS="$(QEMU_CFLAGS) -I../target-$(TARGET_BASE_ARCH)" \ + TARGET_DIR=$(TARGET_DIR)libinstrument/ VPATH=$(VPATH) \ + SRC_PATH=$(SRC_PATH) V="$(V)" libinstrument.a) + +libinstrument-clean: + $(MAKE) $(SUBDIR_MAKEFLAGS) -C $(LIBINSTRUMENT_DIR) \ + VPATH=$(VPATH) SRC_PATH=$(SRC_PATH) V="$(V)" clean || true +endif -$(QEMU_PROG)-prepare: $(GENERATED_HEADERS) $(LIBBACKDOOR_LIB) $(QEMU_PROG) +$(QEMU_PROG)-prepare: $(GENERATED_HEADERS) $(LIBBACKDOOR_LIB) $(LIBINSTRUMENT_LIB) $(QEMU_PROG) -$(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y) $(LIBBACKDOOR_LIB) - $(call LINK,$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y)) $(LIBBACKDOOR_LIB) +$(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y) $(LIBBACKDOOR_LIB) $(LIBINSTRUMENT_LIB) + $(call LINK,$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y)) $(LIBBACKDOOR_LIB) $(LIBINSTRUMENT_LIB) gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/feature_to_c.sh diff --git a/configure b/configure index e6fbf97..40f94bf 100755 --- a/configure +++ b/configure @@ -333,6 +333,7 @@ trace_backend="nop" trace_file="trace" spice="" backdoor="" +instrument="" # OS specific if check_define __linux__ ; then @@ -753,6 +754,22 @@ for opt do backdoor=`readlink -f $backdoor` fi ;; + --with-instrument=*) instrument="$optarg" + if test ! -f "$instrument/Makefile"; then + echo + echo "Error: cannot make into '$instrument'" + echo "Please choose a directory where I can run 'make'" + echo + exit 1 + elif test ! -f "$instrument/trace-instrument.h"; then + echo + echo "Error: directory '$instrument' does not contain a \"trace-instrument.h\" file" + echo + exit 1 + else + instrument=`readlink -f $instrument` + fi + ;; *) echo "ERROR: unknown option $opt"; show_help="yes" ;; esac @@ -946,6 +963,8 @@ echo " --trace-file=NAME Full PATH,NAME of file to store traces" echo " Default:trace-" echo " --disable-spice disable spice" echo " --enable-spice enable spice" +echo " --with-backdoor=PATH enable backdoor communication and compile implementation in PATH" +echo " --with-instrument=PATH enable static instrumentation and compile user code in PATH" echo "" echo "NOTE: The object files are built at the place where configure is launched" exit 1 @@ -2353,6 +2372,9 @@ echo "spice support $spice" if test -n "$backdoor"; then echo "Backdoor comm. $backdoor" fi +if test -n "$instrument"; then + echo "Instrumentation $instrument" +fi if test $sdl_too_old = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support" @@ -2622,6 +2644,14 @@ if test -n "$backdoor"; then rm -rf *-{bsd-usr,darwin-user,linux-user,softmmu}/libbackdoor/ fi +if test -n "$instrument"; then + echo "CONFIG_INSTRUMENT=y" >> $config_host_mak + echo "INSTRUMENT_PATH=$instrument" >> $config_host_mak + echo "TRACETOOL_EXTRA=--instrument" >> $config_host_mak + QEMU_CFLAGS="-I$instrument $QEMU_CFLAGS" + rm -rf *-{bsd-usr,darwin-user,linux-user,softmmu}/libinstrument/ +fi + # XXX: suppress that if [ "$bsd" = "yes" ] ; then echo "CONFIG_BSD=y" >> $config_host_mak