Patchwork trace: Support trace events with no arguments

login
register
mail settings
Submitter Stefan Hajnoczi
Date June 29, 2010, 1:08 p.m.
Message ID <1277816904-32614-1-git-send-email-stefanha@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/57267/
State New
Headers show

Comments

Stefan Hajnoczi - June 29, 2010, 1:08 p.m.
Trace events with no arguments are not parsed correctly.  For example:
foo(void) ""

This patch fixes the trace-events parsing code and simple trace backend.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
This patch applies against the tracing branch:

http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/tracing

 simpletrace.c |    4 ++++
 tracetool     |   24 +++++++++++++++++++-----
 2 files changed, 23 insertions(+), 5 deletions(-)

Patch

diff --git a/simpletrace.c b/simpletrace.c
index 2d65114..5c327af 100644
--- a/simpletrace.c
+++ b/simpletrace.c
@@ -55,6 +55,10 @@  static void trace(TraceEventID event, unsigned long x1,
     }
 }
 
+void trace0(TraceEventID event) {
+    trace(event, 0, 0, 0, 0, 0);
+}
+
 void trace1(TraceEventID event, unsigned long x1) {
     trace(event, x1, 0, 0, 0, 0);
 }
diff --git a/tracetool b/tracetool
index c77280d..9ce8e74 100755
--- a/tracetool
+++ b/tracetool
@@ -39,8 +39,11 @@  get_args()
 # Get the argument name list of a trace event
 get_argnames()
 {
-    local first field name
+    local nfields field name
+    nfields=0
     for field in $(get_args "$1"); do
+        nfields=$((nfields + 1))
+
         # Drop pointer star
         field=${field#\*}
 
@@ -50,7 +53,12 @@  get_argnames()
 
         echo -n "$name, "
     done
-    echo -n "$name"
+
+    # Last argument name
+    if [ "$nfields" -gt 1 ]
+    then
+        echo -n "$name"
+    fi
 }
 
 # Get the number of arguments to a trace event
@@ -125,6 +133,7 @@  typedef struct {
     bool state;
 } TraceEvent;
 
+void trace0(TraceEventID event);
 void trace1(TraceEventID event, unsigned long x1);
 void trace2(TraceEventID event, unsigned long x1, unsigned long x2);
 void trace3(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3);
@@ -148,15 +157,20 @@  cast_args_to_ulong()
 
 linetoh_simple()
 {
-    local name args argc ulong_args
+    local name args argc trace_args
     name=$(get_name "$1")
     args=$(get_args "$1")
     argc=$(get_argc "$1")
-    ulong_args=$(cast_args_to_ulong "$1")
+
+    trace_args="$simple_event_num"
+    if [ "$argc" -gt 0 ]
+    then
+        trace_args="$trace_args, $(cast_args_to_ulong "$1")"
+    fi
 
     cat <<EOF
 static inline void trace_$name($args) {
-    trace$argc($simple_event_num, $ulong_args);
+    trace$argc($trace_args);
 }
 EOF