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 

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 Wu
---
  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()
+{
+cattrace-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<>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<  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) "event %u,
  virtio_serial_handle_control_message_port(unsigned int port) "port %u"

  # hw/virtio-console.c
+# group_start:virtio-console
  virtio_console_flush_buf(unsigned int port, size_t len, ssize_t ret) "port %u, 
in_len %zu, out_len %zd"
  virtio_console_chr_read(unsigned int port, int size) "port %u, size %d"
  virtio_console_chr_event(unsigned int port, int event) "port %u, event %d"
+# group_end

  # block.c
+# group_start:block
  multiwrite_cb(void *mcb, int ret) "mcb %p ret %d"
  bdrv_aio_multiwrite(void *mcb, int num_callbacks, int num_reqs) "mcb %p 
num_callbacks %d num_reqs %d"
  bdrv_aio_multiwrite_earlyfail(void *mcb) "mcb %p"
@@ -67,26 +74,34 @@ bdrv_lock_medium(void *bs, bool locked) "bs %p locked %d"
  bdrv_co_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num 
%"PRId64" nb_sectors %d"
  bdrv_co_writev(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num 
%"PRId64" nb_sectors %d"
  bdrv_co_io(int is_write, void *acb) "is_write %d acb %p"
+# group_end

  # hw/virtio-blk.c
+# group_start:virtio-blk
  virtio_blk_req_complete(void *req, int status) "req %p status %d"
  virtio_blk_rw_complete(void *req, int ret) "req %p ret %d"
  virtio_blk_handle_write(void *req, uint64_t sector, size_t nsectors) "req %p sector 
%"PRIu64" nsectors %zu"
+# group_end

  # posix-aio-compat.c
+# group_start:posix-aio
  paio_submit(void *acb, void *opaque, int64_t sector_num, int nb_sectors, int type) "acb %p 
opaque %p sector_num %"PRId64" nb_sectors %d type %d"
  paio_complete(void *acb, void *opaque, int ret) "acb %p opaque %p ret %d"
  paio_cancel(void *acb, void *opaque) "acb %p opaque %p"
+# group_end

  # ioport.c
+# group_start:ioport
  cpu_in(unsigned int addr, unsigned int val) "addr %#x value %u

[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 
---
 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 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 <>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 < 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) "event %u,
 virtio_serial_handle_control_message_port(unsigned int port) "port %u"
 
 # hw/virtio-console.c
+# group_start:virtio-console
 virtio_console_flush_buf(unsigned int port, size_t len, ssize_t ret) "port %u, 
in_len %zu, out_len %zd"
 virtio_console_chr_read(unsigned int port, int size) "port %u, size %d"
 virtio_console_chr_event(unsigned int port, int event) "port %u, event %d"
+# group_end
 
 # block.c
+# group_start:block
 multiwrite_cb(void *mcb, int ret) "mcb %p ret %d"
 bdrv_aio_multiwrite(void *mcb, int num_callbacks, int num_reqs) "mcb %p 
num_callbacks %d num_reqs %d"
 bdrv_aio_multiwrite_earlyfail(void *mcb) "mcb %p"
@@ -67,26 +74,34 @@ bdrv_lock_medium(void *bs, bool locked) "bs %p locked %d"
 bdrv_co_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num 
%"PRId64" nb_sectors %d"
 bdrv_co_writev(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num 
%"PRId64" nb_sectors %d"
 bdrv_co_io(int is_write, void *acb) "is_write %d acb %p"
+# group_end
 
 # hw/virtio-blk.c
+# group_start:virtio-blk
 virtio_blk_req_complete(void *req, int status) "req %p status %d"
 virtio_blk_rw_complete(void *req, int ret) "req %p ret %d"
 virtio_blk_handle_write(void *req, uint64_t sector, size_t nsectors) "req %p 
sector %"PRIu64" nsectors %zu"
+# group_end
 
 # posix-aio-compat.c
+# group_start:posix-aio
 paio_submit(void *acb, void *opaque, int64_t sector_num, int nb_sectors, int 
type) "acb %p opaque %p sector_num %"PRId64" nb_sectors %d type %d"
 paio_complete(void *acb, void *opaque, int ret) "acb %p opaque %p ret %d"
 paio_cancel(void *acb, void *opaque) "acb %p opaque %p"
+# group_end
 
 # ioport.c
+# group_start:ioport
 cpu_in(unsigned int addr, unsigned int val) "addr %#x value %u"
 cpu_out(unsigned int addr, unsigned int val) "addr %#x value %u"
+# group_end
 
 # balloon.c
 # Since requests are raised via monitor, not many tracepoints are needed.
 balloon_event(void *opaque, unsigned long