From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47964 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OsdPW-00057C-3X for qemu-devel@nongnu.org; Mon, 06 Sep 2010 11:15:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OsdPN-0003yW-TF for qemu-devel@nongnu.org; Mon, 06 Sep 2010 11:15:06 -0400 Received: from mtagate7.de.ibm.com ([195.212.17.167]:49147) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OsdPN-0003xi-Fo for qemu-devel@nongnu.org; Mon, 06 Sep 2010 11:14:57 -0400 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate7.de.ibm.com (8.13.1/8.13.1) with ESMTP id o86FEt3d018315 for ; Mon, 6 Sep 2010 15:14:55 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o86FEn3W4132876 for ; Mon, 6 Sep 2010 17:14:55 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o86FEmpS017905 for ; Mon, 6 Sep 2010 17:14:49 +0200 From: Stefan Hajnoczi Date: Mon, 6 Sep 2010 16:13:57 +0100 Message-Id: <1283786051-29530-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v3 00/14] trace: Add static tracing to QEMU List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Blue Swirl , Anthony Liguori , "Michael S. Tsirkin" , Prerna Saxena This patch series adds static tracing to QEMU. It can be used to instrument QEMU code by means of lightweight logging called trace events. Prerna and I are now posting the entire patch series with a serious eye towards checking we meet users' and developers' tracing needs and with the goal of getting this functionality merged into qemu.git. Tracing infrastructure allows debugging, performance analysis, and observation to be performed. Right now there are ad-hoc logging calls in some source files which require rebuilding QEMU with certain #defines and perform poorly. This patch series introduces a single tracing infrastructure which is easy to use and can replace ad-hoc techniques. Two key points: 1. The trace-events file contains the set of defined trace events which can be called from a source file. For example, trace-events has: qemu_malloc(size_t size, void *ptr) "size %zu ptr %p" and qemu-malloc.c uses this trace event like this: #include "trace.h" /* needed for trace event prototype */ void *qemu_malloc(size_t size) { void *ptr; if (!size && !allow_zero_malloc()) { abort(); } ptr = oom_check(malloc(size ? size : 1)); trace_qemu_malloc(size, ptr); /* <-- trace event */ return ptr; } 2. The built-in 'simple' trace backend writes binary traces to trace-. They can be pretty-printed like this: ./simpletrace.py trace-events trace-* Although you can also try LTTng Userspace Tracer ('ust' trace backend), the 'simple' trace backend provides commands within the QEMU monitor to enable/disable trace events at runtime. It is easy to use and should serve as a good default trace backend. The 'simple' trace backend's limitation is that it isn't thread-safe and can therefore only trace correctly when the QEMU global mutex is held. For full documentation, see: http://repo.or.cz/w/qemu/stefanha.git/blob_plain/refs/heads/tracing_v3:/docs/tracing.txt The git branch is here: http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/tracing_v3 Changes in v3: * write trace files to current working directory by default * avoid adding -lust to LIBS twice Changes in v2: * add 6th argument to trace record to avoid changing file format later * add type usage documentation for trace event declarations * switch to QemuOptsList for -trace command-line option * use atexit() once and only once to flush the trace buffer * keep disabled event ids in sync between tracetool and simpletrace.py * change echo -n to printf for portability * move #include statements to correct spot in the patch series * fix style issues from code review