qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Stefan Hajnoczi" <stefanha@redhat.com>,
	"Lluís Vilanova" <vilanova@ac.upc.edu>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>
Subject: [Qemu-devel] [PATCH v3 7/8] trace: update docs to reflect new code generation approach
Date: Tue, 24 Jan 2017 11:01:50 +0000	[thread overview]
Message-ID: <20170124110151.937-8-berrange@redhat.com> (raw)
In-Reply-To: <20170124110151.937-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 | 55 ++++++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 44 insertions(+), 11 deletions(-)

diff --git a/docs/tracing.txt b/docs/tracing.txt
index f351998a..e14bb6d 100644
--- a/docs/tracing.txt
+++ b/docs/tracing.txt
@@ -27,18 +27,44 @@ for debugging, profiling, and observing execution.
 
 == Trace events ==
 
-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:
+=== Sub-directory setup ===
 
-    qemu_vmalloc(size_t size, void *ptr) "size %zu ptr %p"
-    qemu_vfree(void *ptr) "ptr %p"
-
-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".
+Each directory in the source tree can declare a set of static trace events
+in a local "trace-events" file. All directories which contain "trace-events"
+files 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 into a "trace-events-all" file,
+which is also installed into "/usr/share/qemu" with the name "trace-events".
+This merged file is to be used by the "simpletrace.py" script to later analyse
+traces in the simpletrace data format.
+
+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 event probe specification
+ - 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 #include the local 'trace.h' file,
+without any sub-directory path prefix. eg io/channel-buffer.c would do
+
+  #include "trace.h"
+
+To access the 'io/trace.h' file. While it is possible 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. The only exception is where there are some
+shared trace events defined in the top level directory trace-events file.
+The top level directory generates trace files with a filename prefix of
+"trace-root" instead of just "trace". This is to avoid ambiguity between
+a trace.h in the current directory, vs the top level directory.
+
+=== Using trace events ===
 
 Trace events are invoked directly from source code like this:
 
@@ -83,6 +109,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
-- 
2.9.3

  parent reply	other threads:[~2017-01-24 11:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-24 11:01 [Qemu-devel] [PATCH v3 0/8] Switch all subdirs over to modular trace.h file Daniel P. Berrange
2017-01-24 11:01 ` [Qemu-devel] [PATCH v3 1/8] make: move top level dir to end of include search path Daniel P. Berrange
2017-01-24 20:11   ` Eric Blake
2017-01-25 10:56     ` Daniel P. Berrange
2017-01-24 11:01 ` [Qemu-devel] [PATCH v3 2/8] trace: move hw/block/dataplane events to correct subdir Daniel P. Berrange
2017-01-25 13:43   ` Stefan Hajnoczi
2017-01-24 11:01 ` [Qemu-devel] [PATCH v3 3/8] trace: move hw/xen " Daniel P. Berrange
2017-01-25 13:43   ` Stefan Hajnoczi
2017-01-24 11:01 ` [Qemu-devel] [PATCH v3 4/8] trace: move hw/i386/xen " Daniel P. Berrange
2017-01-25 13:43   ` Stefan Hajnoczi
2017-01-24 11:01 ` [Qemu-devel] [PATCH v3 5/8] trace: move setting of group name into Makefiles Daniel P. Berrange
2017-01-25 14:03   ` Stefan Hajnoczi
2017-01-24 11:01 ` [Qemu-devel] [PATCH v3 6/8] trace: switch to modular code generation for sub-directories Daniel P. Berrange
2017-01-24 18:53   ` Lluís Vilanova
2017-01-25 16:08     ` Daniel P. Berrange
2017-01-25 14:38   ` Stefan Hajnoczi
2017-01-24 11:01 ` Daniel P. Berrange [this message]
2017-01-25 14:41   ` [Qemu-devel] [PATCH v3 7/8] trace: update docs to reflect new code generation approach Stefan Hajnoczi
2017-01-24 11:01 ` [Qemu-devel] [PATCH v3 8/8] trace: improve error reporting when parsing simpletrace header Daniel P. Berrange
2017-01-25 14:41   ` Stefan Hajnoczi
2017-01-25 14:42 ` [Qemu-devel] [PATCH v3 0/8] Switch all subdirs over to modular trace.h file Stefan Hajnoczi

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=20170124110151.937-8-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=vilanova@ac.upc.edu \
    /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).