print_info: Use LLVM to disassemble A32
This commit is contained in:
parent
c59a127e86
commit
d0075f4ea6
4 changed files with 26 additions and 2 deletions
|
@ -127,7 +127,7 @@ if (DYNARMIC_USE_LLVM)
|
||||||
find_package(LLVM REQUIRED CONFIG)
|
find_package(LLVM REQUIRED CONFIG)
|
||||||
include_directories(${LLVM_INCLUDE_DIRS})
|
include_directories(${LLVM_INCLUDE_DIRS})
|
||||||
add_definitions(-DDYNARMIC_USE_LLVM ${LLVM_DEFINITIONS})
|
add_definitions(-DDYNARMIC_USE_LLVM ${LLVM_DEFINITIONS})
|
||||||
llvm_map_components_to_libnames(llvm_libs aarch64desc aarch64disassembler x86desc x86disassembler)
|
llvm_map_components_to_libnames(llvm_libs armdesc armdisassembler aarch64desc aarch64disassembler x86desc x86disassembler)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (DYNARMIC_TESTS_USE_UNICORN)
|
if (DYNARMIC_TESTS_USE_UNICORN)
|
||||||
|
|
|
@ -54,6 +54,29 @@ std::string DisassembleX64(const void* begin, const void* end) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string DisassembleAArch32([[maybe_unused]] u32 instruction, [[maybe_unused]] u64 pc) {
|
||||||
|
std::string result;
|
||||||
|
|
||||||
|
#ifdef DYNARMIC_USE_LLVM
|
||||||
|
LLVMInitializeARMTargetInfo();
|
||||||
|
LLVMInitializeARMTargetMC();
|
||||||
|
LLVMInitializeARMDisassembler();
|
||||||
|
LLVMDisasmContextRef llvm_ctx = LLVMCreateDisasm("armv8-arm", nullptr, 0, nullptr, nullptr);
|
||||||
|
LLVMSetDisasmOptions(llvm_ctx, LLVMDisassembler_Option_AsmPrinterVariant);
|
||||||
|
|
||||||
|
char buffer[80];
|
||||||
|
size_t inst_size = LLVMDisasmInstruction(llvm_ctx, (u8*)&instruction, sizeof(instruction), pc, buffer, sizeof(buffer));
|
||||||
|
result = inst_size > 0 ? buffer : "<invalid instruction>";
|
||||||
|
result += '\n';
|
||||||
|
|
||||||
|
LLVMDisasmDispose(llvm_ctx);
|
||||||
|
#else
|
||||||
|
result += fmt::format("(disassembly disabled)\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
std::string DisassembleAArch64([[maybe_unused]] u32 instruction, [[maybe_unused]] u64 pc) {
|
std::string DisassembleAArch64([[maybe_unused]] u32 instruction, [[maybe_unused]] u64 pc) {
|
||||||
std::string result;
|
std::string result;
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
namespace Dynarmic::Common {
|
namespace Dynarmic::Common {
|
||||||
|
|
||||||
std::string DisassembleX64(const void* pos, const void* end);
|
std::string DisassembleX64(const void* pos, const void* end);
|
||||||
|
std::string DisassembleAArch32(u32 instruction, u64 pc = 0);
|
||||||
std::string DisassembleAArch64(u32 instruction, u64 pc = 0);
|
std::string DisassembleAArch64(u32 instruction, u64 pc = 0);
|
||||||
|
|
||||||
} // namespace Dynarmic::Common
|
} // namespace Dynarmic::Common
|
||||||
|
|
|
@ -48,7 +48,7 @@ const char* GetNameOfA64Instruction(u32 instruction) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintA32Instruction(u32 instruction) {
|
void PrintA32Instruction(u32 instruction) {
|
||||||
fmt::print("{:08x} {}\n", instruction, A32::DisassembleArm(instruction));
|
fmt::print("{:08x} {}\n", instruction, Common::DisassembleAArch32(instruction));
|
||||||
fmt::print("Name: {}\n", GetNameOfA32Instruction(instruction));
|
fmt::print("Name: {}\n", GetNameOfA32Instruction(instruction));
|
||||||
|
|
||||||
const A32::LocationDescriptor location{0, {}, {}};
|
const A32::LocationDescriptor location{0, {}, {}};
|
||||||
|
|
Loading…
Reference in a new issue