58 |
|
#define DEBUG 0 |
59 |
|
#include "debug.h" |
60 |
|
|
61 |
+ |
extern "C" { |
62 |
+ |
#include "dis-asm.h" |
63 |
+ |
} |
64 |
+ |
|
65 |
|
// Emulation time statistics |
66 |
|
#ifndef EMUL_TIME_STATS |
67 |
|
#define EMUL_TIME_STATS 0 |
730 |
|
ppc_cpu->dump_log(); |
731 |
|
} |
732 |
|
|
733 |
< |
/* |
734 |
< |
* Initialize CPU emulation |
735 |
< |
*/ |
733 |
> |
static int read_mem(bfd_vma memaddr, bfd_byte *myaddr, int length, struct disassemble_info *info) |
734 |
> |
{ |
735 |
> |
Mac2Host_memcpy(myaddr, memaddr, length); |
736 |
> |
return 0; |
737 |
> |
} |
738 |
> |
|
739 |
> |
static void dump_disassembly(const uint32 pc, const int prefix_count, const int suffix_count) |
740 |
> |
{ |
741 |
> |
struct disassemble_info info; |
742 |
> |
INIT_DISASSEMBLE_INFO(info, stderr, fprintf); |
743 |
> |
info.read_memory_func = read_mem; |
744 |
> |
|
745 |
> |
const int count = prefix_count + suffix_count + 1; |
746 |
> |
const uint32 base_addr = pc - prefix_count * 4; |
747 |
> |
for (int i = 0; i < count; i++) { |
748 |
> |
const bfd_vma addr = base_addr + i * 4; |
749 |
> |
fprintf(stderr, "%s0x%8llx: ", addr == pc ? " >" : " ", addr); |
750 |
> |
print_insn_ppc(addr, &info); |
751 |
> |
fprintf(stderr, "\n"); |
752 |
> |
} |
753 |
> |
} |
754 |
|
|
755 |
|
sigsegv_return_t sigsegv_handler(sigsegv_info_t *sip) |
756 |
|
{ |
816 |
|
fprintf(stderr, " ea %p\n", sigsegv_get_fault_address(sip)); |
817 |
|
dump_registers(); |
818 |
|
ppc_cpu->dump_log(); |
819 |
+ |
dump_disassembly(pc, 8, 8); |
820 |
+ |
|
821 |
|
enter_mon(); |
822 |
|
QuitEmulator(); |
823 |
|
|
824 |
|
return SIGSEGV_RETURN_FAILURE; |
825 |
|
} |
826 |
|
|
827 |
+ |
/* |
828 |
+ |
* Initialize CPU emulation |
829 |
+ |
*/ |
830 |
+ |
|
831 |
|
void init_emul_ppc(void) |
832 |
|
{ |
833 |
|
// Get pointer to KernelData in host address space |