trace: Support trace events with no arguments
PATCH 1/1 trace: Support trace events with no arguments
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 <[email protected]>
---
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(-)
simpletrace.c +4 -0
@@ -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 ); }
tracetool +19 -5
@@ -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
Signature · 1 line
1.7.1