Patchwork [07/10] trace: qemu_(put|get)_(byte|buffer) events

login
register
mail settings
Submitter Michael Roth
Date Oct. 14, 2011, 6:19 p.m.
Message ID <1318616402-18474-8-git-send-email-mdroth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/119896/
State New
Headers show

Comments

Michael Roth - Oct. 14, 2011, 6:19 p.m.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 qemu-file.c  |   22 ++++++++++++++++++++--
 trace-events |   18 ++++++++++++++++++
 2 files changed, 38 insertions(+), 2 deletions(-)

Patch

diff --git a/qemu-file.c b/qemu-file.c
index 3d05622..34bc136 100644
--- a/qemu-file.c
+++ b/qemu-file.c
@@ -27,6 +27,7 @@ 
 #include "hw/hw.h"
 #include "qapi/qemu-file-output-visitor.h"
 #include "qapi/qemu-file-input-visitor.h"
+#include "trace.h"
 
 #define IO_BUF_SIZE 32768
 
@@ -206,6 +207,8 @@  void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size)
 {
     int l;
 
+    trace_qemu_put_buffer(f, buf, size);
+
     if (!f->has_error && f->is_write == 0 && f->buf_index > 0) {
         fprintf(stderr,
                 "Attempted to write to buffer while read buffer is not empty\n");
@@ -236,6 +239,7 @@  void qemu_put_byte(QEMUFile *f, int v)
         abort();
     }
 
+    trace_qemu_put_byte(f, v & 0xff);
     f->buf[f->buf_index++] = v;
     f->is_write = 1;
     if (f->buf_index >= IO_BUF_SIZE) {
@@ -247,6 +251,8 @@  int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size1)
 {
     int size, l;
 
+    trace_qemu_get_buffer(f, buf, size1);
+
     if (f->is_write) {
         abort();
     }
@@ -273,6 +279,8 @@  int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size1)
 
 int qemu_get_byte(QEMUFile *f)
 {
+    int ret;
+
     if (f->is_write) {
         abort();
     }
@@ -280,10 +288,14 @@  int qemu_get_byte(QEMUFile *f)
     if (f->buf_index >= f->buf_size) {
         qemu_fill_buffer(f);
         if (f->buf_index >= f->buf_size) {
-            return 0;
+            ret = 0;
+            goto out;
         }
     }
-    return f->buf[f->buf_index++];
+    ret = f->buf[f->buf_index++];
+out:
+    trace_qemu_get_byte(f, ret);
+    return ret;
 }
 
 int64_t qemu_ftell(QEMUFile *f)
@@ -360,6 +372,7 @@  void qemu_put_be16(QEMUFile *f, unsigned int v)
 {
     qemu_put_byte(f, v >> 8);
     qemu_put_byte(f, v);
+    trace_qemu_put_be16(f, v);
 }
 
 void qemu_put_be32(QEMUFile *f, unsigned int v)
@@ -368,12 +381,14 @@  void qemu_put_be32(QEMUFile *f, unsigned int v)
     qemu_put_byte(f, v >> 16);
     qemu_put_byte(f, v >> 8);
     qemu_put_byte(f, v);
+    trace_qemu_put_be32(f, v);
 }
 
 void qemu_put_be64(QEMUFile *f, uint64_t v)
 {
     qemu_put_be32(f, v >> 32);
     qemu_put_be32(f, v);
+    trace_qemu_put_be64(f, v);
 }
 
 unsigned int qemu_get_be16(QEMUFile *f)
@@ -381,6 +396,7 @@  unsigned int qemu_get_be16(QEMUFile *f)
     unsigned int v;
     v = qemu_get_byte(f) << 8;
     v |= qemu_get_byte(f);
+    trace_qemu_get_be16(f, v);
     return v;
 }
 
@@ -391,6 +407,7 @@  unsigned int qemu_get_be32(QEMUFile *f)
     v |= qemu_get_byte(f) << 16;
     v |= qemu_get_byte(f) << 8;
     v |= qemu_get_byte(f);
+    trace_qemu_get_be32(f, v);
     return v;
 }
 
@@ -399,6 +416,7 @@  uint64_t qemu_get_be64(QEMUFile *f)
     uint64_t v;
     v = (uint64_t)qemu_get_be32(f) << 32;
     v |= qemu_get_be32(f);
+    trace_qemu_get_be64(f, v);
     return v;
 }
 
diff --git a/trace-events b/trace-events
index 63d8c8e..fe639ff 100644
--- a/trace-events
+++ b/trace-events
@@ -538,3 +538,21 @@  esp_mem_writeb_cmd_ensel(uint32_t val) "Enable selection (%2.2x)"
 # monitor.c
 handle_qmp_command(void *mon, const char *cmd_name) "mon %p cmd_name \"%s\""
 monitor_protocol_emitter(void *mon) "mon %p"
+
+# qemu-file.c
+qemu_put_buffer(void *f, const uint8_t *buf, int size) "file=%p, buf=%p, size=%d"
+qemu_get_buffer(void *f, const uint8_t *buf, int size) "file=%p, buf=%p, size=%d"
+qemu_put_byte(void *f, int val) "file=%p, val=0x%x"
+qemu_get_byte(void *f, int val) "file=%p, val=0x%x"
+qemu_put_be16(void *f, unsigned int v) "file=%p, val=0x%x"
+qemu_get_be16(void *f, unsigned int v) "file=%p, val=0x%x"
+qemu_put_be32(void *f, unsigned int v) "file=%p, val=0x%x"
+qemu_get_be32(void *f, unsigned int v) "file=%p, val=0x%x"
+qemu_put_be64(void *f, uint64_t v) "file=%p, val=0x%"PRIx64
+qemu_get_be64(void *f, uint64_t v) "file=%p, val=0x%"PRIx64
+qemu_put_sbe16(void *f, int v) "file=%p, val=0x%x"
+qemu_get_sbe16(void *f, int v) "file=%p, val=0x%x"
+qemu_put_sbe32(void *f, int v) "file=%p, val=0x%x"
+qemu_get_sbe32(void *f, int v) "file=%p, val=0x%x"
+qemu_put_sbe64(void *f, int64_t v) "file=%p, val=0x%"PRIx64
+qemu_get_sbe64(void *f, int64_t v) "file=%p, val=0x%"PRIx64