Skip to content

Commit

Permalink
changed disas() prototype for multi target support
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@233 c046a42c-6fe2-441c-8c8c-71466251a162
  • Loading branch information
bellard committed Jun 15, 2003
1 parent 5898e81 commit 95cbfc6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
23 changes: 17 additions & 6 deletions disas.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ bfd_vma bfd_getb32 (const bfd_byte *addr)
return (bfd_vma) v;
}

/* Disassemble this for me please... (debugging). */
void disas(FILE *out, void *code, unsigned long size, enum disas_type type)
/* Disassemble this for me please... (debugging). 'flags' is only used
for i386: non zero means 16 bit code */
void disas(FILE *out, void *code, unsigned long size, int is_host, int flags)
{
uint8_t *pc;
int count;
Expand All @@ -106,7 +107,7 @@ void disas(FILE *out, void *code, unsigned long size, enum disas_type type)
disasm_info.buffer_vma = (unsigned long)code;
disasm_info.buffer_length = size;

if (type == DISAS_TARGET) {
if (is_host) {
#ifdef WORDS_BIGENDIAN
disasm_info.endian = BFD_ENDIAN_BIG;
#else
Expand All @@ -128,21 +129,31 @@ void disas(FILE *out, void *code, unsigned long size, enum disas_type type)
return;
#endif
} else {
/* Currently only source supported in x86. */
#ifdef TARGET_WORDS_BIGENDIAN
disasm_info.endian = BFD_ENDIAN_BIG;
#else
disasm_info.endian = BFD_ENDIAN_LITTLE;
if (type == DISAS_I386_I386)
#endif
#if defined(TARGET_I386)
if (!flags)
disasm_info.mach = bfd_mach_i386_i386;
else
disasm_info.mach = bfd_mach_i386_i8086;
print_insn = print_insn_i386;
#elif defined(TARGET_ARM)
print_insn = print_insn_arm;
#else
fprintf(out, "Asm output not supported on this arch\n");
return;
#endif
}

for (pc = code; pc < (uint8_t *)code + size; pc += count) {
fprintf(out, "0x%08lx: ", (long)pc);
#ifdef __arm__
/* since data are included in the code, it is better to
display code data too */
if (type == DISAS_TARGET) {
if (is_host) {
fprintf(out, "%08x ", (int)bfd_getl32((const bfd_byte *)pc));
}
#endif
Expand Down
8 changes: 1 addition & 7 deletions disas.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
#ifndef _QEMU_DISAS_H
#define _QEMU_DISAS_H

enum disas_type {
DISAS_I386_I386,
DISAS_I386_I8086,
DISAS_TARGET, /* whatever host is. */
};

/* Disassemble this for me please... (debugging). */
void disas(FILE *out, void *code, unsigned long size, enum disas_type type);
void disas(FILE *out, void *code, unsigned long size, int is_host, int flags);

/* Look up symbol for debugging purpose. Returns "" if unknown. */
const char *lookup_symbol(void *orig_addr);
Expand Down

0 comments on commit 95cbfc6

Please sign in to comment.