diff mbox series

[v17,23/24] target/rx: Dump bytes for each insn during disassembly

Message ID 20190607091116.49044-24-ysato@users.sourceforge.jp
State Superseded
Headers show
Series None | expand

Commit Message

Yoshinori Sato June 7, 2019, 9:11 a.m. UTC
From: Richard Henderson <richard.henderson@linaro.org>


There are so many different forms of each RX instruction
that it will be very useful to be able to look at the bytes
to see on which path a bug may lie.

Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp>

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>

---
 target/rx/disas.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

-- 
2.11.0

Comments

Philippe Mathieu-Daudé June 7, 2019, 1:42 p.m. UTC | #1
On 6/7/19 11:11 AM, Yoshinori Sato wrote:
> From: Richard Henderson <richard.henderson@linaro.org>

> 

> There are so many different forms of each RX instruction

> that it will be very useful to be able to look at the bytes

> to see on which path a bug may lie.

> 

> Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp>

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>


Again:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


> Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>

> ---

>  target/rx/disas.c | 16 +++++++++++++++-

>  1 file changed, 15 insertions(+), 1 deletion(-)

> 

> diff --git a/target/rx/disas.c b/target/rx/disas.c

> index 5a32a87534..d73b53db44 100644

> --- a/target/rx/disas.c

> +++ b/target/rx/disas.c

> @@ -102,7 +102,21 @@ static int bdsp_s(DisasContext *ctx, int d)

>  /* Include the auto-generated decoder.  */

>  #include "decode.inc.c"

>  

> -#define prt(...) (ctx->dis->fprintf_func)((ctx->dis->stream), __VA_ARGS__)

> +static void dump_bytes(DisasContext *ctx)

> +{

> +    int i, len = ctx->len;

> +

> +    for (i = 0; i < len; ++i) {

> +        ctx->dis->fprintf_func(ctx->dis->stream, "%02x ", ctx->bytes[i]);

> +    }

> +    ctx->dis->fprintf_func(ctx->dis->stream, "%*c", (8 - i) * 3, '\t');

> +}

> +

> +#define prt(...) \

> +    do {                                                        \

> +        dump_bytes(ctx);                                        \

> +        ctx->dis->fprintf_func(ctx->dis->stream, __VA_ARGS__);  \

> +    } while (0)

>  

>  #define RX_MEMORY_BYTE 0

>  #define RX_MEMORY_WORD 1

>
diff mbox series

Patch

diff --git a/target/rx/disas.c b/target/rx/disas.c
index 5a32a87534..d73b53db44 100644
--- a/target/rx/disas.c
+++ b/target/rx/disas.c
@@ -102,7 +102,21 @@  static int bdsp_s(DisasContext *ctx, int d)
 /* Include the auto-generated decoder.  */
 #include "decode.inc.c"
 
-#define prt(...) (ctx->dis->fprintf_func)((ctx->dis->stream), __VA_ARGS__)
+static void dump_bytes(DisasContext *ctx)
+{
+    int i, len = ctx->len;
+
+    for (i = 0; i < len; ++i) {
+        ctx->dis->fprintf_func(ctx->dis->stream, "%02x ", ctx->bytes[i]);
+    }
+    ctx->dis->fprintf_func(ctx->dis->stream, "%*c", (8 - i) * 3, '\t');
+}
+
+#define prt(...) \
+    do {                                                        \
+        dump_bytes(ctx);                                        \
+        ctx->dis->fprintf_func(ctx->dis->stream, __VA_ARGS__);  \
+    } while (0)
 
 #define RX_MEMORY_BYTE 0
 #define RX_MEMORY_WORD 1