Received: from [140.186.70.92] (port=47049 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OW7Wm-0002oD-Lk for qemu-devel@nongnu.org; Tue, 06 Jul 2010 08:45:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OW7Wl-0000hJ-5e for qemu-devel@nongnu.org; Tue, 06 Jul 2010 08:45:32 -0400 Received: from mtagate1.uk.ibm.com ([194.196.100.161]:38035) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OW7Wk-0000h9-TF for qemu-devel@nongnu.org; Tue, 06 Jul 2010 08:45:31 -0400 Received: from d06nrmr1806.portsmouth.uk.ibm.com (d06nrmr1806.portsmouth.uk.ibm.com [9.149.39.193]) by mtagate1.uk.ibm.com (8.13.1/8.13.1) with ESMTP id o66CjT6O021423 for ; Tue, 6 Jul 2010 12:45:29 GMT Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o66CjPTS1450142 for ; Tue, 6 Jul 2010 13:45:29 +0100 Received: from d06av04.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o66CjOFX016253 for ; Tue, 6 Jul 2010 13:45:24 +0100 Date: Tue, 6 Jul 2010 13:45:23 +0100 From: Stefan Hajnoczi Message-ID: <20100706124523.GB6651@stefan-thinkpad.transitives.com> References: <20100705223919.324fdf4a@in.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100705223919.324fdf4a@in.ibm.com> Subject: [Qemu-devel] Re: Reg. trace infrastructure List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sripathi Kodi Cc: "qemu-devel@nongnu.org" , Prerna Saxena On Mon, Jul 05, 2010 at 10:39:19PM +0530, Sripathi Kodi wrote: > Hi Stefan, Prerna, > > I pulled down QEMU tracing code from git://repo.or.cz/qemu/stefanha.git > and tried to use it to trace something in virtio-9p code. I don't have > any knowledge of how traces are implemented and I just went with the > documentation. With help from Prerna, I was able to insert a trace > point and observe it getting hit from the QEMU monitor. However, I have > a few questions about this. Could you please help me out? Great, thanks for trying out tracing. This is useful feedback and is going to help us decide what to work on next. > *) My understanding is the traces are dumped to a file only when the > trace buffer gets filled. Is there a way to: > a) Forcibly dump the contents of the buffer when needed. There is currently no way to do this. > b) When QEMU exits it should dump the buffer. Doesn't seem to be > doing this now. I will add a commit to fix this. Once the buffer can be dumped out on exit it should also be easy to add a monitor command to do this any time (solves point a). > c) A way to specify the file into which it writes the traces. There is currently no way to do this. I think we need a trace file management command, something like: trace start Opens a trace file trace stop Flushes and closes the trace file trace flush Flushes the trace buffer to the file Prerna also has a patch to inspect the trace buffer in memory - before it is flushed to file. I'm not sure how we want to integrate this with the trace file management command. > *) Is QEMU monitor the only way to enable/disable trace points? Is it > possible to programmatically enable/disable trace points from within > QEMU code? If that is not possible, is it possible to specify all trace > points to be enabled in a text file and ask QEMU to read the file when > it starts up? These are good ideas. There is currently no "enable virtio_*" wildcard support and even that wouldn't allow enabling/disable per source file. Trace events could be grouped (e.g. by file) or even tagged if this feature is desirable. Currently the trace-events file already has comments naming the source files of each group of trace events. Programmatically enabling/disabling trace events is possible with: #include "trace.h" change_trace_event_state("virtio_irq", true); /* enable */ [...] change_trace_event_state("virtio_irq", false); /* disable */ I like the idea of loading a list of trace events to enable on startup. We need to support both tracing from startup and toggling trace events at runtime. > *) Is it possible to enable/disable a bunch of trace points at one > shot? Can trace points be grouped in some way? Can I say "enable all > trace points in a particular .c file" or "enable all trace points in > these 2 functions"? Not yet, explained more above. There is still a ways to go before tracing is usable. Thanks for sharing your ideas! Today we created a skeleton wiki page where I hope we can plan which use cases and commands should be possible: http://wiki.qemu.org/Features/Tracing Stefan