qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Julien Desfossez <ju@klipix.org>,
	Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
	Prerna Saxena <prerna@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH 09/14] trace: Support disabled events in trace-events
Date: Thu, 12 Aug 2010 11:36:30 +0100	[thread overview]
Message-ID: <1281609395-17621-10-git-send-email-stefanha@linux.vnet.ibm.com> (raw)
In-Reply-To: <1281609395-17621-1-git-send-email-stefanha@linux.vnet.ibm.com>

Sometimes it is useful to disable a trace event.  Removing the event
from trace-events is not enough since source code will call the
trace_*() function for the event.

This patch makes it easy to build without specific trace events by
marking them disabled in trace-events:

disable multiwrite_cb(void *mcb, int ret) "mcb %p ret %d"

This builds without the multiwrite_cb trace event.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

trace: Allow bulk enabling/disabling of trace events at compile time

For 'simple' trace backend, allow bulk enabling/disabling of trace
events at compile time.  Trace events that are preceded by 'disable'
keyword are compiled in, but turned off by default. These can
individually be turned on using the monitor.  All other trace events are
enabled by default.

TODO :
This could be enhanced when the trace-event namespace is partitioned into a
group and an ID within that group. In such a case, marking a group as enabled
would automatically enable all trace-events listed under it.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 trace-events |    7 ++++++-
 tracetool    |   44 +++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/trace-events b/trace-events
index eae62da..e96d1f3 100644
--- a/trace-events
+++ b/trace-events
@@ -12,10 +12,15 @@
 #
 # Format of a trace event:
 #
-# <name>(<type1> <arg1>[, <type2> <arg2>] ...) "<format-string>"
+# [disable] <name>(<type1> <arg1>[, <type2> <arg2>] ...) "<format-string>"
 #
 # Example: qemu_malloc(size_t size) "size %zu"
 #
+# The "disable" keyword will build without the trace event.
+# In case of 'simple' trace backend, it will allow the trace event to be
+# compiled, but this would be turned off by default. It can be toggled on via
+# the monitor.
+#
 # The <name> must be a valid as a C function name.
 #
 # Types should be standard C types.  Use void * for pointers because the trace
diff --git a/tracetool b/tracetool
index 30dc812..d840e6f 100755
--- a/tracetool
+++ b/tracetool
@@ -87,6 +87,20 @@ get_fmt()
     echo "$fmt"
 }
 
