From: Lluís <xscript@gmx.net>
To: qemu-devel@nongnu.org
Cc: stefanha@gmail.com, chouteau@adacore.com
Subject: [Qemu-devel] [PATCH v4 03/10] trace: generalize the "property" concept in the trace-events file
Date: Tue, 03 May 2011 22:41:03 +0200 [thread overview]
Message-ID: <20110503204103.438.6164.stgit@ginnungagap.bsc.es> (raw)
In-Reply-To: <20110503204042.438.2257.stgit@ginnungagap.bsc.es>
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()
next prev parent reply other threads:[~2011-05-03 20:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-03 20:40 [Qemu-devel] [RFC][PATCH v4 00/10] trace-state: make the behaviour of "disable" consistent across all backends Lluís
2011-05-03 20:40 ` [Qemu-devel] [PATCH v4 01/10] trace: move backend-specific code into the trace/ directory Lluís
2011-05-03 20:40 ` [Qemu-devel] [PATCH v4 02/10] trace: avoid conditional code compilation during option parsing Lluís
2011-05-03 20:41 ` Lluís [this message]
2011-05-03 20:41 ` [Qemu-devel] [PATCH v4 04/10] trace-state: separate trace event control and query routines from the simple backend Lluís
2011-05-03 20:41 ` [Qemu-devel] [PATCH v4 05/10] trace-state: always compile support for controlling and querying trace event states Lluís
2011-05-03 20:41 ` [Qemu-devel] [PATCH v4 06/10] trace-state: add "-trace events" argument to control initial state Lluís
2011-05-03 20:41 ` [Qemu-devel] [PATCH v4 07/10] trace-state: always use the "nop" backend on events with the "disable" keyword Lluís
2011-05-03 20:41 ` [Qemu-devel] [PATCH v4 08/10] trace-state: [simple] disable all trace points by default Lluís
2011-05-03 20:41 ` [Qemu-devel] [PATCH v4 09/10] trace-state: [stderr] add support for dynamically enabling/disabling events Lluís
2011-05-04 14:17 ` Lluís
2011-05-03 20:41 ` [Qemu-devel] [PATCH v4 10/10] trace: enable all events Lluís
2011-05-19 14:10 ` [Qemu-devel] [RFC][PATCH v4 00/10] trace-state: make the behaviour of "disable" consistent across all backends Lluís
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=20110503204103.438.6164.stgit@ginnungagap.bsc.es \
--to=xscript@gmx.net \
--cc=chouteau@adacore.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.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 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).