aboutsummaryrefslogtreecommitdiff
path: root/disas.c
diff options
context:
space:
mode:
Diffstat (limited to 'disas.c')
-rw-r--r--disas.c119
1 files changed, 44 insertions, 75 deletions
diff --git a/disas.c b/disas.c
index 576c6a437b..69a6066914 100644
--- a/disas.c
+++ b/disas.c
@@ -1,5 +1,6 @@
/* General "disassemble this chunk" code. Used for debugging. */
#include "config.h"
+#include "qemu-common.h"
#include "disas/bfd.h"
#include "elf.h"
#include <errno.h>
@@ -150,14 +151,6 @@ bfd_vma bfd_getb16 (const bfd_byte *addr)
return (bfd_vma) v;
}
-#ifdef TARGET_ARM
-static int
-print_insn_thumb1(bfd_vma pc, disassemble_info *info)
-{
- return print_insn_arm(pc | 1, info);
-}
-#endif
-
static int print_insn_objdump(bfd_vma pc, disassemble_info *info,
const char *prefix)
{
@@ -190,7 +183,6 @@ static int print_insn_od_target(bfd_vma pc, disassemble_info *info)
/* Disassemble this for me please... (debugging). 'flags' has the following
values:
i386 - 1 means 16 bit code, 2 means 64 bit code
- arm - bit 0 = thumb, bit 1 = reverse endian, bit 2 = A64
ppc - bits 0:15 specify (optionally) the machine instruction set;
bit 16 indicates little endian.
other targets - unused
@@ -198,10 +190,10 @@ static int print_insn_od_target(bfd_vma pc, disassemble_info *info)
void target_disas(FILE *out, CPUState *cpu, target_ulong code,
target_ulong size, int flags)
{
+ CPUClass *cc = CPU_GET_CLASS(cpu);
target_ulong pc;
int count;
CPUDebug s;
- int (*print_insn)(bfd_vma pc, disassemble_info *info) = NULL;
INIT_DISASSEMBLE_INFO(s.info, out, fprintf);
@@ -216,6 +208,11 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code,
#else
s.info.endian = BFD_ENDIAN_LITTLE;
#endif
+
+ if (cc->disas_set_info) {
+ cc->disas_set_info(cpu, &s.info);
+ }
+
#if defined(TARGET_I386)
if (flags == 2) {
s.info.mach = bfd_mach_x86_64;
@@ -224,30 +221,9 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code,
} else {
s.info.mach = bfd_mach_i386_i386;
}
- print_insn = print_insn_i386;
-#elif defined(TARGET_ARM)
- if (flags & 4) {
- /* We might not be compiled with the A64 disassembler
- * because it needs a C++ compiler; in that case we will
- * fall through to the default print_insn_od case.
- */
-#if defined(CONFIG_ARM_A64_DIS)
- print_insn = print_insn_arm_a64;
-#endif
- } else if (flags & 1) {
- print_insn = print_insn_thumb1;
- } else {
- print_insn = print_insn_arm;
- }
- if (flags & 2) {
-#ifdef TARGET_WORDS_BIGENDIAN
- s.info.endian = BFD_ENDIAN_LITTLE;
-#else
- s.info.endian = BFD_ENDIAN_BIG;
-#endif
- }
+ s.info.print_insn = print_insn_i386;
#elif defined(TARGET_SPARC)
- print_insn = print_insn_sparc;
+ s.info.print_insn = print_insn_sparc;
#ifdef TARGET_SPARC64
s.info.mach = bfd_mach_sparc_v9b;
#endif
@@ -266,49 +242,38 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code,
#endif
}
s.info.disassembler_options = (char *)"any";
- print_insn = print_insn_ppc;
+ s.info.print_insn = print_insn_ppc;
#elif defined(TARGET_M68K)
- print_insn = print_insn_m68k;
+ s.info.print_insn = print_insn_m68k;
#elif defined(TARGET_MIPS)
#ifdef TARGET_WORDS_BIGENDIAN
- print_insn = print_insn_big_mips;
+ s.info.print_insn = print_insn_big_mips;
#else
- print_insn = print_insn_little_mips;
+ s.info.print_insn = print_insn_little_mips;
#endif
#elif defined(TARGET_SH4)
s.info.mach = bfd_mach_sh4;
- print_insn = print_insn_sh;
+ s.info.print_insn = print_insn_sh;
#elif defined(TARGET_ALPHA)
s.info.mach = bfd_mach_alpha_ev6;
- print_insn = print_insn_alpha;
-#elif defined(TARGET_CRIS)
- if (flags != 32) {
- s.info.mach = bfd_mach_cris_v0_v10;
- print_insn = print_insn_crisv10;
- } else {
- s.info.mach = bfd_mach_cris_v32;
- print_insn = print_insn_crisv32;
- }
+ s.info.print_insn = print_insn_alpha;
#elif defined(TARGET_S390X)
s.info.mach = bfd_mach_s390_64;
- print_insn = print_insn_s390;
-#elif defined(TARGET_MICROBLAZE)
- s.info.mach = bfd_arch_microblaze;
- print_insn = print_insn_microblaze;
+ s.info.print_insn = print_insn_s390;
#elif defined(TARGET_MOXIE)
s.info.mach = bfd_arch_moxie;
- print_insn = print_insn_moxie;
+ s.info.print_insn = print_insn_moxie;
#elif defined(TARGET_LM32)
s.info.mach = bfd_mach_lm32;
- print_insn = print_insn_lm32;
+ s.info.print_insn = print_insn_lm32;
#endif
- if (print_insn == NULL) {
- print_insn = print_insn_od_target;
+ if (s.info.print_insn == NULL) {
+ s.info.print_insn = print_insn_od_target;
}
for (pc = code; size > 0; pc += count, size -= count) {
fprintf(out, "0x" TARGET_FMT_lx ": ", pc);
- count = print_insn(pc, &s.info);
+ count = s.info.print_insn(pc, &s.info);
#if 0
{
int i;
@@ -450,9 +415,9 @@ monitor_fprintf(FILE *stream, const char *fmt, ...)
void monitor_disas(Monitor *mon, CPUState *cpu,
target_ulong pc, int nb_insn, int is_physical, int flags)
{
+ CPUClass *cc = CPU_GET_CLASS(cpu);
int count, i;
CPUDebug s;
- int (*print_insn)(bfd_vma pc, disassemble_info *info);
INIT_DISASSEMBLE_INFO(s.info, (FILE *)mon, monitor_fprintf);
@@ -468,6 +433,11 @@ void monitor_disas(Monitor *mon, CPUState *cpu,
#else
s.info.endian = BFD_ENDIAN_LITTLE;
#endif
+
+ if (cc->disas_set_info) {
+ cc->disas_set_info(cpu, &s.info);
+ }
+
#if defined(TARGET_I386)
if (flags == 2) {
s.info.mach = bfd_mach_x86_64;
@@ -476,13 +446,11 @@ void monitor_disas(Monitor *mon, CPUState *cpu,
} else {
s.info.mach = bfd_mach_i386_i386;
}
- print_insn = print_insn_i386;
-#elif defined(TARGET_ARM)
- print_insn = print_insn_arm;
+ s.info.print_insn = print_insn_i386;
#elif defined(TARGET_ALPHA)
- print_insn = print_insn_alpha;
+ s.info.print_insn = print_insn_alpha;
#elif defined(TARGET_SPARC)
- print_insn = print_insn_sparc;
+ s.info.print_insn = print_insn_sparc;
#ifdef TARGET_SPARC64
s.info.mach = bfd_mach_sparc_v9b;
#endif
@@ -500,36 +468,37 @@ void monitor_disas(Monitor *mon, CPUState *cpu,
if ((flags >> 16) & 1) {
s.info.endian = BFD_ENDIAN_LITTLE;
}
- print_insn = print_insn_ppc;
+ s.info.print_insn = print_insn_ppc;
#elif defined(TARGET_M68K)
- print_insn = print_insn_m68k;
+ s.info.print_insn = print_insn_m68k;
#elif defined(TARGET_MIPS)
#ifdef TARGET_WORDS_BIGENDIAN
- print_insn = print_insn_big_mips;
+ s.info.print_insn = print_insn_big_mips;
#else
- print_insn = print_insn_little_mips;
+ s.info.print_insn = print_insn_little_mips;
#endif
#elif defined(TARGET_SH4)
s.info.mach = bfd_mach_sh4;
- print_insn = print_insn_sh;
+ s.info.print_insn = print_insn_sh;
#elif defined(TARGET_S390X)
s.info.mach = bfd_mach_s390_64;
- print_insn = print_insn_s390;
+ s.info.print_insn = print_insn_s390;
#elif defined(TARGET_MOXIE)
s.info.mach = bfd_arch_moxie;
- print_insn = print_insn_moxie;
+ s.info.print_insn = print_insn_moxie;
#elif defined(TARGET_LM32)
s.info.mach = bfd_mach_lm32;
- print_insn = print_insn_lm32;
-#else
- monitor_printf(mon, "0x" TARGET_FMT_lx
- ": Asm output not supported on this arch\n", pc);
- return;
+ s.info.print_insn = print_insn_lm32;
#endif
+ if (!s.info.print_insn) {
+ monitor_printf(mon, "0x" TARGET_FMT_lx
+ ": Asm output not supported on this arch\n", pc);
+ return;
+ }
for(i = 0; i < nb_insn; i++) {
monitor_printf(mon, "0x" TARGET_FMT_lx ": ", pc);
- count = print_insn(pc, &s.info);
+ count = s.info.print_insn(pc, &s.info);
monitor_printf(mon, "\n");
if (count < 0)
break;