mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-02-19 06:49:38 +00:00
fuzz_with_unicorn: Print AArch64 disassembly
This commit is contained in:
@@ -15,6 +15,8 @@ add_library(dynarmic
|
||||
common/crc32.h
|
||||
common/intrusive_list.h
|
||||
common/iterator_util.h
|
||||
common/llvm_disassemble.cpp
|
||||
common/llvm_disassemble.h
|
||||
common/memory_pool.cpp
|
||||
common/memory_pool.h
|
||||
common/mp.h
|
||||
@@ -158,8 +160,6 @@ if (ARCHITECTURE_x86_64)
|
||||
backend_x64/constant_pool.cpp
|
||||
backend_x64/constant_pool.h
|
||||
backend_x64/devirtualize.h
|
||||
backend_x64/disassemble_x64.cpp
|
||||
backend_x64/disassemble_x64.h
|
||||
backend_x64/emit_x64.cpp
|
||||
backend_x64/emit_x64.h
|
||||
backend_x64/emit_x64_aes.cpp
|
||||
|
||||
@@ -9,20 +9,15 @@
|
||||
#include <boost/icl/interval_set.hpp>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#ifdef DYNARMIC_USE_LLVM
|
||||
#include <llvm-c/Disassembler.h>
|
||||
#include <llvm-c/Target.h>
|
||||
#endif
|
||||
|
||||
#include "backend_x64/a32_emit_x64.h"
|
||||
#include "backend_x64/a32_jitstate.h"
|
||||
#include "backend_x64/block_of_code.h"
|
||||
#include "backend_x64/callback.h"
|
||||
#include "backend_x64/devirtualize.h"
|
||||
#include "backend_x64/disassemble_x64.h"
|
||||
#include "backend_x64/jitstate_info.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/llvm_disassemble.h"
|
||||
#include "common/scope_exit.h"
|
||||
#include "dynarmic/A32/a32.h"
|
||||
#include "dynarmic/A32/context.h"
|
||||
@@ -74,7 +69,7 @@ struct Jit::Impl {
|
||||
std::string Disassemble(const IR::LocationDescriptor& descriptor) {
|
||||
auto block = GetBasicBlock(descriptor);
|
||||
std::string result = fmt::format("address: {}\nsize: {} bytes\n", block.entrypoint, block.size);
|
||||
result += DisassembleX64(block.entrypoint, reinterpret_cast<const char*>(block.entrypoint) + block.size);
|
||||
result += Common::DisassembleX64(block.entrypoint, reinterpret_cast<const char*>(block.entrypoint) + block.size);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
#include "backend_x64/a64_jitstate.h"
|
||||
#include "backend_x64/block_of_code.h"
|
||||
#include "backend_x64/devirtualize.h"
|
||||
#include "backend_x64/disassemble_x64.h"
|
||||
#include "backend_x64/jitstate_info.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/scope_exit.h"
|
||||
#include "common/llvm_disassemble.h"
|
||||
#include "dynarmic/A64/a64.h"
|
||||
#include "frontend/A64/translate/translate.h"
|
||||
#include "frontend/ir/basic_block.h"
|
||||
@@ -164,7 +164,7 @@ public:
|
||||
}
|
||||
|
||||
std::string Disassemble() const {
|
||||
return DisassembleX64(block_of_code.GetCodeBegin(), block_of_code.getCurr());
|
||||
return Common::DisassembleX64(block_of_code.GetCodeBegin(), block_of_code.getCurr());
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
#include <llvm-c/Target.h>
|
||||
#endif
|
||||
|
||||
#include "backend_x64/disassemble_x64.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/llvm_disassemble.h"
|
||||
|
||||
namespace Dynarmic::BackendX64 {
|
||||
namespace Dynarmic::Common {
|
||||
|
||||
std::string DisassembleX64(const void* begin, const void* end) {
|
||||
std::string result;
|
||||
@@ -55,4 +55,28 @@ std::string DisassembleX64(const void* begin, const void* end) {
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace Dynarmic::BackendX64
|
||||
std::string DisassembleAArch64([[maybe_unused]] u32 instruction, [[maybe_unused]] u64 pc) {
|
||||
std::string result;
|
||||
|
||||
#ifdef DYNARMIC_USE_LLVM
|
||||
LLVMInitializeAArch64TargetInfo();
|
||||
LLVMInitializeAArch64TargetMC();
|
||||
LLVMInitializeAArch64Disassembler();
|
||||
LLVMDisasmContextRef llvm_ctx = LLVMCreateDisasm("aarch64", 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));
|
||||
ASSERT(inst_size);
|
||||
result = buffer;
|
||||
result += '\n';
|
||||
|
||||
LLVMDisasmDispose(llvm_ctx);
|
||||
#else
|
||||
result += fmt::format("(disassembly disabled)\n");
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace Dynarmic::Common
|
||||
@@ -6,8 +6,11 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Dynarmic::BackendX64 {
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace Dynarmic::Common {
|
||||
|
||||
std::string DisassembleX64(const void* pos, const void* end);
|
||||
std::string DisassembleAArch64(u32 instruction, u64 pc = 0);
|
||||
|
||||
} // namespace Dynarmic::BackendX64
|
||||
} // namespace Dynarmic::Common
|
||||
Reference in New Issue
Block a user