Re: [Qemu-devel] [PATCH 1/6] trace: Make tracetool generate a group list

2011-10-13 Thread Sheldon

git apply fails. details as follow:
error: patch failed: trace-events:51
error: trace-events: patch does not apply

Tested-by ShaoHe Feng shao...@linux.vnet.ibm.com

On 10/13/2011 01:14 AM, Mark Wu wrote:

Each trace events group starts with a line containing group_start:
GroupName and end with a line containing group_end. The range of
a trace events group is determined by the tracetool script when it
processes the trace-events file.

Signed-off-by: Mark Wuwu...@linux.vnet.ibm.com
---
  scripts/tracetool |   94 +++-
  trace-events  |   88 +
  2 files changed, 180 insertions(+), 2 deletions(-)

diff --git a/scripts/tracetool b/scripts/tracetool
index 4c9951d..3b4ca41 100755
--- a/scripts/tracetool
+++ b/scripts/tracetool
@@ -166,6 +166,82 @@ linetoc_end_nop()
  return
  }

+linetoh_begin_group()
+{
+group_num=0
+}
+
+linetoh_end_group()
+{
+catEOF
+#define NR_TRACE_EVENT_GROUPS $group_num
+extern TraceEventGroup trace_group_list[NR_TRACE_EVENT_GROUPS];
+EOF
+}
+
+linetoc_begin_group()
+{
+catEOFtrace-groups
+
+TraceEventGroup trace_group_list[] = {
+
+EOF
+group_num=0
+}
+
+linetoc_end_group()
+{
+catEOFtrace-groups
+};
+EOF
+cat  trace-groups
+rm -f trace-groups
+}
+
+linetoc_group()
+{
+if echo $str|grep -q group_start; then
+gp_name=${1##*group_start:}
+   if ! test -z $gp_name; then
+start=$((${backend}_event_num))
+   fi
+elif echo $str|grep -q group_end; then
+   stop=$((${backend}_event_num - 1))
+   catEOFtrace-groups
+{.gp_name = $gp_name, .state = 0, .start = $start, .end = $stop},
+
+EOF
+   group_num=$((group_num + 1))
+fi
+}
+
+linetoc_group_simple()
+{
+linetoc_group $1
+}
+
+linetoc_group_stderr()
+{
+linetoc_group $1
+}
+
+linetoh_group()
+{
+if echo $str|grep -q group_end; then
+group_num=$((group_num + 1))
+fi
+}
+
+linetoh_group_simple()
+{
+linetoh_group
+}
+
+linetoh_group_stderr()
+{
+linetoh_group
+}
+
  linetoh_begin_simple()
  {
  catEOF
@@ -173,8 +249,10 @@ linetoh_begin_simple()
  EOF

  simple_event_num=0
+linetoh_begin_group
  }

+
  cast_args_to_uint64_t()
  {
  local arg
@@ -206,12 +284,14 @@ EOF
  simple_event_num=$((simple_event_num + 1))
  }

+
  linetoh_end_simple()
  {
  catEOF
  #define NR_TRACE_EVENTS $simple_event_num
  extern TraceEvent trace_list[NR_TRACE_EVENTS];
  EOF
+linetoh_end_group
  }

  linetoc_begin_simple()
@@ -222,7 +302,7 @@ linetoc_begin_simple()
  TraceEvent trace_list[] = {
  EOF
  simple_event_num=0
-
+linetoc_begin_group
  }

  linetoc_simple()
@@ -240,6 +320,7 @@ linetoc_end_simple()
  catEOF
  };
  EOF
+linetoc_end_group
  }

  #STDERR
@@ -285,6 +366,7 @@ linetoh_end_stderr()
  catEOF
  #define NR_TRACE_EVENTS $stderr_event_num
  EOF
+linetoh_end_group
  }

  linetoc_begin_stderr()
@@ -295,6 +377,7 @@ linetoc_begin_stderr()
  TraceEvent trace_list[] = {
  EOF
  stderr_event_num=0
+linetoc_begin_group
  }

  linetoc_stderr()
@@ -312,6 +395,7 @@ linetoc_end_stderr()
  catEOF
  };
  EOF
+linetoc_end_group
  }
  #END OF STDERR

@@ -523,12 +607,18 @@ convert()
  begin=lineto$1_begin_$backend
  process_line=lineto$1_$backend
  end=lineto$1_end_$backend
