From: Lluís <xscript@gmx.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v1 3/3] trace-instrument: handle config-time activation
Date: Wed, 03 Nov 2010 20:58:43 +0100 [thread overview]
Message-ID: <20101103195842.6430.82405.stgit@ginnungagap.bsc.es> (raw)
In-Reply-To: <20101103195814.6430.3786.stgit@ginnungagap.bsc.es>
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 <vilanova@ac.upc.edu>
---
Makefile.target | 29 ++++++++++++++++++++++++++---
configure | 30 ++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 3 deletions(-)
diff --git a/Makefile.target b/Makefile.target
index 9152723..90867e7 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 991f0b8..2476512 100755
--- a/configure
+++ b/configure
@@ -332,6 +332,7 @@ trace_backend="nop"
trace_file="trace"
spice=""
backdoor=""
+instrument=""
# OS specific
if check_define __linux__ ; then
@@ -752,6 +753,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
@@ -943,6 +960,8 @@ echo " --trace-file=NAME Full PATH,NAME of file to store traces"
echo " Default:trace-<pid>"
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
@@ -2335,6 +2354,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"
@@ -2600,6 +2622,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
prev parent reply other threads:[~2010-11-03 19:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-03 19:58 [Qemu-devel] [RFC][PATCH v1 0/3] trace-instrument: let the user wrap/override code generated from trace-events Lluís
2010-11-03 19:58 ` [Qemu-devel] [PATCH v1 1/3] trace: rewrite 'tracetool' to facilitate future extensions Lluís
2010-11-03 19:58 ` [Qemu-devel] [PATCH v1 2/3] trace-instrument: let the user override events generated by 'tracetool' Lluís
2010-11-03 19:58 ` Lluís [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101103195842.6430.82405.stgit@ginnungagap.bsc.es \
--to=xscript@gmx.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).