Removing beaengine disassembler use.
This commit is contained in:
parent
5ab2ae4954
commit
b67488e70a
|
@ -7,13 +7,11 @@ project("xenia-cpu-backend-x64")
|
|||
kind("StaticLib")
|
||||
language("C++")
|
||||
links({
|
||||
"beaengine",
|
||||
"capstone",
|
||||
"xenia-base",
|
||||
"xenia-cpu",
|
||||
})
|
||||
defines({
|
||||
"BEA_ENGINE_STATIC=1",
|
||||
"CAPSTONE_X86_ATT_DISABLE",
|
||||
"CAPSTONE_DIET_NO",
|
||||
"CAPSTONE_X86_REDUCE_NO",
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include "xenia/cpu/backend/x64/x64_assembler.h"
|
||||
|
||||
#include "third_party/capstone/include/capstone.h"
|
||||
#include "third_party/capstone/include/x86.h"
|
||||
#include "xenia/base/reset_scope.h"
|
||||
#include "xenia/cpu/backend/x64/x64_backend.h"
|
||||
#include "xenia/cpu/backend/x64/x64_emitter.h"
|
||||
|
@ -19,19 +21,6 @@
|
|||
#include "xenia/cpu/processor.h"
|
||||
#include "xenia/profiling.h"
|
||||
|
||||
//#define DISASM_BEAENGINE
|
||||
#define DISASM_CAPSTONE
|
||||
|
||||
#ifdef DISASM_BEAENGINE
|
||||
namespace BE {
|
||||
#include <beaengine/BeaEngine.h>
|
||||
} // namespace BE
|
||||
#endif // DISASM_BEAENGINE
|
||||
#ifdef DISASM_CAPSTONE
|
||||
#include "third_party/capstone/include/capstone.h"
|
||||
#include "third_party/capstone/include/x86.h"
|
||||
#endif // DISASM_CAPSTONE
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
namespace backend {
|
||||
|
@ -44,13 +33,11 @@ using xe::cpu::hir::HIRBuilder;
|
|||
|
||||
X64Assembler::X64Assembler(X64Backend* backend)
|
||||
: Assembler(backend), x64_backend_(backend), capstone_handle_(0) {
|
||||
#ifdef DISASM_CAPSTONE
|
||||
if (cs_open(CS_ARCH_X86, CS_MODE_64, &capstone_handle_) != CS_ERR_OK) {
|
||||
assert_always("Failed to initialize capstone");
|
||||
}
|
||||
cs_option(capstone_handle_, CS_OPT_SYNTAX, CS_OPT_SYNTAX_INTEL);
|
||||
cs_option(capstone_handle_, CS_OPT_DETAIL, CS_OPT_OFF);
|
||||
#endif // DISASM_CAPSTONE
|
||||
}
|
||||
|
||||
X64Assembler::~X64Assembler() {
|
||||
|
@ -58,11 +45,9 @@ X64Assembler::~X64Assembler() {
|
|||
emitter_.reset();
|
||||
allocator_.reset();
|
||||
|
||||
#ifdef DISASM_CAPSTONE
|
||||
if (capstone_handle_) {
|
||||
cs_close(&capstone_handle_);
|
||||
}
|
||||
#endif // DISASM_CAPSTONE
|
||||
}
|
||||
|
||||
bool X64Assembler::Initialize() {
|
||||
|
@ -129,35 +114,6 @@ void X64Assembler::DumpMachineCode(DebugInfo* debug_info, void* machine_code,
|
|||
auto source_map_index = 0;
|
||||
uint32_t next_code_offset = source_map_entries[0].code_offset;
|
||||
|
||||
#if defined(DISASM_BEAENGINE)
|
||||
BE::DISASM disasm = {0};
|
||||
disasm.Archi = 64;
|
||||
disasm.Options = BE::Tabulation + BE::MasmSyntax + BE::PrefixedNumeral;
|
||||
disasm.EIP = (BE::UIntPtr)machine_code;
|
||||
BE::UIntPtr eip_end = disasm.EIP + code_size;
|
||||
uint64_t prev_source_offset = 0;
|
||||
while (disasm.EIP < eip_end) {
|
||||
// Look up source offset.
|
||||
auto code_offset =
|
||||
static_cast<uint32_t>(disasm.EIP - (BE::UIntPtr)machine_code);
|
||||
if (code_offset >= next_code_offset &&
|
||||
source_map_index < source_map_count) {
|
||||
auto& source_map_entry = source_map_entries[source_map_index];
|
||||
str->AppendFormat("%.8X ", source_map_entry.source_offset);
|
||||
++source_map_index;
|
||||
next_code_offset = source_map_entries[source_map_index].code_offset;
|
||||
} else {
|
||||
str->Append(" ");
|
||||
}
|
||||
|
||||
size_t len = BE::Disasm(&disasm);
|
||||
if (len == BE::UNKNOWN_OPCODE) {
|
||||
break;
|
||||
}
|
||||
str->AppendFormat("%.8X %s\n", uint32_t(disasm.EIP), disasm.CompleteInstr);
|
||||
disasm.EIP += len;
|
||||
}
|
||||
#elif defined(DISASM_CAPSTONE)
|
||||
const uint8_t* code_ptr = reinterpret_cast<uint8_t*>(machine_code);
|
||||
size_t remaining_code_size = code_size;
|
||||
uint64_t address = uint64_t(machine_code);
|
||||
|
@ -181,7 +137,6 @@ void X64Assembler::DumpMachineCode(DebugInfo* debug_info, void* machine_code,
|
|||
str->AppendFormat("%.8X %-6s %s\n", uint32_t(insn.address),
|
||||
insn.mnemonic, insn.op_str);
|
||||
}
|
||||
#endif // DISASM_BEAENGINE / DISASM_CAPSTONE
|
||||
}
|
||||
|
||||
} // namespace x64
|
||||
|
|
Loading…
Reference in New Issue