+group=lineto$1_group_$backend

  $begin

  while read -r str; do
  # Skip comments and empty lines
-test -z ${str%%#*}  continue
+if test -z ${str%%#*}; then
+   if [ $backend == simple -o $backend == stderr ]  [ ! `echo 
$str|grep -q ^# group_` ]; then
+   $group $str
+   fi
+   continue
+   fi

  echo
  # Process the line.  The nop backend handles disabled lines.
diff --git a/trace-events b/trace-events
index a31d9aa..cbd4b58 100644
--- a/trace-events
+++ b/trace-events
@@ -26,6 +26,7 @@
  # Theformat-string  should be a sprintf()-compatible format string.

  # qemu-malloc.c
+# group_start:qemu-memory
  g_malloc(size_t size, void *ptr) size %zu ptr %p
  g_realloc(void *ptr, size_t size, void *newptr) ptr %p size %zu newptr %p
  g_free(void *ptr) ptr %p
@@ -34,8 +35,10 @@ g_free(void *ptr) ptr %p
  qemu_memalign(size_t alignment, size_t size, void *ptr) alignment %zu size %zu 
ptr %p
  qemu_vmalloc(size_t size, void *ptr) size %zu ptr %p
  qemu_vfree(void *ptr) ptr %p
+# group_end

  # hw/virtio.c
+# group_start:virtio
  virtqueue_fill(void *vq, const void *elem, unsigned int len, unsigned int idx) vq 
%p elem %p len %u idx %u
  virtqueue_flush(void *vq, unsigned int count) vq %p count %u
  virtqueue_pop(void *vq, void *elem, unsigned int in_num, unsigned int out_num) vq 
%p elem %p in_num %u out_num %u
@@ -43,6 +46,7 @@ virtio_queue_notify(void *vdev, int n, void *vq) vdev %p n %d vq 
%p
  virtio_irq(void *vq) vq %p
  virtio_notify(void *vdev, void *vq) vdev %p vq %p
  virtio_set_status(void *vdev, uint8_t val) vdev %p 

[Qemu-devel] [PATCH 1/6] trace: Make tracetool generate a group list

2011-10-12 Thread Mark Wu
Each trace events group starts with a line containing group_start:
GroupName and end with a line containing group_end. The range of
a trace events group is determined by the tracetool script when it
processes the trace-events file.

Signed-off-by: Mark Wu wu...@linux.vnet.ibm.com
---
 scripts/tracetool |   94 +++-
 trace-events  |   88 +
 2 files changed, 180 insertions(+), 2 deletions(-)

diff --git a/scripts/tracetool b/scripts/tracetool
index 4c9951d..3b4ca41 100755
--- a/scripts/tracetool
+++ b/scripts/tracetool
@@ -166,6 +166,82 @@ linetoc_end_nop()
 return
 }
 
+linetoh_begin_group()
+{
+group_num=0
+}
+
+linetoh_end_group()
+{
+cat EOF
+#define NR_TRACE_EVENT_GROUPS $group_num
+extern TraceEventGroup trace_group_list[NR_TRACE_EVENT_GROUPS];
+EOF
+}
+
+linetoc_begin_group()
+{
+cat EOF trace-groups
+
+TraceEventGroup trace_group_list[] = {
+
+EOF
+group_num=0
+}
+
+linetoc_end_group()
+{
+cat EOF trace-groups
+};
+EOF
+cat  trace-groups
+rm -f trace-groups
+}
+
+linetoc_group()
+{
+if echo $str|grep -q group_start; then
+gp_name=${1##*group_start:}
+   if ! test -z $gp_name; then
+start=$((${backend}_event_num))
+   fi
+elif echo $str|grep -q group_end; then
+   stop=$((${backend}_event_num - 1))
+   cat EOF trace-groups
+{.gp_name = $gp_name, .state = 0, .start = $start, .end = $stop},
+
+EOF
+   group_num=$((group_num + 1))
+fi
+}
+
+linetoc_group_simple()
+{
+linetoc_group $1
+}
+
+linetoc_group_stderr()
+{
+linetoc_group $1
+}
+
+linetoh_group()
+{
+if echo $str|grep -q group_end; then
+group_num=$((group_num + 1))
+fi
+}
+
+linetoh_group_simple()
+{
+linetoh_group
+}
+
+linetoh_group_stderr()
+{
+linetoh_group
+}
+
 linetoh_begin_simple()
 {
 cat EOF
@@ -173,8 +249,10 @@ linetoh_begin_simple()
 EOF
 
 simple_event_num=0
+linetoh_begin_group
 }
 
+
 cast_args_to_uint64_t()
 {
 local arg
@@ -206,12 +284,14 @@ EOF
 simple_event_num=$((simple_event_num + 1))
 }
 
+
 linetoh_end_simple()
 {
 cat EOF
 #define NR_TRACE_EVENTS $simple_event_num
 extern TraceEvent trace_list[NR_TRACE_EVENTS];
 EOF
+linetoh_end_group
 }
 
 linetoc_begin_simple()
@@ -222,7 +302,7 @@ linetoc_begin_simple()
 TraceEvent trace_list[] = {
 EOF
 simple_event_num=0
-
+linetoc_begin_group
 }
 
 linetoc_simple()
@@ -240,6 +320,7 @@ linetoc_end_simple()
 cat EOF
 };
 EOF
+linetoc_end_group
 }
 
 #STDERR
