All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>
Subject: [Qemu-devel] [PATCH v2 46/47] trace: update docs to reflect new code generation approach
Date: Fri,  6 Jan 2017 15:55:42 +0000	[thread overview]
Message-ID: <20170106155543.12827-47-berrange@redhat.com> (raw)
In-Reply-To: <20170106155543.12827-1-berrange@redhat.com>

Describe use of per-subdir trace events files and how it impacts
code generation.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 docs/tracing.txt | 61 +++++++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 52 insertions(+), 9 deletions(-)

diff --git a/docs/tracing.txt b/docs/tracing.txt
index f351998a..3262a61 100644
--- a/docs/tracing.txt
+++ b/docs/tracing.txt
@@ -27,18 +27,51 @@ for debugging, profiling, and observing execution.
 
 == Trace events ==
 
+=== Sub-directory setup ===
+
 Each directory in the source tree can declare a set of static trace events
-in a "trace-events" file. Each trace event declaration names the event, its
-arguments, and the format string which can be used for pretty-printing:
+in a "trace-events" file. The first (non-comment) statement in the file
+must be "@id_offset(NN)" where NN is an integer that is unique among all
+"trace-events" files in the QEMU source tree. The IDs can be arbitrarily
+chosen, but for extra fun the current "trace-events" files use values from
+the "powerful number" integer sequence :-)
 
-    qemu_vmalloc(size_t size, void *ptr) "size %zu ptr %p"
-    qemu_vfree(void *ptr) "ptr %p"
+Any subdirectory which contains a "trace-events" file must be listed in the
+"trace-events-subdirs" make variable in the top level Makefile.objs. During
+build, the "trace-events" file in each listed subdirectory will be processed
+by the "tracetool" script to generate code for the trace events.
+
+The individual "trace-events" files are merged together into a "trace-events-all"
+file, which is also installed into "/usr/share/qemu" with the name "trace-events".
+This merge file is to be used by the "simpletrace.py" script to later analyse
+traces in the simpletrace data format.
+
+The Makefile.objs in the subdirectory should have two lines added
+
+  trace-obj-y += trace.o
+  trace-obj-$(CONFIG_TRACE_DTRACE) += trace-dtrace.o
+
+In the sub-directory the following files will be automatically generated
+
+ - trace.c - the trace event state declarations
+ - trace.h - the trace event enums and probe functions
+ - trace-dtrace.h - DTrace speci
+ - trace-dtrace.dtrace - DTrace event probe helper declaration
+ - trace-dtrace.o - binary DTrace provider (generated by dtrace)
+ - trace-ust.h - UST event probe helper declarations
+
+Source files in the sub-directory should only #include the 'trace.h'
+file and use the full sub-directory path. eg io/channel-buffer.c
+would do
 
-All "trace-events" files must be listed in the "trace-event-y" make variable
-in the top level Makefile.objs. During build the individual files are combined
-to create a "trace-events-all" file, which is processed by the "tracetool"
-script during build to generate code for the trace events. The
-"trace-events-all" file is also installed into "/usr/share/qemu".
+  #include "io/trace.h"
+
+While it is permited to include a trace.h file from outside a source
+files' own sub-directory, this is discouraged in general. It is strongly
+preferred that all events be declared directly in the sub-directory that
+uses them.
+
+=== Using trace events ===
 
 Trace events are invoked directly from source code like this:
 
@@ -83,6 +116,13 @@ Format strings should reflect the types defined in the trace event.  Take
 special care to use PRId64 and PRIu64 for int64_t and uint64_t types,
 respectively.  This ensures portability between 32- and 64-bit platforms.
 
+Each event declaration will start with the event name, then its arguments,
+finally a format string for pretty-printing. For example:
+
+    qemu_vmalloc(size_t size, void *ptr) "size %zu ptr %p"
+    qemu_vfree(void *ptr) "ptr %p"
+
+
 === Hints for adding new trace events ===
 
 1. Trace state changes in the code.  Interesting points in the code usually
@@ -372,6 +412,9 @@ information. If used together with the "tcg" property, it adds a second
 "TCGv_env" argument that must point to the per-target global TCG register that
 points to the vCPU when guest code is executed (usually the "cpu_env" variable).
 
+All "vcpu" events *must* be declared in the top level "trace-events" file. It
+is not permitted to have them declared in sub-directories.
+
 The following example events:
 
     foo(uint32_t a) "a=%x"
