2003-04-30 04:41:16 +08:00
|
|
|
/* General "disassemble this chunk" code. Used for debugging. */
|
2016-01-30 01:50:05 +08:00
|
|
|
#include "qemu/osdep.h"
|
2019-04-18 03:18:04 +08:00
|
|
|
#include "disas/dis-asm.h"
|
2003-04-30 04:41:16 +08:00
|
|
|
#include "elf.h"
|
2019-04-18 03:18:03 +08:00
|
|
|
#include "qemu/qemu-print.h"
|
2003-04-30 04:41:16 +08:00
|
|
|
|
2012-10-24 17:12:21 +08:00
|
|
|
#include "disas/disas.h"
|
2017-09-15 00:41:12 +08:00
|
|
|
#include "disas/capstone.h"
|
2003-10-28 05:13:58 +08:00
|
|
|
|
2012-09-08 20:40:00 +08:00
|
|
|
typedef struct CPUDebug {
|
|
|
|
struct disassemble_info info;
|
2015-05-25 05:20:41 +08:00
|
|
|
CPUState *cpu;
|
2012-09-08 20:40:00 +08:00
|
|
|
} CPUDebug;
|
|
|
|
|
2003-04-30 04:41:16 +08:00
|
|
|
/* Filled in by elfload.c. Simplistic, but will do for now. */
|
2004-12-20 07:18:01 +08:00
|
|
|
struct syminfo *syminfos = NULL;
|
2003-04-30 04:41:16 +08:00
|
|
|
|
2020-09-11 05:40:54 +08:00
|
|
|
/*
|
|
|
|
* Get LENGTH bytes from info's buffer, at host address memaddr.
|
|
|
|
* Transfer them to myaddr.
|
|
|
|
*/
|
|
|
|
static int host_read_memory(bfd_vma memaddr, bfd_byte *myaddr, int length,
|
|
|
|
struct disassemble_info *info)
|
2003-06-09 23:23:31 +08:00
|
|
|
{
|
2003-10-28 05:13:58 +08:00
|
|
|
if (memaddr < info->buffer_vma
|
2020-09-11 05:40:54 +08:00
|
|
|
|| memaddr + length > info->buffer_vma + info->buffer_length) {
|
2003-10-28 05:13:58 +08:00
|
|
|
/* Out of bounds. Use EIO because GDB uses it. */
|
|
|
|
return EIO;
|
2020-09-11 05:40:54 +08:00
|
|
|
}
|
2003-10-28 05:13:58 +08:00
|
|
|
memcpy (myaddr, info->buffer + (memaddr - info->buffer_vma), length);
|
|
|
|
return 0;
|
2003-06-09 23:23:31 +08:00
|
|
|
}
|
|
|
|
|
2020-09-11 05:40:54 +08:00
|
|
|
/*
|
|
|
|
* Get LENGTH bytes from info's buffer, at target address memaddr.
|
|
|
|
* Transfer them to myaddr.
|
|
|
|
*/
|
|
|
|
static int target_read_memory(bfd_vma memaddr, bfd_byte *myaddr, int length,
|
|
|
|
struct disassemble_info *info)
|
2003-10-28 05:13:58 +08:00
|
|
|
{
|
2012-09-08 20:40:00 +08:00
|
|
|
CPUDebug *s = container_of(info, CPUDebug, info);
|
2020-09-11 05:40:54 +08:00
|
|
|
int r = cpu_memory_rw_debug(s->cpu, memaddr, myaddr, length, 0);
|
2020-05-18 23:53:04 +08:00
|
|
|
return r ? EIO : 0;
|
2003-10-28 05:13:58 +08:00
|
|
|
}
|
|
|
|
|
2020-09-11 05:40:54 +08:00
|
|
|
/*
|
|
|
|
* Print an error message. We can assume that this is in response to
|
|
|
|
* an error return from {host,target}_read_memory.
|
|
|
|
*/
|
|
|
|
static void perror_memory(int status, bfd_vma memaddr,
|
|
|
|
struct disassemble_info *info)
|
2003-06-09 23:23:31 +08:00
|
|
|
{
|
2020-09-11 05:40:54 +08:00
|
|
|
if (status != EIO) {
|
|
|
|
/* Can't happen. */
|
|
|
|
info->fprintf_func(info->stream, "Unknown error %d\n", status);
|
|
|
|
} else {
|
|
|
|
/* Address between memaddr and memaddr + len was out of bounds. */
|
|
|
|
info->fprintf_func(info->stream,
|
|
|
|
"Address 0x%" PRIx64 " is out of bounds.\n",
|
|
|
|
memaddr);
|
|
|
|
}
|
2003-06-09 23:23:31 +08:00
|
|
|
}
|
|
|
|
|
2020-09-11 05:40:54 +08:00
|
|
|
/* Print address in hex. */
|
|
|
|
static void print_address(bfd_vma addr, struct disassemble_info *info)
|
2003-06-09 23:23:31 +08:00
|
|
|
{
|
2020-09-11 05:40:54 +08:00
|
|
|
info->fprintf_func(info->stream, "0x%" PRIx64, addr);
|
2003-06-09 23:23:31 +08:00
|
|
|
}
|
|
|
|
|
2012-06-25 12:55:55 +08:00
|
|
|
/* Print address in hex, truncated to the width of a host virtual address. */
|
2020-09-11 05:40:54 +08:00
|
|
|
static void host_print_address(bfd_vma addr, struct disassemble_info *info)
|
2012-06-25 12:55:55 +08:00
|
|
|
{
|
2020-09-11 05:40:54 +08:00
|
|
|
print_address((uintptr_t)addr, info);
|
2012-06-25 12:55:55 +08:00
|
|
|
}
|
|
|
|
|
2020-09-11 05:40:54 +08:00
|
|
|
/* Stub prevents some fruitless earching in optabs disassemblers. */
|
|
|
|
static int symbol_at_address(bfd_vma addr, struct disassemble_info *info)
|
2003-06-09 23:23:31 +08:00
|
|
|
{
|
2020-09-11 05:40:54 +08:00
|
|
|
return 1;
|
2003-06-09 23:23:31 +08:00
|
|
|
}
|
|
|
|
|
2013-08-17 14:29:45 +08:00
|
|
|
static int print_insn_objdump(bfd_vma pc, disassemble_info *info,
|
|
|
|
const char *prefix)
|
|
|
|
{
|
|
|
|
int i, n = info->buffer_length;
|
2022-09-29 19:42:14 +08:00
|
|
|
g_autofree uint8_t *buf = g_malloc(n);
|
|
|
|
|
|
|
|
if (info->read_memory_func(pc, buf, n, info) == 0) {
|
|
|
|
for (i = 0; i < n; ++i) {
|
|
|
|
if (i % 32 == 0) {
|
|
|
|
info->fprintf_func(info->stream, "\n%s: ", prefix);
|
|
|
|
}
|
|
|
|
info->fprintf_func(info->stream, "%02x", buf[i]);
|
2013-08-17 14:29:45 +08:00
|
|
|
}
|
2022-09-29 19:42:14 +08:00
|
|
|
} else {
|
|
|
|
info->fprintf_func(info->stream, "unable to read memory");
|
2013-08-17 14:29:45 +08:00
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int print_insn_od_host(bfd_vma pc, disassemble_info *info)
|
|
|
|
{
|
|
|
|
return print_insn_objdump(pc, info, "OBJD-H");
|
|
|
|
}
|
|
|
|
|
|
|
|
static int print_insn_od_target(bfd_vma pc, disassemble_info *info)
|
|
|
|
{
|
|
|
|
return print_insn_objdump(pc, info, "OBJD-T");
|
|
|
|
}
|
|
|
|
|
2020-09-11 05:40:54 +08:00
|
|
|
static void initialize_debug(CPUDebug *s)
|
|
|
|
{
|
|
|
|
memset(s, 0, sizeof(*s));
|
|
|
|
s->info.arch = bfd_arch_unknown;
|
|
|
|
s->info.cap_arch = -1;
|
|
|
|
s->info.cap_insn_unit = 4;
|
|
|
|
s->info.cap_insn_split = 4;
|
|
|
|
s->info.memory_error_func = perror_memory;
|
|
|
|
s->info.symbol_at_address_func = symbol_at_address;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void initialize_debug_target(CPUDebug *s, CPUState *cpu)
|
|
|
|
{
|
|
|
|
initialize_debug(s);
|
|
|
|
|
|
|
|
s->cpu = cpu;
|
|
|
|
s->info.read_memory_func = target_read_memory;
|
|
|
|
s->info.print_address_func = print_address;
|
2022-03-23 23:57:18 +08:00
|
|
|
#if TARGET_BIG_ENDIAN
|
2020-09-11 05:40:54 +08:00
|
|
|
s->info.endian = BFD_ENDIAN_BIG;
|
|
|
|
#else
|
|
|
|
s->info.endian = BFD_ENDIAN_LITTLE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
CPUClass *cc = CPU_GET_CLASS(cpu);
|
|
|
|
if (cc->disas_set_info) {
|
|
|
|
cc->disas_set_info(cpu, &s->info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void initialize_debug_host(CPUDebug *s)
|
|
|
|
{
|
|
|
|
initialize_debug(s);
|
|
|
|
|
|
|
|
s->info.read_memory_func = host_read_memory;
|
|
|
|
s->info.print_address_func = host_print_address;
|
2022-03-23 23:57:17 +08:00
|
|
|
#if HOST_BIG_ENDIAN
|
2020-09-11 05:40:54 +08:00
|
|
|
s->info.endian = BFD_ENDIAN_BIG;
|
|
|
|
#else
|
|
|
|
s->info.endian = BFD_ENDIAN_LITTLE;
|
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_TCG_INTERPRETER)
|
|
|
|
s->info.print_insn = print_insn_tci;
|
|
|
|
#elif defined(__i386__)
|
|
|
|
s->info.mach = bfd_mach_i386_i386;
|
|
|
|
s->info.cap_arch = CS_ARCH_X86;
|
|
|
|
s->info.cap_mode = CS_MODE_32;
|
|
|
|
s->info.cap_insn_unit = 1;
|
|
|
|
s->info.cap_insn_split = 8;
|
|
|
|
#elif defined(__x86_64__)
|
|
|
|
s->info.mach = bfd_mach_x86_64;
|
|
|
|
s->info.cap_arch = CS_ARCH_X86;
|
|
|
|
s->info.cap_mode = CS_MODE_64;
|
|
|
|
s->info.cap_insn_unit = 1;
|
|
|
|
s->info.cap_insn_split = 8;
|
|
|
|
#elif defined(_ARCH_PPC)
|
|
|
|
s->info.cap_arch = CS_ARCH_PPC;
|
|
|
|
# ifdef _ARCH_PPC64
|
|
|
|
s->info.cap_mode = CS_MODE_64;
|
|
|
|
# endif
|
|
|
|
#elif defined(__riscv) && defined(CONFIG_RISCV_DIS)
|
|
|
|
#if defined(_ILP32) || (__riscv_xlen == 32)
|
|
|
|
s->info.print_insn = print_insn_riscv32;
|
|
|
|
#elif defined(_LP64)
|
|
|
|
s->info.print_insn = print_insn_riscv64;
|
|
|
|
#else
|
|
|
|
#error unsupported RISC-V ABI
|
|
|
|
#endif
|
2020-09-12 08:59:01 +08:00
|
|
|
#elif defined(__aarch64__)
|
2020-09-11 05:40:54 +08:00
|
|
|
s->info.cap_arch = CS_ARCH_ARM64;
|
|
|
|
#elif defined(__alpha__)
|
|
|
|
s->info.print_insn = print_insn_alpha;
|
|
|
|
#elif defined(__sparc__)
|
|
|
|
s->info.print_insn = print_insn_sparc;
|
|
|
|
s->info.mach = bfd_mach_sparc_v9b;
|
|
|
|
#elif defined(__arm__)
|
|
|
|
/* TCG only generates code for arm mode. */
|
|
|
|
s->info.cap_arch = CS_ARCH_ARM;
|
|
|
|
#elif defined(__MIPSEB__)
|
|
|
|
s->info.print_insn = print_insn_big_mips;
|
|
|
|
#elif defined(__MIPSEL__)
|
|
|
|
s->info.print_insn = print_insn_little_mips;
|
|
|
|
#elif defined(__m68k__)
|
|
|
|
s->info.print_insn = print_insn_m68k;
|
|
|
|
#elif defined(__s390__)
|
2020-01-04 05:24:59 +08:00
|
|
|
s->info.cap_arch = CS_ARCH_SYSZ;
|
|
|
|
s->info.cap_insn_unit = 2;
|
|
|
|
s->info.cap_insn_split = 6;
|
2020-09-11 05:40:54 +08:00
|
|
|
#elif defined(__hppa__)
|
|
|
|
s->info.print_insn = print_insn_hppa;
|
2022-12-01 08:22:09 +08:00
|
|
|
#elif defined(__loongarch__)
|
|
|
|
s->info.print_insn = print_insn_loongarch;
|
2020-09-11 05:40:54 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-09-14 23:38:35 +08:00
|
|
|
/* Disassemble this for me please... (debugging). */
|
2015-05-25 05:20:41 +08:00
|
|
|
void target_disas(FILE *out, CPUState *cpu, target_ulong code,
|
2017-09-14 23:38:35 +08:00
|
|
|
target_ulong size)
|
2003-04-30 04:41:16 +08:00
|
|
|
{
|
2005-01-04 07:35:10 +08:00
|
|
|
target_ulong pc;
|
2003-04-30 04:41:16 +08:00
|
|
|
int count;
|
2012-09-08 20:40:00 +08:00
|
|
|
CPUDebug s;
|
2003-04-30 04:41:16 +08:00
|
|
|
|
2020-09-11 05:40:54 +08:00
|
|
|
initialize_debug_target(&s, cpu);
|
|
|
|
s.info.fprintf_func = fprintf;
|
|
|
|
s.info.stream = out;
|
2012-09-08 20:40:00 +08:00
|
|
|
s.info.buffer_vma = code;
|
|
|
|
s.info.buffer_length = size;
|
2015-06-24 11:57:33 +08:00
|
|
|
|
2017-09-15 00:41:12 +08:00
|
|
|
if (s.info.cap_arch >= 0 && cap_disas_target(&s.info, code, size)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-06-24 11:57:32 +08:00
|
|
|
if (s.info.print_insn == NULL) {
|
|
|
|
s.info.print_insn = print_insn_od_target;
|
2013-08-17 14:29:45 +08:00
|
|
|
}
|
2003-10-28 05:13:58 +08:00
|
|
|
|
2009-02-14 05:44:41 +08:00
|
|
|
for (pc = code; size > 0; pc += count, size -= count) {
|
2005-02-01 07:32:31 +08:00
|
|
|
fprintf(out, "0x" TARGET_FMT_lx ": ", pc);
|
2015-06-24 11:57:32 +08:00
|
|
|
count = s.info.print_insn(pc, &s.info);
|
2005-01-04 07:35:10 +08:00
|
|
|
fprintf(out, "\n");
|
|
|
|
if (count < 0)
|
|
|
|
break;
|
2009-04-22 06:26:22 +08:00
|
|
|
if (size < count) {
|
|
|
|
fprintf(out,
|
|
|
|
"Disassembler disagrees with translator over instruction "
|
|
|
|
"decoding\n"
|
|
|
|
"Please report this to qemu-devel@nongnu.org\n");
|
|
|
|
break;
|
|
|
|
}
|
2005-01-04 07:35:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-19 21:02:00 +08:00
|
|
|
static int G_GNUC_PRINTF(2, 3)
|
|
|
|
gstring_printf(FILE *stream, const char *fmt, ...)
|
2019-05-22 17:27:14 +08:00
|
|
|
{
|
2020-09-11 06:13:38 +08:00
|
|
|
/* We abuse the FILE parameter to pass a GString. */
|
|
|
|
GString *s = (GString *)stream;
|
2019-05-22 17:27:14 +08:00
|
|
|
int initial_len = s->len;
|
2020-09-11 06:13:38 +08:00
|
|
|
va_list va;
|
2019-05-22 17:27:14 +08:00
|
|
|
|
|
|
|
va_start(va, fmt);
|
|
|
|
g_string_append_vprintf(s, fmt, va);
|
|
|
|
va_end(va);
|
|
|
|
|
|
|
|
return s->len - initial_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void plugin_print_address(bfd_vma addr, struct disassemble_info *info)
|
|
|
|
{
|
|
|
|
/* does nothing */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We should only be dissembling one instruction at a time here. If
|
|
|
|
* there is left over it usually indicates the front end has read more
|
|
|
|
* bytes than it needed.
|
|
|
|
*/
|
|
|
|
char *plugin_disas(CPUState *cpu, uint64_t addr, size_t size)
|
|
|
|
{
|
|
|
|
CPUDebug s;
|
2020-09-11 06:13:38 +08:00
|
|
|
GString *ds = g_string_new(NULL);
|
2019-05-22 17:27:14 +08:00
|
|
|
|
2020-09-11 05:40:54 +08:00
|
|
|
initialize_debug_target(&s, cpu);
|
2022-09-29 19:42:13 +08:00
|
|
|
s.info.fprintf_func = gstring_printf;
|
2020-09-11 06:13:38 +08:00
|
|
|
s.info.stream = (FILE *)ds; /* abuse this slot */
|
2019-05-22 17:27:14 +08:00
|
|
|
s.info.buffer_vma = addr;
|
|
|
|
s.info.buffer_length = size;
|
|
|
|
s.info.print_address_func = plugin_print_address;
|
|
|
|
|
|
|
|
if (s.info.cap_arch >= 0 && cap_disas_plugin(&s.info, addr, size)) {
|
2020-09-11 06:13:38 +08:00
|
|
|
; /* done */
|
|
|
|
} else if (s.info.print_insn) {
|
|
|
|
s.info.print_insn(addr, &s.info);
|
|
|
|
} else {
|
|
|
|
; /* cannot disassemble -- return empty string */
|
2019-05-22 17:27:14 +08:00
|
|
|
}
|
|
|
|
|
2020-09-11 06:13:38 +08:00
|
|
|
/* Return the buffer, freeing the GString container. */
|
|
|
|
return g_string_free(ds, false);
|
2019-05-22 17:27:14 +08:00
|
|
|
}
|
|
|
|
|
2005-01-04 07:35:10 +08:00
|
|
|
/* Disassemble this for me please... (debugging). */
|
2020-10-31 11:59:01 +08:00
|
|
|
void disas(FILE *out, const void *code, unsigned long size)
|
2005-01-04 07:35:10 +08:00
|
|
|
{
|
2012-04-12 21:44:35 +08:00
|
|
|
uintptr_t pc;
|
2005-01-04 07:35:10 +08:00
|
|
|
int count;
|
2012-09-08 20:40:00 +08:00
|
|
|
CPUDebug s;
|
2005-01-04 07:35:10 +08:00
|
|
|
|
2020-09-11 05:40:54 +08:00
|
|
|
initialize_debug_host(&s);
|
|
|
|
s.info.fprintf_func = fprintf;
|
|
|
|
s.info.stream = out;
|
2012-09-08 20:40:00 +08:00
|
|
|
s.info.buffer = code;
|
|
|
|
s.info.buffer_vma = (uintptr_t)code;
|
|
|
|
s.info.buffer_length = size;
|
2017-09-15 00:41:12 +08:00
|
|
|
|
2020-09-11 03:15:04 +08:00
|
|
|
if (s.info.cap_arch >= 0 && cap_disas_host(&s.info, code, size)) {
|
2017-09-15 00:41:12 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-09-11 05:40:54 +08:00
|
|
|
if (s.info.print_insn == NULL) {
|
|
|
|
s.info.print_insn = print_insn_od_host;
|
2013-08-17 14:29:45 +08:00
|
|
|
}
|
2012-04-12 21:44:35 +08:00
|
|
|
for (pc = (uintptr_t)code; size > 0; pc += count, size -= count) {
|
|
|
|
fprintf(out, "0x%08" PRIxPTR ": ", pc);
|
2020-09-11 05:40:54 +08:00
|
|
|
count = s.info.print_insn(pc, &s.info);
|
2020-05-14 01:51:32 +08:00
|
|
|
fprintf(out, "\n");
|
|
|
|
if (count < 0) {
|
|
|
|
break;
|
|
|
|
}
|
2003-04-30 04:41:16 +08:00
|
|
|
}
|
2020-05-14 01:51:32 +08:00
|
|
|
|
2003-04-30 04:41:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Look up symbol for debugging purpose. Returns "" if unknown. */
|
2005-01-04 07:35:10 +08:00
|
|
|
const char *lookup_symbol(target_ulong orig_addr)
|
2003-04-30 04:41:16 +08:00
|
|
|
{
|
2008-10-22 23:11:31 +08:00
|
|
|
const char *symbol = "";
|
2004-12-20 07:18:01 +08:00
|
|
|
struct syminfo *s;
|
2007-09-17 16:09:54 +08:00
|
|
|
|
2004-12-20 07:18:01 +08:00
|
|
|
for (s = syminfos; s; s = s->next) {
|
2008-10-22 23:11:31 +08:00
|
|
|
symbol = s->lookup_symbol(s, orig_addr);
|
|
|
|
if (symbol[0] != '\0') {
|
|
|
|
break;
|
|
|
|
}
|
2003-04-30 04:41:16 +08:00
|
|
|
}
|
2008-10-22 23:11:31 +08:00
|
|
|
|
|
|
|
return symbol;
|
2003-04-30 04:41:16 +08:00
|
|
|
}
|
2004-04-04 20:57:25 +08:00
|
|
|
|
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
|
|
|
|
2012-12-18 01:19:49 +08:00
|
|
|
#include "monitor/monitor.h"
|
2004-08-02 05:49:07 +08:00
|
|
|
|
2004-04-04 20:57:25 +08:00
|
|
|
static int
|
2017-09-19 22:40:40 +08:00
|
|
|
physical_read_memory(bfd_vma memaddr, bfd_byte *myaddr, int length,
|
2008-08-18 04:21:51 +08:00
|
|
|
struct disassemble_info *info)
|
2004-04-04 20:57:25 +08:00
|
|
|
{
|
2018-12-14 21:30:49 +08:00
|
|
|
CPUDebug *s = container_of(info, CPUDebug, info);
|
2020-05-18 23:53:04 +08:00
|
|
|
MemTxResult res;
|
2018-12-14 21:30:49 +08:00
|
|
|
|
2020-05-18 23:53:04 +08:00
|
|
|
res = address_space_read(s->cpu->as, memaddr, MEMTXATTRS_UNSPECIFIED,
|
|
|
|
myaddr, length);
|
|
|
|
return res == MEMTX_OK ? 0 : EIO;
|
2004-04-04 20:57:25 +08:00
|
|
|
}
|
|
|
|
|
2017-09-14 23:38:35 +08:00
|
|
|
/* Disassembler for the monitor. */
|
2015-05-25 05:20:41 +08:00
|
|
|
void monitor_disas(Monitor *mon, CPUState *cpu,
|
2017-09-14 23:38:35 +08:00
|
|
|
target_ulong pc, int nb_insn, int is_physical)
|
2004-04-04 20:57:25 +08:00
|
|
|
{
|
|
|
|
int count, i;
|
2012-09-08 20:40:00 +08:00
|
|
|
CPUDebug s;
|
2022-09-29 19:42:13 +08:00
|
|
|
g_autoptr(GString) ds = g_string_new("");
|
2004-04-04 20:57:25 +08:00
|
|
|
|
2020-09-11 05:40:54 +08:00
|
|
|
initialize_debug_target(&s, cpu);
|
2022-09-29 19:42:13 +08:00
|
|
|
s.info.fprintf_func = gstring_printf;
|
|
|
|
s.info.stream = (FILE *)ds; /* abuse this slot */
|
|
|
|
|
2020-09-11 05:40:54 +08:00
|
|
|
if (is_physical) {
|
|
|
|
s.info.read_memory_func = physical_read_memory;
|
2015-06-24 11:57:33 +08:00
|
|
|
}
|
2020-09-11 05:40:54 +08:00
|
|
|
s.info.buffer_vma = pc;
|
2015-06-24 11:57:33 +08:00
|
|
|
|
2017-09-15 00:41:12 +08:00
|
|
|
if (s.info.cap_arch >= 0 && cap_disas_monitor(&s.info, pc, nb_insn)) {
|
2022-09-29 19:42:13 +08:00
|
|
|
monitor_puts(mon, ds->str);
|
2017-09-15 00:41:12 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-06-24 11:57:33 +08:00
|
|
|
if (!s.info.print_insn) {
|
|
|
|
monitor_printf(mon, "0x" TARGET_FMT_lx
|
|
|
|
": Asm output not supported on this arch\n", pc);
|
|
|
|
return;
|
|
|
|
}
|
2004-04-04 20:57:25 +08:00
|
|
|
|
2022-09-29 19:42:13 +08:00
|
|
|
for (i = 0; i < nb_insn; i++) {
|
|
|
|
g_string_append_printf(ds, "0x" TARGET_FMT_lx ": ", pc);
|
2015-06-24 11:57:32 +08:00
|
|
|
count = s.info.print_insn(pc, &s.info);
|
2022-09-29 19:42:13 +08:00
|
|
|
g_string_append_c(ds, '\n');
|
|
|
|
if (count < 0) {
|
|
|
|
break;
|
|
|
|
}
|
2004-04-04 20:57:25 +08:00
|
|
|
pc += count;
|
|
|
|
}
|
2022-09-29 19:42:13 +08:00
|
|
|
|
|
|
|
monitor_puts(mon, ds->str);
|
2004-04-04 20:57:25 +08:00
|
|
|
}
|
|
|
|
#endif
|