@@ -285,6 +366,7 @@ linetoh_end_stderr()
 cat EOF
 #define NR_TRACE_EVENTS $stderr_event_num
 EOF
+linetoh_end_group
 }
 
 linetoc_begin_stderr()
@@ -295,6 +377,7 @@ linetoc_begin_stderr()
 TraceEvent trace_list[] = {
 EOF
 stderr_event_num=0
+linetoc_begin_group
 }
 
 linetoc_stderr()
@@ -312,6 +395,7 @@ linetoc_end_stderr()
 cat EOF
 };
 EOF
+linetoc_end_group
 }
 #END OF STDERR
 
@@ -523,12 +607,18 @@ convert()
 begin=lineto$1_begin_$backend
 process_line=lineto$1_$backend
 end=lineto$1_end_$backend
+group=lineto$1_group_$backend
 
 $begin
 
 while read -r str; do
 # Skip comments and empty lines
-test -z ${str%%#*}  continue
+if test -z ${str%%#*}; then
+   if [ $backend == simple -o $backend == stderr ]  [ ! 
`echo $str|grep -q ^# group_` ]; then
+   $group $str
+   fi
+   continue
+   fi
 
 echo
 # Process the line.  The nop backend handles disabled lines.
diff --git a/trace-events b/trace-events
index a31d9aa..cbd4b58 100644
--- a/trace-events
+++ b/trace-events
@@ -26,6 +26,7 @@
 # The format-string should be a sprintf()-compatible format string.
 
 # qemu-malloc.c
+# group_start:qemu-memory
 g_malloc(size_t size, void *ptr) size %zu ptr %p
 g_realloc(void *ptr, size_t size, void *newptr) ptr %p size %zu newptr %p
 g_free(void *ptr) ptr %p
@@ -34,8 +35,10 @@ g_free(void *ptr) ptr %p
 qemu_memalign(size_t alignment, size_t size, void *ptr) alignment %zu size 
%zu ptr %p
 qemu_vmalloc(size_t size, void *ptr) size %zu ptr %p
 qemu_vfree(void *ptr) ptr %p
+# group_end
 
 # hw/virtio.c
+# group_start:virtio
 virtqueue_fill(void *vq, const void *elem, unsigned int len, unsigned int idx) 
vq %p elem %p len %u idx %u
 virtqueue_flush(void *vq, unsigned int count) vq %p count %u
 virtqueue_pop(void *vq, void *elem, unsigned int in_num, unsigned int out_num) 
vq %p elem %p in_num %u out_num %u
@@ -43,6 +46,7 @@ virtio_queue_notify(void *vdev, int n, void *vq) vdev %p n 
%d vq %p
 virtio_irq(void *vq) vq %p
 virtio_notify(void *vdev, void *vq) vdev %p vq %p
 virtio_set_status(void *vdev, uint8_t val) vdev %p val %u
+# group_end
 
 # hw/virtio-serial-bus.c
 virtio_serial_send_control_event(unsigned int port, uint16_t event, uint16_t 
value) port %u, event %u, value %u
@@ -51,11 +55,14 @@ virtio_serial_handle_control_message(uint16_t event, 
uint16_t value)