-- 
2.9.3

  parent reply	other threads:[~2017-01-06 15:57 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-06 15:54 [Qemu-devel] [PATCH v2 00/47] Switch all subdirs over to modular trace.h file Daniel P. Berrange
2017-01-06 15:54 ` [Qemu-devel] [PATCH v2 01/47] trace: introduce some Makefile rules for module code gen Daniel P. Berrange
2017-01-06 17:20   ` Lluís Vilanova
2017-01-06 17:25     ` Daniel P. Berrange
2017-01-06 20:53       ` Lluís Vilanova
2017-01-06 15:54 ` [Qemu-devel] [PATCH v2 02/47] trace: switch io/ directory to modular trace.h file Daniel P. Berrange
2017-01-10 16:37   ` Stefan Hajnoczi
2017-01-10 16:51     ` Daniel P. Berrange
2017-01-10 17:45       ` Paolo Bonzini
2017-01-10 18:36         ` Daniel P. Berrange
2017-01-10 21:01           ` Paolo Bonzini
2017-01-11 10:28             ` Daniel P. Berrange
2017-01-11 10:34               ` Daniel P. Berrange
2017-01-11 10:50                 ` Paolo Bonzini
2017-01-10 16:51     ` Eric Blake
2017-01-10 17:47       ` Paolo Bonzini
2017-01-11 17:12       ` Stefan Hajnoczi
2017-01-11 17:16         ` Daniel P. Berrange
2017-01-11 17:34           ` Paolo Bonzini
2017-01-11 17:40             ` Daniel P. Berrange
2017-01-11 18:05               ` Paolo Bonzini
2017-01-12  1:02                 ` Lluís Vilanova
2017-01-12  8:48                   ` Paolo Bonzini
2017-01-12 14:29                     ` Lluís Vilanova
2017-01-12 14:30                     ` Daniel P. Berrange
2017-01-12  0:59               ` Lluís Vilanova
2017-01-10 16:38   ` Stefan Hajnoczi
2017-01-11 17:17     ` Daniel P. Berrange
2017-01-06 15:54 ` [Qemu-devel] [PATCH v2 03/47] trace: switch util/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 04/47] trace: switch crypto/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 05/47] trace: switch migration/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 06/47] trace: switch block/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 07/47] trace: switch hw/block/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 08/47] trace: switch hw/char/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 09/47] trace: switch hw/intc/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 10/47] trace: switch hw/net/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 11/47] trace: switch hw/virtio/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 12/47] trace: switch hw/audio/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 13/47] trace: switch hw/misc/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 14/47] trace: switch hw/usb/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 15/47] trace: switch hw/scsi/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 16/47] trace: switch hw/nvram/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 17/47] trace: switch hw/display/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 18/47] trace: switch hw/input/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 19/47] trace: switch hw/timer/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 20/47] trace: switch hw/dma/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 21/47] trace: switch hw/sparc/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 22/47] trace: switch hw/sd/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 23/47] trace: switch hw/isa/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 24/47] trace: switch hw/mem/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 25/47] trace: switch hw/i386/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 26/47] trace: switch hw/9pfs/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 27/47] trace: switch hw/ppc/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 28/47] trace: switch hw/pci/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 29/47] trace: switch hw/s390x/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 30/47] trace: switch hw/vfio/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 31/47] trace: switch hw/acpi/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 32/47] trace: switch hw/arm/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 33/47] trace: switch hw/alpha/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 34/47] trace: switch ui/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 35/47] trace: switch audio/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 36/47] trace: switch net/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 37/47] trace: switch target/arm/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 38/47] trace: switch target/i386/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 39/47] trace: switch target/sparc/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 40/47] trace: switch target/s390x/ " Daniel P. Berrange
2017-01-06 17:09   ` Lluís Vilanova
2017-01-06 17:18     ` Daniel P. Berrange
2017-01-06 20:45       ` Lluís Vilanova
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 41/47] trace: switch target/ppc/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 42/47] trace: switch qom/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 43/47] trace: switch linux-user/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 44/47] trace: switch qapi/ " Daniel P. Berrange
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 45/47] trace: remove the global include/trace.h file Daniel P. Berrange
2017-01-06 15:55 ` Daniel P. Berrange [this message]
2017-01-06 17:26   ` [Qemu-devel] [PATCH v2 46/47] trace: update docs to reflect new code generation approach Lluís Vilanova
2017-01-06 18:13   ` Eric Blake
2017-01-06 15:55 ` [Qemu-devel] [PATCH v2 47/47] trace: improve error reporting when parsing simpletrace header Daniel P. Berrange
2017-01-06 18:15   ` Eric Blake
2017-01-10 16:40   ` Stefan Hajnoczi
2017-01-06 16:05 ` [Qemu-devel] [PATCH v2 00/47] Switch all subdirs over to modular trace.h file Daniel P. Berrange
2017-01-06 17:02 ` no-reply
2017-01-06 17:23   ` Daniel P. Berrange

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=20170106155543.12827-47-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.