From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: "Anthony Liguori" <aliguori@us.ibm.com>, Lluís <xscript@gmx.net>,
"Lluís Vilanova" <vilanova@ac.upc.edu>
Subject: [Qemu-devel] [PATCH 07/15] trace: generalize the "property" concept in the trace-events file
Date: Thu, 1 Sep 2011 09:06:18 +0100 [thread overview]
Message-ID: <1314864386-14202-8-git-send-email-stefanha@linux.vnet.ibm.com> (raw)
In-Reply-To: <1314864386-14202-1-git-send-email-stefanha@linux.vnet.ibm.com>
From: Lluís <xscript@gmx.net>
This adds/modifies the following functions:
* get_name: Get _only_ the event name
* has_property: Return whether an event has a property (keyword before the event
name)
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
docs/tracing.txt | 4 +-
scripts/tracetool | 73 ++++++++++++++++++++++++-----------------------------
2 files changed, 35 insertions(+), 42 deletions(-)
diff --git a/docs/tracing.txt b/docs/tracing.txt
index c99a0f2..1ad106a 100644
--- a/docs/tracing.txt
+++ b/docs/tracing.txt
@@ -38,7 +38,7 @@ generate code for the trace events. Trace events are invoked directly from
source code like this:
#include "trace.h" /* needed for trace event prototype */
-
+
void *qemu_malloc(size_t size)
{
void *ptr;
@@ -103,7 +103,7 @@ portability macros, ensure they are preceded and followed by double quotes:
4. Name trace events after their function. If there are multiple trace events
in one function, append a unique distinguisher at the end of the name.
-5. Declare trace events with the "disable" keyword. Some trace events can
+5. Declare trace events with the "disable" property. Some trace events can
produce a lot of output and users are typically only interested in a subset
of trace events. Marking trace events disabled by default saves the user
from having to manually disable noisy trace events.
diff --git a/scripts/tracetool b/scripts/tracetool
index 9ed4fae..e649a5b 100755
--- a/scripts/tracetool
+++ b/scripts/tracetool
@@ -43,7 +43,26 @@ EOF
# Get the name of a trace event
get_name()
{
- echo ${1%%\(*}
+ local name
+ name=${1%%\(*}
+ echo "${name##* }"
+}
+
+# Get the given property of a trace event
+# 1: trace-events line
+# 2: property name
+# -> return 0 if property is present, or 1 otherwise
+has_property()
+{
+ local props prop
+ props=${1%%\(*}
+ props=${props% *}
+ for prop in $props; do
+ if [ "$prop" = "$2" ]; then
+ return 0
+ fi
+ done
+ return 1
}
# Get the argument list of a trace event, including types and names
@@ -101,20 +120,6 @@ 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
@@ -174,14 +179,10 @@ cast_args_to_uint64_t()
linetoh_simple()
{
- local name args argc trace_args state
+ local name args argc trace_args
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 ]
@@ -222,9 +223,10 @@ linetoc_simple()
{
local name state
name=$(get_name "$1")
- state=$(get_state "$1")
- if [ "$state" = "0" ] ; then
- name=${name##disable }
+ if has_property "$1" "disable"; then
+ state="0"
+ else
+ state="1"
fi
cat <<EOF
{.tp_name = "$name", .state=$state},
@@ -379,14 +381,10 @@ EOF
linetoh_dtrace()
{
- local name args argnames state nameupper
+ local name args argnames nameupper
name=$(get_name "$1")
args=$(get_args "$1")
argnames=$(get_argnames "$1", ",")
- state=$(get_state "$1")
- if [ "$state" = "0" ] ; then
- name=${name##disable }
- fi
nameupper=`echo $name | tr '[:lower:]' '[:upper:]'`
@@ -430,13 +428,9 @@ EOF
linetod_dtrace()
{
- local name args state
+ local name args
name=$(get_name "$1")
args=$(get_args "$1")
- state=$(get_state "$1")
- if [ "$state" = "0" ] ; then
- name=${name##disable }
- fi
# DTrace provider syntax expects foo() for empty
# params, not foo(void)
@@ -464,14 +458,10 @@ linetostap_begin_dtrace()
linetostap_dtrace()
{
- local i arg name args arglist state
+ local i arg name args arglist
name=$(get_name "$1")
args=$(get_args "$1")
arglist=$(get_argnames "$1", "")
- state=$(get_state "$1")
- if [ "$state" = "0" ] ; then
- name=${name##disable }
- fi
# Define prototype for probe arguments
cat <<EOF
@@ -517,9 +507,12 @@ convert()
test -z "${str%%#*}" && continue
# Process the line. The nop backend handles disabled lines.
- disable=${str%%disable *}
+ disable="0"
+ if has_property "$str" "disable"; then
+ disable="1"
+ fi
echo
- if test -z "$disable"; then
+ if [ "$disable" = "1" ]; then
# Pass the disabled state as an arg for the simple
# or DTrace backends which handle it dynamically.
# For all other backends, call lineto$1_nop()
--
1.7.5.4
next prev parent reply other threads:[~2011-09-01 8:07 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-01 8:06 [Qemu-devel] [PULL 00/15] Tracing patches Stefan Hajnoczi
2011-09-01 8:06 ` [Qemu-devel] [PATCH 01/15] build: Fix linkage of QEMU_PROG Stefan Hajnoczi
2011-09-01 8:06 ` [Qemu-devel] [PATCH 02/15] build: [simple] Include qemu-timer-common.o in trace-obj-y Stefan Hajnoczi
2011-09-01 8:06 ` [Qemu-devel] [PATCH 03/15] trace: [configure] rename CONFIG_*_TRACE into CONFIG_TRACE_* Stefan Hajnoczi
2011-09-01 8:06 ` [Qemu-devel] [PATCH 04/15] trace: [make] replace 'ifeq' with values in CONFIG_TRACE_* Stefan Hajnoczi
2011-09-01 8:06 ` [Qemu-devel] [PATCH 05/15] trace: move backend-specific code into the trace/ directory Stefan Hajnoczi
2011-09-01 8:06 ` [Qemu-devel] [PATCH 06/15] trace: avoid conditional code compilation during option parsing Stefan Hajnoczi
2011-09-01 8:06 ` Stefan Hajnoczi [this message]
2011-09-01 8:06 ` [Qemu-devel] [PATCH 08/15] trace: separate trace event control and query routines from the simple backend Stefan Hajnoczi
2011-09-01 8:06 ` [Qemu-devel] [PATCH 09/15] trace: always compile support for controlling and querying trace event states Stefan Hajnoczi
2011-09-01 8:06 ` [Qemu-devel] [PATCH 10/15] trace: add "-trace events" argument to control initial state Stefan Hajnoczi
2011-09-01 8:06 ` [Qemu-devel] [PATCH 11/15] trace: always use the "nop" backend on events with the "disable" keyword Stefan Hajnoczi
2011-09-01 8:06 ` [Qemu-devel] [PATCH 12/15] trace: [simple] disable all trace points by default Stefan Hajnoczi
2011-09-01 8:06 ` [Qemu-devel] [PATCH 13/15] trace: [stderr] add support for dynamically enabling/disabling events Stefan Hajnoczi
2011-09-01 8:06 ` [Qemu-devel] [PATCH 14/15] trace: enable all events Stefan Hajnoczi
2011-09-01 8:06 ` [Qemu-devel] [PATCH 15/15] simpletrace: fix process() argument count Stefan Hajnoczi
2011-09-01 19:08 ` [Qemu-devel] [PULL 00/15] Tracing patches Anthony Liguori
2011-09-02 9:39 ` Stefan Hajnoczi
2011-09-02 14:54 ` Anthony Liguori
2011-09-02 15:00 ` Anthony Liguori
2011-09-02 15:30 ` Lluís Vilanova
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=1314864386-14202-8-git-send-email-stefanha@linux.vnet.ibm.com \
--to=stefanha@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=vilanova@ac.upc.edu \
--cc=xscript@gmx.net \
/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).