Patchwork [v3,03/24] trace: Let the user specify her own trace-events file

login
register
mail settings
Submitter Lluís Vilanova
Date April 21, 2013, 7:11 p.m.
Message ID <20130421191146.8947.68752.stgit@fimbulvetr.bsc.es>
Download mbox | patch
Permalink /patch/238239/
State New
Headers show

Comments

Lluís Vilanova - April 21, 2013, 7:11 p.m.
With this option the user can perform multiple builds of QEMU with different
tracing event properties.

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
 Makefile.target     |    2 +-
 configure           |   19 +++++++++++++++++++
 trace/Makefile.objs |   10 +++++-----
 3 files changed, 25 insertions(+), 6 deletions(-)
Paolo Bonzini - April 26, 2013, 3:21 p.m.
Il 21/04/2013 21:11, Lluís Vilanova ha scritto:
> With this option the user can perform multiple builds of QEMU with different
> tracing event properties.

I don't understand why this is useful?  If it is just to add/remove
"disable" here and there, surely the user should be using git and
different branches?

Paolo

> Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
> ---
>  Makefile.target     |    2 +-
>  configure           |   19 +++++++++++++++++++
>  trace/Makefile.objs |   10 +++++-----
>  3 files changed, 25 insertions(+), 6 deletions(-)
> 
> diff --git a/Makefile.target b/Makefile.target
> index 2bd6d14..f382559 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -47,7 +47,7 @@ else
>  TARGET_TYPE=system
>  endif
>  
> -$(QEMU_PROG).stp: $(SRC_PATH)/trace-events
> +$(QEMU_PROG).stp: $(TRACE_EVENTS)
>  	$(call quiet-command,$(TRACETOOL) \
>  		--format=stap \
>  		--backend=$(TRACE_BACKEND) \
> diff --git a/configure b/configure
> index 73df181..a3bd336 100755
> --- a/configure
> +++ b/configure
> @@ -221,6 +221,7 @@ blobs="yes"
>  pkgversion=""
>  pie=""
>  zero_malloc=""
> +trace_events=`dirname $0`/trace-events
>  trace_backend="nop"
>  trace_file="trace"
>  spice=""
> @@ -639,6 +640,8 @@ for opt do
>    ;;
>    --target-list=*) target_list="$optarg"
>    ;;
> +  --with-trace-events=*) trace_events="$optarg"
> +  ;;
>    --enable-trace-backend=*) trace_backend="$optarg"
>    ;;
>    --with-trace-file=*) trace_file="$optarg"
> @@ -1158,6 +1161,7 @@ echo "  --enable-docs            enable documentation build"
>  echo "  --disable-docs           disable documentation build"
>  echo "  --disable-vhost-net      disable vhost-net acceleration support"
>  echo "  --enable-vhost-net       enable vhost-net acceleration support"
> +echo "  --with-trace-events=PATH file with tracing events description (default: $trace_events)"
>  echo "  --enable-trace-backend=B Set trace backend"
>  echo "                           Available backends:" $($python "$source_path"/scripts/tracetool.py --list-backends)
>  echo "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
> @@ -3009,6 +3013,18 @@ if compile_prog "" "" ; then
>  fi
>  
>  ##########################################
> +# check if trace-events file exists
> +
> +if test ! -f "$trace_events"; then
> +    echo
> +    echo "Error: the given trace-events file does not exist"
> +    echo
> +    exit 1
> +else
> +    trace_events=`readlink -f "$trace_events"`
> +fi
> +
> +##########################################
>  # check if trace backend exists
>  
>  $python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend  > /dev/null 2> /dev/null
> @@ -3418,6 +3434,7 @@ echo "sigev_thread_id   $sigev_thread_id"
>  echo "uuid support      $uuid"
>  echo "libcap-ng support $cap_ng"
>  echo "vhost-net support $vhost_net"
> +echo "Trace events      $trace_events"
>  echo "Trace backend     $trace_backend"
>  echo "Trace output file $trace_file-<pid>"
>  echo "spice support     $spice ($spice_protocol_version/$spice_server_version)"
> @@ -3810,6 +3827,8 @@ bsd)
>  ;;
>  esac
>  
> +echo "TRACE_EVENTS=$trace_events" >> $config_host_mak
> +
>  # use default implementation for tracing backend-specific routines
>  trace_default=yes
>  echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak
> diff --git a/trace/Makefile.objs b/trace/Makefile.objs
> index a043072..bf0a965 100644
> --- a/trace/Makefile.objs
> +++ b/trace/Makefile.objs
> @@ -4,7 +4,7 @@
>  # Auto-generated event descriptions
>  
>  $(obj)/generated-events.h: $(obj)/generated-events.h-timestamp
> -$(obj)/generated-events.h-timestamp: $(SRC_PATH)/trace-events
> +$(obj)/generated-events.h-timestamp: $(TRACE_EVENTS)
>  	$(call quiet-command,$(TRACETOOL) \
>  		--format=events-h \
>  		--backend=events \
> @@ -12,7 +12,7 @@ $(obj)/generated-events.h-timestamp: $(SRC_PATH)/trace-events
>  	@cmp -s $@ $(patsubst %-timestamp,%,$@) || cp $@ $(patsubst %-timestamp,%,$@)
>  
>  $(obj)/generated-events.c: $(obj)/generated-events.c-timestamp $(BUILD_DIR)/config-host.mak
> -$(obj)/generated-events.c-timestamp: $(SRC_PATH)/trace-events
> +$(obj)/generated-events.c-timestamp: $(TRACE_EVENTS)
>  	$(call quiet-command,$(TRACETOOL) \
>  		--format=events-c \
>  		--backend=events \
> @@ -27,7 +27,7 @@ util-obj-y += generated-events.o
>  
>  $(obj)/generated-tracers.h: $(obj)/generated-tracers.h-timestamp
>  	@cmp -s $< $@ || cp $< $@
> -$(obj)/generated-tracers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak
> +$(obj)/generated-tracers.h-timestamp: $(TRACE_EVENTS) $(BUILD_DIR)/config-host.mak
>  	$(call quiet-command,$(TRACETOOL) \
>  		--format=h \
>  		--backend=$(TRACE_BACKEND) \
> @@ -39,7 +39,7 @@ $(obj)/generated-tracers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/conf
>  ifneq ($(TRACE_BACKEND),dtrace)
>  $(obj)/generated-tracers.c: $(obj)/generated-tracers.c-timestamp
>  	@cmp -s $< $@ || cp $< $@
> -$(obj)/generated-tracers.c-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak
> +$(obj)/generated-tracers.c-timestamp: $(TRACE_EVENTS) $(BUILD_DIR)/config-host.mak
>  	$(call quiet-command,$(TRACETOOL) \
>  		--format=c \
>  		--backend=$(TRACE_BACKEND) \
> @@ -57,7 +57,7 @@ endif
>  # rule file. So we use '.dtrace' instead
>  ifeq ($(TRACE_BACKEND),dtrace)
>  $(obj)/generated-tracers.dtrace: $(obj)/generated-tracers.dtrace-timestamp
> -$(obj)/generated-tracers.dtrace-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak
> +$(obj)/generated-tracers.dtrace-timestamp: $(TRACE_EVENTS) $(BUILD_DIR)/config-host.mak
>  	$(call quiet-command,$(TRACETOOL) \
>  		--format=d \
>  		--backend=$(TRACE_BACKEND) \
> 
> 
>
Lluís Vilanova - April 26, 2013, 6:28 p.m.
Paolo Bonzini writes:

> Il 21/04/2013 21:11, Lluís Vilanova ha scritto:
>> With this option the user can perform multiple builds of QEMU with different
>> tracing event properties.

> I don't understand why this is useful?  If it is just to add/remove
> "disable" here and there, surely the user should be using git and
> different branches?

Well, you can create multiple build directories that use a different
trace-events file. As you have to explicitly add the "instrument" keyword on
events, I found it handy to have builds with different sorts of events.


Lluis

Patch

diff --git a/Makefile.target b/Makefile.target
index 2bd6d14..f382559 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -47,7 +47,7 @@  else
 TARGET_TYPE=system
 endif
 
-$(QEMU_PROG).stp: $(SRC_PATH)/trace-events
+$(QEMU_PROG).stp: $(TRACE_EVENTS)
 	$(call quiet-command,$(TRACETOOL) \
 		--format=stap \
 		--backend=$(TRACE_BACKEND) \
diff --git a/configure b/configure
index 73df181..a3bd336 100755
--- a/configure
+++ b/configure
@@ -221,6 +221,7 @@  blobs="yes"
 pkgversion=""
 pie=""
 zero_malloc=""
+trace_events=`dirname $0`/trace-events
 trace_backend="nop"
 trace_file="trace"
 spice=""
@@ -639,6 +640,8 @@  for opt do
   ;;
   --target-list=*) target_list="$optarg"
   ;;
+  --with-trace-events=*) trace_events="$optarg"
+  ;;
   --enable-trace-backend=*) trace_backend="$optarg"
   ;;
   --with-trace-file=*) trace_file="$optarg"
@@ -1158,6 +1161,7 @@  echo "  --enable-docs            enable documentation build"
 echo "  --disable-docs           disable documentation build"
 echo "  --disable-vhost-net      disable vhost-net acceleration support"
 echo "  --enable-vhost-net       enable vhost-net acceleration support"
+echo "  --with-trace-events=PATH file with tracing events description (default: $trace_events)"
 echo "  --enable-trace-backend=B Set trace backend"
 echo "                           Available backends:" $($python "$source_path"/scripts/tracetool.py --list-backends)
 echo "  --with-trace-file=NAME   Full PATH,NAME of file to store traces"
@@ -3009,6 +3013,18 @@  if compile_prog "" "" ; then
 fi
 
 ##########################################
+# check if trace-events file exists
+
+if test ! -f "$trace_events"; then
+    echo
+    echo "Error: the given trace-events file does not exist"
+    echo
+    exit 1
+else
+    trace_events=`readlink -f "$trace_events"`
+fi
+
+##########################################
 # check if trace backend exists
 
 $python "$source_path/scripts/tracetool.py" "--backend=$trace_backend" --check-backend  > /dev/null 2> /dev/null
@@ -3418,6 +3434,7 @@  echo "sigev_thread_id   $sigev_thread_id"
 echo "uuid support      $uuid"
 echo "libcap-ng support $cap_ng"
 echo "vhost-net support $vhost_net"
+echo "Trace events      $trace_events"
 echo "Trace backend     $trace_backend"
 echo "Trace output file $trace_file-<pid>"
 echo "spice support     $spice ($spice_protocol_version/$spice_server_version)"
@@ -3810,6 +3827,8 @@  bsd)
 ;;
 esac
 
+echo "TRACE_EVENTS=$trace_events" >> $config_host_mak
+
 # use default implementation for tracing backend-specific routines
 trace_default=yes
 echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak
diff --git a/trace/Makefile.objs b/trace/Makefile.objs
index a043072..bf0a965 100644
--- a/trace/Makefile.objs
+++ b/trace/Makefile.objs
@@ -4,7 +4,7 @@ 
 # Auto-generated event descriptions
 
 $(obj)/generated-events.h: $(obj)/generated-events.h-timestamp
-$(obj)/generated-events.h-timestamp: $(SRC_PATH)/trace-events
+$(obj)/generated-events.h-timestamp: $(TRACE_EVENTS)
 	$(call quiet-command,$(TRACETOOL) \
 		--format=events-h \
 		--backend=events \
@@ -12,7 +12,7 @@  $(obj)/generated-events.h-timestamp: $(SRC_PATH)/trace-events
 	@cmp -s $@ $(patsubst %-timestamp,%,$@) || cp $@ $(patsubst %-timestamp,%,$@)
 
 $(obj)/generated-events.c: $(obj)/generated-events.c-timestamp $(BUILD_DIR)/config-host.mak
-$(obj)/generated-events.c-timestamp: $(SRC_PATH)/trace-events
+$(obj)/generated-events.c-timestamp: $(TRACE_EVENTS)
 	$(call quiet-command,$(TRACETOOL) \
 		--format=events-c \
 		--backend=events \
@@ -27,7 +27,7 @@  util-obj-y += generated-events.o
 
 $(obj)/generated-tracers.h: $(obj)/generated-tracers.h-timestamp
 	@cmp -s $< $@ || cp $< $@
-$(obj)/generated-tracers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak
+$(obj)/generated-tracers.h-timestamp: $(TRACE_EVENTS) $(BUILD_DIR)/config-host.mak
 	$(call quiet-command,$(TRACETOOL) \
 		--format=h \
 		--backend=$(TRACE_BACKEND) \
@@ -39,7 +39,7 @@  $(obj)/generated-tracers.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/conf
 ifneq ($(TRACE_BACKEND),dtrace)
 $(obj)/generated-tracers.c: $(obj)/generated-tracers.c-timestamp
 	@cmp -s $< $@ || cp $< $@
-$(obj)/generated-tracers.c-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak
+$(obj)/generated-tracers.c-timestamp: $(TRACE_EVENTS) $(BUILD_DIR)/config-host.mak
 	$(call quiet-command,$(TRACETOOL) \
 		--format=c \
 		--backend=$(TRACE_BACKEND) \
@@ -57,7 +57,7 @@  endif
 # rule file. So we use '.dtrace' instead
 ifeq ($(TRACE_BACKEND),dtrace)
 $(obj)/generated-tracers.dtrace: $(obj)/generated-tracers.dtrace-timestamp
-$(obj)/generated-tracers.dtrace-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak
+$(obj)/generated-tracers.dtrace-timestamp: $(TRACE_EVENTS) $(BUILD_DIR)/config-host.mak
 	$(call quiet-command,$(TRACETOOL) \
 		--format=d \
 		--backend=$(TRACE_BACKEND) \