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 values of 'get_api_name_fmt' and 'get_api_name_fmt_default'.
The old 'get_name' is still available to refer to the name of an event. This allows future tracetool options to change the naming of the tracing API on a per-event basis without having to modify backend-specific code. Signed-off-by: Lluís Vilanova <vilan...@ac.upc.edu> --- scripts/tracetool | 41 +++++++++++++++++++++++++++++------------ 1 files changed, 29 insertions(+), 12 deletions(-) diff --git a/scripts/tracetool b/scripts/tracetool index 701b517..c699801 100755 --- a/scripts/tracetool +++ b/scripts/tracetool @@ -57,6 +57,20 @@ 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' if set +# or 'get_api_name_fmt_default' otherwise +get_api_name() +{ + local name fmt + name=$(get_name "$1") + fmt="$get_api_name_fmt" + [ -n "$fmt" ] || fmt=$get_api_name_fmt_default + printf "$fmt" "$name" +} + # Get the given property of a trace event # 1: trace-events line # 2: property name @@ -133,13 +147,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 @@ -185,8 +199,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") @@ -197,7 +211,7 @@ linetoh_simple() fi cat <<EOF -static inline void trace_$name($args) +static inline void $api($args) { trace$argc($trace_args); } @@ -257,8 +271,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") @@ -269,7 +284,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); @@ -333,14 +348,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 } @@ -405,8 +421,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", ",") @@ -414,7 +431,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); }