Skip to content

Commit

Permalink
JIT: enabled udis86 logging
Browse files Browse the repository at this point in the history
  • Loading branch information
FrodeSolheim committed Sep 7, 2015
1 parent d62da37 commit 774df57
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
6 changes: 3 additions & 3 deletions libudis86/include/udis86.h
Expand Up @@ -26,8 +26,8 @@
#ifndef UDIS86_H
#define UDIS86_H

#include "libudis86/types.h"
#include "libudis86/extern.h"
#include "libudis86/itab.h"
#include "../src/types.h"
#include "../src/extern.h"
#include "../src/itab.h"

#endif
6 changes: 3 additions & 3 deletions src/jit/codegen_udis86.h
Expand Up @@ -17,7 +17,7 @@
if (dSize > 0) { \
uint8_t* p = (uint8_t*)(udis_func); \
for ( ; dSize && (!p[dSize-1] || (0x90 == p[dSize-1])); --dSize) ; /* Find ending */ \
JITLOG("Disassembling %s (size %u bytes) @ 0x%p:", #udis_func, dSize, p) \
jit_log("Disassembling %s (size %u bytes) @ 0x%p:", #udis_func, dSize, p) \
for (int i = 0; i < dSize; i += 0x10) { \
write_log("%08x ", i); \
for (int j = 0; j < 16; ++j) \
Expand All @@ -31,10 +31,10 @@
ud_set_syntax(&ud_obj, UD_SYN_INTEL); \
while (dSize > 0) { \
dSize -= ud_disassemble(&ud_obj); \
JITLOG(" [x86] %s", ud_insn_asm(&ud_obj)); \
jit_log(" [x86] %s", ud_insn_asm(&ud_obj)); \
} \
} else \
JITLOG("Can't dissassemble %s, start (0x%08lx) is larger than end (0x%08lx)", \
jit_log("Can't dissassemble %s, start (0x%08lx) is larger than end (0x%08lx)", \
#udis_func, (uintptr_t)udis_func, (uintptr_t)udis_end); \
}

Expand Down
5 changes: 5 additions & 0 deletions src/jit/codegen_x86.cpp
Expand Up @@ -3360,6 +3360,11 @@ cpuid(uae_u32 op, uae_u32 *eax, uae_u32 *ebx, uae_u32 *ecx, uae_u32 *edx)
raw_pop_l_r(1);
raw_pop_l_r(0);
raw_ret();
#ifdef USE_UDIS86
if (!op) { /* Only disassemble once! */
UDISFN(cpuid_space, target)
}
#endif
set_target(tmp);

((compop_func*)cpuid_space)(0);
Expand Down
10 changes: 10 additions & 0 deletions src/jit/compemu_support.cpp
Expand Up @@ -82,6 +82,9 @@
#include "comptbl.h"
#ifdef UAE
#include "compemu.h"
#ifdef FSUAE
#include "codegen_udis86.h"
#endif
#else
#include "compiler/compemu.h"
#include "fpu/fpu.h"
Expand Down Expand Up @@ -3648,6 +3651,9 @@ static inline void create_popalls(void)

#ifdef UAE
/* FIXME: write-protect popallspace? */
#ifdef USE_UDIS86
UDISFN(pushall_call_handler, get_target());
#endif
#else
// no need to further write into popallspace
vm_protect(popallspace, POPALLSPACE_SIZE, VM_PAGE_READ | VM_PAGE_EXECUTE);
Expand Down Expand Up @@ -4552,6 +4558,10 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
align_target(align_jumps);
current_compile_p=get_target();

#ifdef USE_UDIS86
UDISFN(current_block_start_target, target)
#endif

raise_in_cl_list(bi);
bi->nexthandler=current_compile_p;

Expand Down

0 comments on commit 774df57

Please sign in to comment.