qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH 14/26] sdcard: use qemu_hexbuf_strdup() to trace


From: Philippe Mathieu-Daudé
Subject: [Qemu-devel] [RFC PATCH 14/26] sdcard: use qemu_hexbuf_strdup() to trace command response
Date: Wed, 13 Dec 2017 20:20:13 -0300

Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
 hw/sd/sd.c         | 26 +++++++-------------------
 hw/sd/trace-events |  1 +
 2 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 84e02745f1..2a249b1612 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -35,6 +35,7 @@
 #include "hw/sd/sd.h"
 #include "qapi/error.h"
 #include "qemu/bitmap.h"
+#include "qemu/cutils.h"
 #include "hw/qdev-properties.h"
 #include "qemu/error-report.h"
 #include "qemu/timer.h"
@@ -42,15 +43,6 @@
 #include "sd-internal.h"
 #include "trace.h"
 
-//#define DEBUG_SD 1
-
-#ifdef DEBUG_SD
-#define DPRINTF(fmt, ...) \
-do { fprintf(stderr, "SD: " fmt , ## __VA_ARGS__); } while (0)
-#else
-#define DPRINTF(fmt, ...) do {} while(0)
-#endif
-
 #define ACMD41_ENQUIRY_MASK     0x00ffffff
 #define OCR_POWER_UP            0x80000000
 #define OCR_POWER_DELAY_NS      500000 /* 0.5ms */
@@ -1595,17 +1587,13 @@ send_response:
         sd->card_status &= ~CARD_STATUS_B;
     }
 
-#ifdef DEBUG_SD
-    if (rsplen) {
-        int i;
-        DPRINTF("Response:");
-        for (i = 0; i < rsplen; i++)
-            fprintf(stderr, " %02x", response[i]);
-        fprintf(stderr, " state %d\n", sd->state);
-    } else {
-        DPRINTF("No response %d\n", sd->state);
+    if (trace_event_get_state_backends(TRACE_SDCARD_COMMAND_RESPONSE)) {
+        char *hexbuf;
+
+        hexbuf = qemu_hexbuf_strdup(response, rsplen, NULL, "(no response)");
+        trace_sdcard_command_response(hexbuf, sd_state_name(sd->state));
+        g_free(hexbuf);
     }
-#endif
 
     return rsplen;
 }
diff --git a/hw/sd/trace-events b/hw/sd/trace-events
index 0e78f980de..01f94c4b54 100644
--- a/hw/sd/trace-events
+++ b/hw/sd/trace-events
@@ -26,6 +26,7 @@ sdcard_set_mode(const char *current_mode, const char 
*new_mode, const char *stat
 sdcard_set_state(const char *current_state, const char *new_state, const char 
*mode) "%s -> %s (mode: %s)"
 sdcard_normal_command(uint8_t cmd, uint32_t arg, const char *state) "CMD%d arg 
0x%08x (state %s)"
 sdcard_app_command(uint8_t acmd, uint32_t arg) "ACMD%d arg 0x%08x"
+sdcard_command_response(const char *hexdump, const char *state) "%s (state %s)"
 sdcard_reset(void) ""
 sdcard_inserted(bool readonly) "read_only: %d"
 sdcard_ejected(void) ""
-- 
2.15.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]