From patchwork Tue Jul 6 08:04:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prerna Saxena X-Patchwork-Id: 57991 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 6C4D61007D4 for ; Tue, 6 Jul 2010 19:22:22 +1000 (EST) Received: from localhost ([127.0.0.1]:55744 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OW4M6-0002dT-9v for incoming@patchwork.ozlabs.org; Tue, 06 Jul 2010 05:22:18 -0400 Received: from [140.186.70.92] (port=38216 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OW4L8-0002dM-Jt for qemu-devel@nongnu.org; Tue, 06 Jul 2010 05:21:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OW4L7-0000hV-5W for qemu-devel@nongnu.org; Tue, 06 Jul 2010 05:21:18 -0400 Received: from [202.81.31.141] (port=41607 helo=e23smtp08.au.ibm.com) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OW4L6-0000gg-He for qemu-devel@nongnu.org; Tue, 06 Jul 2010 05:21:17 -0400 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [202.81.31.246]) by e23smtp08.au.ibm.com (8.14.4/8.13.1) with ESMTP id o6684Nia001110 for ; Tue, 6 Jul 2010 18:04:23 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o6684OUa1257492 for ; Tue, 6 Jul 2010 18:04:24 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o6684NOO008092 for ; Tue, 6 Jul 2010 18:04:24 +1000 Received: from zephyr ([9.124.35.83]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o6684Mvf008014; Tue, 6 Jul 2010 18:04:22 +1000 Date: Tue, 6 Jul 2010 13:34:17 +0530 From: Prerna Saxena To: Stefan Hajnoczi Message-ID: <20100706133417.1a344397@zephyr> In-Reply-To: <20100701091839.GB2344@stefan-thinkpad.transitives.com> References: <20100630211145.41631855@zephyr> <20100701091839.GB2344@stefan-thinkpad.transitives.com> Organization: IBM X-Mailer: Claws Mail 3.7.5 (GTK+ 2.16.6; i586-redhat-linux-gnu) Mime-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Maneesh Soni , qemu-devel , Ananth Narayan Subject: [Qemu-devel] [RFC v2][PATCH][Tracing] Fix build errors for target i386-linux-user 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 On Thu, 1 Jul 2010 10:18:41 +0100 Stefan Hajnoczi wrote: > On Wed, Jun 30, 2010 at 09:11:45PM +0530, Prerna Saxena wrote: > > [PATCH 1/1] Move definitions of monitor command handlers (do_info_trace, > > do_info_all_trace_events) to monitor.c. This removes build errors for > > user targets such as i386-linux-user, which are not linked with monitor. > > > > The export of trace_buf and trace_idx is an unfortunate side effect, > > since these are needed by do_info_trace which dumps buffer > > contents. > > "git grep monitor_printf" suggests that other source files do their own > monitor printing. Did you look into alternatives that don't expose the > trace buffer internals? $grep "monitor_printf" would show this function being used in lot of places, but all of those include "monitor.h" and are linked to the monitor object as a part of the build process. I could not find any other definition of this function apart from the one in "monitor.c", and a dummy definition in qemu_tool.c. > > I feel #ifndef CONFIG_USER_ONLY in simpletrace.c would be would be nicer > than exposing the internals. (CONFIG_USER_ONLY is just a guess, I > haven't investigated which is the right thing to test for.) > > Stefan > Yes, I did explore some alternatives. The monitor command handlers for tracing need knowledge of buffer internals. The top-level trace object gets compiled earlier, and all target objects include this later at link time. None of the user targets (linux-user, bsd-user, darwin-user) are linked with monitor.o, and consequently the trace object when linked with these targets still has dangling references to monitor commands. This flags the linker errors. Even if I were to enclose the monitor-specific interfaces with a #ifdef...#endif , it would allow the trace-object to be built homogenously for all targets -- either with or without the code blocks enclosed in #ifdef..#endif. I am not being able to see how we can utilize CONFIG_USER_ONLY here. There are 3 ways I could think of, to fix this : a) Do not link the trace object for user targets, that don't link with monitor.o Advantage : errors disappear. Drawback : tracing not available for user targets. b) Keep the trace buffer definitions intact. In places where the linker doesn't find the monitor references, put a dummy file that has empty definitions for these monitor interfaces, and link the target object with these to remove the dangling references. Advantage : trace buffer internals are safeguarded. Drawback : Code & build process gets complicated ; not a clean approach. c) Separate the trace buffer functions and the monitor interfaces. In user targets, only the trace object is included which allows trace-events to be built for these targets as well. Just that, the monitor support is not available. Advantage : Clean separation of monitor commands and basic trace functionality. Drawback : Trace buffer internals get exposed. My earlier patch took approach 'c', the one below takes approach 'b'. This patch flags a compile warning : exec.o: warning: multiple common of `logfile' qemu-tool.o: warning: previous common is here I'm running short of ideas to fix this. Any suggestions would be very helpful. [PATCH] User targets dont include monitor.o. Fix to allow compilation of trace object for these. Signed-off-by: Prerna Saxena --- Makefile.target | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.target b/Makefile.target index 493233a..b05e37e 100644 --- a/Makefile.target +++ b/Makefile.target @@ -86,7 +86,7 @@ $(call set-vpath, $(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) obj-y = main.o syscall.o strace.o mmap.o signal.o thunk.o \ elfload.o linuxload.o uaccess.o gdbstub.o cpu-uname.o \ - qemu-malloc.o + qemu-malloc.o qemu-tool.o obj-$(TARGET_HAS_BFLT) += flatload.o @@ -124,7 +124,7 @@ LDFLAGS+=-Wl,-segaddr,__STD_PROG_ZONE,0x1000 -image_base 0x0e000000 LIBS+=-lmx obj-y = main.o commpage.o machload.o mmap.o signal.o syscall.o thunk.o \ - gdbstub.o + gdbstub.o qemu-tool.o obj-i386-y += ioport-user.o @@ -146,7 +146,7 @@ $(call set-vpath, $(SRC_PATH)/bsd-user) QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ARCH) obj-y = main.o bsdload.o elfload.o mmap.o signal.o strace.o syscall.o \ - gdbstub.o uaccess.o + gdbstub.o uaccess.o qemu-tool.o obj-i386-y += ioport-user.o