[PATCH 4/4] target/riscv: honour no_raw_bytes when disassembling

Alex Bennée posted 4 patches 8 months, 3 weeks ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <Alistair.Francis@wdc.com>, Song Gao <gaosong@loongson.cn>
[PATCH 4/4] target/riscv: honour no_raw_bytes when disassembling
Posted by Alex Bennée 8 months, 3 weeks ago
This makes the output suitable when used for plugins.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 disas/riscv.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/disas/riscv.c b/disas/riscv.c
index 8a546d5ea53..86028efea85 100644
--- a/disas/riscv.c
+++ b/disas/riscv.c
@@ -5192,19 +5192,21 @@ print_insn_riscv(bfd_vma memaddr, struct disassemble_info *info, rv_isa isa)
         }
     }
 
-    switch (len) {
-    case 2:
-        (*info->fprintf_func)(info->stream, INST_FMT_2, inst);
-        break;
-    case 4:
-        (*info->fprintf_func)(info->stream, INST_FMT_4, inst);
-        break;
-    case 6:
-        (*info->fprintf_func)(info->stream, INST_FMT_6, inst);
-        break;
-    default:
-        (*info->fprintf_func)(info->stream, INST_FMT_8, inst);
-        break;
+    if (!info->no_raw_bytes) {
+        switch (len) {
+        case 2:
+            (*info->fprintf_func)(info->stream, INST_FMT_2, inst);
+            break;
+        case 4:
+            (*info->fprintf_func)(info->stream, INST_FMT_4, inst);
+            break;
+        case 6:
+            (*info->fprintf_func)(info->stream, INST_FMT_6, inst);
+            break;
+        default:
+            (*info->fprintf_func)(info->stream, INST_FMT_8, inst);
+            break;
+        }
     }
 
     disasm_inst(buf, sizeof(buf), isa, memaddr, inst,
-- 
2.39.2


Re: [PATCH 4/4] target/riscv: honour no_raw_bytes when disassembling
Posted by Alistair Francis 8 months, 3 weeks ago
On Tue, Mar 5, 2024 at 5:15 AM Alex Bennée <alex.bennee@linaro.org> wrote:
>
> This makes the output suitable when used for plugins.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

Acked-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  disas/riscv.c | 28 +++++++++++++++-------------
>  1 file changed, 15 insertions(+), 13 deletions(-)
>
> diff --git a/disas/riscv.c b/disas/riscv.c
> index 8a546d5ea53..86028efea85 100644
> --- a/disas/riscv.c
> +++ b/disas/riscv.c
> @@ -5192,19 +5192,21 @@ print_insn_riscv(bfd_vma memaddr, struct disassemble_info *info, rv_isa isa)
>          }
>      }
>
> -    switch (len) {
> -    case 2:
> -        (*info->fprintf_func)(info->stream, INST_FMT_2, inst);
> -        break;
> -    case 4:
> -        (*info->fprintf_func)(info->stream, INST_FMT_4, inst);
> -        break;
> -    case 6:
> -        (*info->fprintf_func)(info->stream, INST_FMT_6, inst);
> -        break;
> -    default:
> -        (*info->fprintf_func)(info->stream, INST_FMT_8, inst);
> -        break;
> +    if (!info->no_raw_bytes) {
> +        switch (len) {
> +        case 2:
> +            (*info->fprintf_func)(info->stream, INST_FMT_2, inst);
> +            break;
> +        case 4:
> +            (*info->fprintf_func)(info->stream, INST_FMT_4, inst);
> +            break;
> +        case 6:
> +            (*info->fprintf_func)(info->stream, INST_FMT_6, inst);
> +            break;
> +        default:
> +            (*info->fprintf_func)(info->stream, INST_FMT_8, inst);
> +            break;
> +        }
>      }
>
>      disasm_inst(buf, sizeof(buf), isa, memaddr, inst,
> --
> 2.39.2
>
>