diff mbox series

[v4,5/9] i386: Support Capstone in disas_set_info

Message ID 20170928165414.7339-6-richard.henderson@linaro.org
State Superseded
Headers show
Series Support the Capstone disassembler | expand

Commit Message

Richard Henderson Sept. 28, 2017, 4:54 p.m. UTC
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

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

---
 disas.c           | 4 ++++
 target/i386/cpu.c | 7 +++++++
 2 files changed, 11 insertions(+)

-- 
2.13.5

Comments

Philippe Mathieu-Daudé Oct. 2, 2017, 1:37 p.m. UTC | #1
On 09/28/2017 01:54 PM, Richard Henderson wrote:
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>


Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


i386, x86_64:
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


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

> ---

>   disas.c           | 4 ++++

>   target/i386/cpu.c | 7 +++++++

>   2 files changed, 11 insertions(+)

> 

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

> index 746d76c07d..1c44514254 100644

> --- a/disas.c

> +++ b/disas.c

> @@ -439,9 +439,13 @@ void disas(FILE *out, void *code, unsigned long size)

>   #elif defined(__i386__)

>       s.info.mach = bfd_mach_i386_i386;

>       print_insn = print_insn_i386;

> +    s.info.cap_arch = CS_ARCH_X86;

> +    s.info.cap_mode = CS_MODE_32;

>   #elif defined(__x86_64__)

>       s.info.mach = bfd_mach_x86_64;

>       print_insn = print_insn_i386;

> +    s.info.cap_arch = CS_ARCH_X86;

> +    s.info.cap_mode = CS_MODE_64;

>   #elif defined(_ARCH_PPC)

>       s.info.disassembler_options = (char *)"any";

>       print_insn = print_insn_ppc;

> diff --git a/target/i386/cpu.c b/target/i386/cpu.c

> index 13b2f8fbc5..cf890b763b 100644

> --- a/target/i386/cpu.c

> +++ b/target/i386/cpu.c

> @@ -51,6 +51,8 @@

>   #include "hw/i386/apic_internal.h"

>   #endif

>   

> +#include "disas/capstone.h"

> +

>   

>   /* Cache topology CPUID constants: */

>   

> @@ -4106,6 +4108,11 @@ static void x86_disas_set_info(CPUState *cs, disassemble_info *info)

>                     : env->hflags & HF_CS32_MASK ? bfd_mach_i386_i386

>                     : bfd_mach_i386_i8086);

>       info->print_insn = print_insn_i386;

> +

> +    info->cap_arch = CS_ARCH_X86;

> +    info->cap_mode = (env->hflags & HF_CS64_MASK ? CS_MODE_64

> +                      : env->hflags & HF_CS32_MASK ? CS_MODE_32

> +                      : CS_MODE_16);

>   }

>   

>   static Property x86_cpu_properties[] = {

>
diff mbox series

Patch

diff --git a/disas.c b/disas.c
index 746d76c07d..1c44514254 100644
--- a/disas.c
+++ b/disas.c
@@ -439,9 +439,13 @@  void disas(FILE *out, void *code, unsigned long size)
 #elif defined(__i386__)
     s.info.mach = bfd_mach_i386_i386;
     print_insn = print_insn_i386;
+    s.info.cap_arch = CS_ARCH_X86;
+    s.info.cap_mode = CS_MODE_32;
 #elif defined(__x86_64__)
     s.info.mach = bfd_mach_x86_64;
     print_insn = print_insn_i386;
+    s.info.cap_arch = CS_ARCH_X86;
+    s.info.cap_mode = CS_MODE_64;
 #elif defined(_ARCH_PPC)
     s.info.disassembler_options = (char *)"any";
     print_insn = print_insn_ppc;
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 13b2f8fbc5..cf890b763b 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -51,6 +51,8 @@ 
 #include "hw/i386/apic_internal.h"
 #endif
 
+#include "disas/capstone.h"
+
 
 /* Cache topology CPUID constants: */
 
@@ -4106,6 +4108,11 @@  static void x86_disas_set_info(CPUState *cs, disassemble_info *info)
                   : env->hflags & HF_CS32_MASK ? bfd_mach_i386_i386
                   : bfd_mach_i386_i8086);
     info->print_insn = print_insn_i386;
+
+    info->cap_arch = CS_ARCH_X86;
+    info->cap_mode = (env->hflags & HF_CS64_MASK ? CS_MODE_64
+                      : env->hflags & HF_CS32_MASK ? CS_MODE_32
+                      : CS_MODE_16);
 }
 
 static Property x86_cpu_properties[] = {