]> git.proxmox.com Git - qemu.git/blobdiff - disas.c
added a command line monitor
[qemu.git] / disas.c
diff --git a/disas.c b/disas.c
index 8a44e91477dadf1adc98c43077080a922ad5373f..f274ac52d1e2eca22b4118badc88ab7a5d413b57 100644 (file)
--- a/disas.c
+++ b/disas.c
@@ -5,6 +5,9 @@
 #include "elf.h"
 #include <errno.h>
 
+#include "cpu.h"
+#include "exec-all.h"
+
 /* Filled in by elfload.c.  Simplistic, but will do for now. */
 unsigned int disas_num_syms;
 void *disas_symtab;
@@ -19,14 +22,32 @@ buffer_read_memory (memaddr, myaddr, length, info)
      int length;
      struct disassemble_info *info;
 {
-  if (memaddr < info->buffer_vma
-      || memaddr + length > info->buffer_vma + info->buffer_length)
-    /* Out of bounds.  Use EIO because GDB uses it.  */
-    return EIO;
-  memcpy (myaddr, info->buffer + (memaddr - info->buffer_vma), length);
-  return 0;
+    if (memaddr < info->buffer_vma
+        || memaddr + length > info->buffer_vma + info->buffer_length)
+        /* Out of bounds.  Use EIO because GDB uses it.  */
+        return EIO;
+    memcpy (myaddr, info->buffer + (memaddr - info->buffer_vma), length);
+    return 0;
 }
 
+#if !defined(CONFIG_USER_ONLY)
+/* Get LENGTH bytes from info's buffer, at target address memaddr.
+   Transfer them to myaddr.  */
+static int
+target_read_memory (memaddr, myaddr, length, info)
+     bfd_vma memaddr;
+     bfd_byte *myaddr;
+     int length;
+     struct disassemble_info *info;
+{
+    int i;
+    for(i = 0; i < length; i++) {
+        myaddr[i] = ldub_code((void *)((long)memaddr + i));
+    }
+    return 0;
+}
+#endif
+
 /* Print an error message.  We can assume that this is in response to
    an error return from buffer_read_memory.  */
 void
@@ -103,6 +124,12 @@ void disas(FILE *out, void *code, unsigned long size, int is_host, int flags)
 
     INIT_DISASSEMBLE_INFO(disasm_info, out, fprintf);
 
+#if !defined(CONFIG_USER_ONLY)
+    if (!is_host) {
+        disasm_info.read_memory_func = target_read_memory;
+    }
+#endif
+
     disasm_info.buffer = code;
     disasm_info.buffer_vma = (unsigned long)code;
     disasm_info.buffer_length = size;
@@ -142,6 +169,10 @@ void disas(FILE *out, void *code, unsigned long size, int is_host, int flags)
        print_insn = print_insn_i386;
 #elif defined(TARGET_ARM)
        print_insn = print_insn_arm;
+#elif defined(TARGET_SPARC)
+       print_insn = print_insn_sparc;
+#elif defined(TARGET_PPC)
+       print_insn = print_insn_ppc;
 #else
        fprintf(out, "Asm output not supported on this arch\n");
        return;