+# Get the state of a trace event
+get_state()
+{
+    local str disable state
+    str=$(get_name "$1")
+    disable=${str##disable }
+    if [ "$disable" = "$str" ] ; then
+        state=1
+    else
+        state=0
+    fi
+    echo "$state"
+}
+
 linetoh_begin_nop()
 {
     return
@@ -146,10 +160,14 @@ cast_args_to_uint64_t()
 
 linetoh_simple()
 {
-    local name args argc trace_args
+    local name args argc trace_args state
     name=$(get_name "$1")
     args=$(get_args "$1")
     argc=$(get_argc "$1")
+    state=$(get_state "$1")
+    if [ "$state" = "0" ]; then
+        name=${name##disable }
+    fi
 
     trace_args="$simple_event_num"
     if [ "$argc" -gt 0 ]
@@ -188,10 +206,14 @@ EOF
 
 linetoc_simple()
 {
-    local name
+    local name state
     name=$(get_name "$1")
+    state=$(get_state "$1")
+    if [ "$state" = "0" ] ; then
+        name=${name##disable }
+    fi
     cat <<EOF
-{.tp_name = "$name", .state=0},
+{.tp_name = "$name", .state=$state},
 EOF
     simple_event_num=$((simple_event_num + 1))
 }
@@ -206,7 +228,7 @@ EOF
 # Process stdin by calling begin, line, and end functions for the backend
 convert()
 {
-    local begin process_line end
+    local begin process_line end str disable
     begin="lineto$1_begin_$backend"
     process_line="lineto$1_$backend"
     end="lineto$1_end_$backend"
@@ -218,8 +240,20 @@ convert()
         str=${str%%#*}
         test -z "$str" && continue
 
+        # Process the line.  The nop backend handles disabled lines.
+        disable=${str%%disable *}
         echo
-        "$process_line" "$str"
+        if test -z "$disable"; then
+            # Pass the disabled state as an arg to lineto$1_simple().
+            # For all other cases, call lineto$1_nop()
+            if [ $backend = "simple" ]; then
+                "$process_line" "$str"
+            else
+                "lineto$1_nop" "${str##disable }"
+            fi
+        else
+            "$process_line" "$str"
+        fi
     done
 
     echo
-- 
1.7.1

  parent reply	other threads:[~2010-08-12 13:51 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-12 10:36 [Qemu-devel] [PATCH 00/14] trace: Add static tracing to QEMU Stefan Hajnoczi
2010-08-12 10:36 ` [Qemu-devel] [PATCH 01/14] trace: Add trace-events file for declaring trace events Stefan Hajnoczi
2010-08-12 16:07   ` malc
2010-08-12 19:15     ` Stefan Hajnoczi
2010-08-22 21:38   ` Anthony Liguori
2010-08-23 10:00     ` Stefan Hajnoczi
2010-08-12 10:36 ` [Qemu-devel] [PATCH 02/14] trace: Trace qemu_malloc() and qemu_vmalloc() Stefan Hajnoczi
2010-08-12 10:36 ` [Qemu-devel] [PATCH 03/14] trace: Trace virtio-blk, multiwrite, and paio_submit Stefan Hajnoczi
2010-08-12 10:36 ` [Qemu-devel] [PATCH 04/14] trace: Trace virtqueue operations Stefan Hajnoczi
2010-08-12 10:36 ` [Qemu-devel] [PATCH 05/14] trace: Trace port IO Stefan Hajnoczi
2010-08-12 10:36 ` [Qemu-devel] [PATCH 06/14] trace: Trace entry point of balloon request handler Stefan Hajnoczi
2010-08-22 21:41   ` Anthony Liguori
2010-08-23 10:10     ` Stefan Hajnoczi
2010-08-23 13:15       ` Anthony Liguori
2010-08-12 10:36 ` [Qemu-devel] [PATCH 07/14] trace: Add simple built-in tracing backend Stefan Hajnoczi
2010-08-12 17:56   ` Blue Swirl
2010-08-12 19:31     ` Stefan Hajnoczi
2010-08-12 10:36 ` [Qemu-devel] [PATCH 08/14] trace: Support for dynamically enabling/disabling trace events Stefan Hajnoczi
2010-08-12 18:02   ` Blue Swirl
2010-08-13 13:34     ` Stefan Hajnoczi
2010-08-12 10:36 ` Stefan Hajnoczi [this message]
2010-08-12 10:36 ` [Qemu-devel] [PATCH 10/14] trace: Specify trace file name Stefan Hajnoczi
2010-08-12 10:36 ` [Qemu-devel] [PATCH 11/14] trace: Add trace-file command to open/close/flush trace file Stefan Hajnoczi
2010-08-12 10:36 ` [Qemu-devel] [PATCH 12/14] trace: Add trace file name command-line option Stefan Hajnoczi
2010-08-22 21:45   ` Anthony Liguori
2010-08-12 10:36 ` [Qemu-devel] [PATCH 13/14] trace: Add LTTng Userspace Tracer backend Stefan Hajnoczi
2010-08-12 10:36 ` [Qemu-devel] [PATCH 14/14] trace: Add user documentation Stefan Hajnoczi
2010-08-22 21:47   ` Anthony Liguori
2010-08-23 10:11     ` Stefan Hajnoczi
2010-08-12 18:10 ` [Qemu-devel] [PATCH 00/14] trace: Add static tracing to QEMU Blue Swirl
2010-08-13 13:45   ` Stefan Hajnoczi
2010-08-13 19:07     ` Lluís
2010-08-22 21:47 ` Anthony Liguori
2010-09-05  7:30 ` [Qemu-devel] " Michael S. Tsirkin
2010-09-06 13:32   ` 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=1281609395-17621-10-git-send-email-stefanha@linux.vnet.ibm.com \
    --to=stefanha@linux.vnet.ibm.com \
    --cc=ju@klipix.org \
    --cc=prerna@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /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).