qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v7 08/11] arm: Support Capstone in disas_set_info
Date: Sat, 21 Oct 2017 17:46:18 -0700	[thread overview]
Message-ID: <20171022004621.28372-9-richard.henderson@linaro.org> (raw)
In-Reply-To: <20171022004621.28372-1-richard.henderson@linaro.org>

Tested-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 disas.c          |  3 +++
 target/arm/cpu.c | 21 ++++++++++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/disas.c b/disas.c
index 63dc573e9f..8d9bd4901c 100644
--- a/disas.c
+++ b/disas.c
@@ -450,6 +450,7 @@ void disas(FILE *out, void *code, unsigned long size)
     print_insn = print_insn_ppc;
 #elif defined(__aarch64__) && defined(CONFIG_ARM_A64_DIS)
     print_insn = print_insn_arm_a64;
+    s.info.cap_arch = CS_ARCH_ARM64;
 #elif defined(__alpha__)
     print_insn = print_insn_alpha;
 #elif defined(__sparc__)
@@ -457,6 +458,8 @@ void disas(FILE *out, void *code, unsigned long size)
     s.info.mach = bfd_mach_sparc_v9b;
 #elif defined(__arm__)
     print_insn = print_insn_arm;
+    s.info.cap_arch = CS_ARCH_ARM;
+    /* TCG only generates code for arm mode.  */
 #elif defined(__MIPSEB__)
     print_insn = print_insn_big_mips;
 #elif defined(__MIPSEL__)
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index a92d86faa0..a0ed11c9a5 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -33,6 +33,7 @@
 #include "sysemu/sysemu.h"
 #include "sysemu/hw_accel.h"
 #include "kvm_arm.h"
+#include "disas/capstone.h"
 
 static void arm_cpu_set_pc(CPUState *cs, vaddr value)
 {
@@ -487,10 +488,24 @@ static void arm_disas_set_info(CPUState *cpu, disassemble_info *info)
 #if defined(CONFIG_ARM_A64_DIS)
         info->print_insn = print_insn_arm_a64;
 #endif
-    } else if (env->thumb) {
-        info->print_insn = print_insn_thumb1;
+        info->cap_arch = CS_ARCH_ARM64;
     } else {
-        info->print_insn = print_insn_arm;
+        int cap_mode;
+        if (env->thumb) {
+            info->print_insn = print_insn_thumb1;
+            cap_mode = CS_MODE_THUMB;
+        } else {
+            info->print_insn = print_insn_arm;
+            cap_mode = CS_MODE_ARM;
+        }
+        if (arm_feature(env, ARM_FEATURE_V8)) {
+            cap_mode |= CS_MODE_V8;
+        }
+        if (arm_feature(env, ARM_FEATURE_M)) {
+            cap_mode |= CS_MODE_MCLASS;
+        }
+        info->cap_arch = CS_ARCH_ARM;
+        info->cap_mode = cap_mode;
     }
 
     sctlr_b = arm_sctlr_b(env);
-- 
2.13.6

  parent reply	other threads:[~2017-10-22  0:46 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-22  0:46 [Qemu-devel] [PATCH v7 00/11] Support the Capstone disassembler Richard Henderson
2017-10-22  0:46 ` [Qemu-devel] [PATCH v7 01/11] target/i386: Convert to disas_set_info hook Richard Henderson
2017-10-22  0:46 ` [Qemu-devel] [PATCH v7 02/11] target/ppc: " Richard Henderson
2017-10-22  0:46 ` [Qemu-devel] [PATCH v7 03/11] target/arm: Move BE32 disassembler fixup Richard Henderson
2017-10-24 21:35   ` Philippe Mathieu-Daudé
2017-10-22  0:46 ` [Qemu-devel] [PATCH v7 04/11] target/arm: Don't set INSN_ARM_BE32 for CONFIG_USER_ONLY Richard Henderson
2017-10-25 13:27   ` Philippe Mathieu-Daudé
2017-10-22  0:46 ` [Qemu-devel] [PATCH v7 05/11] disas: Remove unused flags arguments Richard Henderson
2017-10-22  0:46 ` [Qemu-devel] [PATCH v7 06/11] disas: Support the Capstone disassembler library Richard Henderson
2017-10-24 16:59   ` Philippe Mathieu-Daudé
2017-10-22  0:46 ` [Qemu-devel] [PATCH v7 07/11] i386: Support Capstone in disas_set_info Richard Henderson
2017-10-22  0:46 ` Richard Henderson [this message]
2017-10-22  0:46 ` [Qemu-devel] [PATCH v7 09/11] ppc: " Richard Henderson
2017-10-22  0:46 ` [Qemu-devel] [PATCH v7 10/11] disas: Remove monitor_disas_is_physical Richard Henderson
2017-10-22  0:46 ` [Qemu-devel] [PATCH v7 11/11] disas: Add capstone as submodule Richard Henderson
2017-10-24 16:45   ` Philippe Mathieu-Daudé
2017-10-24 19:40     ` Richard Henderson
2017-10-25 13:23       ` Philippe Mathieu-Daudé
2017-10-22  0:59 ` [Qemu-devel] [PATCH v7 00/11] Support the Capstone disassembler no-reply
2017-10-22  0:59 ` no-reply
2017-10-22  0:59 ` no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171022004621.28372-9-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).