qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 06/10] trace: [tracetool] Add 'get_api_name' to cons


From: Lluís Vilanova
Subject: [Qemu-devel] [PATCH 06/10] trace: [tracetool] Add 'get_api_name' to construct the name of tracing routines
Date: Thu, 08 Dec 2011 23:49:23 +0100
User-agent: StGit/0.15

All backends now use 'get_api_name' to build the name of the routines that are
used by QEMU code when invoking trace points. This is built based on the value
of 'get_api_name_fmt_default'.

The old 'get_name' is still available to refer to the name of an event.

This ensures proper naming across tracing backends.

Signed-off-by: Lluís Vilanova <address@hidden>
---
 scripts/tracetool |   40 ++++++++++++++++++++++++++++------------
 1 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/scripts/tracetool b/scripts/tracetool
index f2b6680..853f1bd 100755
--- a/scripts/tracetool
+++ b/scripts/tracetool
@@ -57,6 +57,19 @@ get_name()
     echo "${name##* }"
 }
 
+get_api_name_fmt_default="trace_%s"
+
+# Get the tracepoint name of a trace event (the name of the function QEMU uses)
+# The result is 'printf "$fmt" $name', where 'fmt' is
+# 'get_api_name_fmt_default'.
+get_api_name()
+{
+    local name fmt
+    name=$(get_name "$1")
+    fmt="$get_api_name_fmt_default"
+    printf "$fmt" "$name"
+}
+
 # Get the given property of a trace event
 # 1: trace-events line
 # 2: property name
@@ -248,13 +261,13 @@ linetoh_begin_nop()
 
 linetoh_nop()
 {
-    local name args
-    name=$(get_name "$1")
+    local api args
+    api=$(get_api_name "$1")
     args=$(get_args "$1")
 
     # Define an empty function for the trace event
     cat <<EOF
-static inline void trace_$name($args)
+static inline void ${api}($args)
 {
 }
 EOF
@@ -300,8 +313,8 @@ cast_args_to_uint64_t()
 
 linetoh_simple()
 {
-    local name args argc trace_args
-    name=$(get_name "$1")
+    local api args argc trace_args
+    api=$(get_api_name "$1")
     args=$(get_args "$1")
     argc=$(get_argc "$1")
 
@@ -312,7 +325,7 @@ linetoh_simple()
     fi
 
     cat <<EOF
-static inline void trace_$name($args)
+static inline void ${api}($args)
 {
     trace$argc($trace_args);
 }
@@ -372,8 +385,9 @@ EOF
 
 linetoh_stderr()
 {
-    local name args argnames argc fmt
+    local name api args argnames argc fmt
     name=$(get_name "$1")
+    api=$(get_api_name "$1")
     args=$(get_args "$1")
     argnames=$(get_argnames "$1" ",")
     argc=$(get_argc "$1")
@@ -384,7 +398,7 @@ linetoh_stderr()
     fi
 
     cat <<EOF
-static inline void trace_$name($args)
+static inline void ${api}($args)
 {
     if (trace_list[$stderr_event_num].state != 0) {
         fprintf(stderr, "$name " $fmt "\n" $argnames);
@@ -448,14 +462,15 @@ linetoh_begin_ust()
 
 linetoh_ust()
 {
-    local name args argnames
+    local name api args argnames
     name=$(get_name "$1")
+    api=$(get_api_name "$1")
     args=$(get_args "$1")
     argnames=$(get_argnames "$1", ",")
 
     cat <<EOF
 DECLARE_TRACE(ust_$name, TP_PROTO($args), TP_ARGS($argnames));
-#define trace_$name trace_ust_$name
+#define ${api} trace_ust_$name
 EOF
 }
 
@@ -520,8 +535,9 @@ EOF
 
 linetoh_dtrace()
 {
-    local name args argnames nameupper
+    local name api args argnames nameupper
     name=$(get_name "$1")
+    api=$(get_api_name "$1")
     args=$(get_args "$1")
     argnames=$(get_argnames "$1", ",")
 
@@ -529,7 +545,7 @@ linetoh_dtrace()
 
     # Define an empty function for the trace event
     cat <<EOF
-static inline void trace_$name($args) {
+static inline void ${api}($args) {
     if (QEMU_${nameupper}_ENABLED()) {
         QEMU_${nameupper}($argnames);
     }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]