diff --git a/src/dynarmic/backend/x64/a32_interface.cpp b/src/dynarmic/backend/x64/a32_interface.cpp index af0ee8ea..69dfce08 100644 --- a/src/dynarmic/backend/x64/a32_interface.cpp +++ b/src/dynarmic/backend/x64/a32_interface.cpp @@ -18,8 +18,8 @@ #include "dynarmic/common/assert.h" #include "dynarmic/common/cast_util.h" #include "dynarmic/common/common_types.h" -#include "dynarmic/common/llvm_disassemble.h" #include "dynarmic/common/scope_exit.h" +#include "dynarmic/common/x64_disassemble.h" #include "dynarmic/frontend/A32/translate/translate.h" #include "dynarmic/interface/A32/a32.h" #include "dynarmic/interface/A32/context.h" @@ -91,13 +91,6 @@ struct Jit::Impl { jit_state.exclusive_state = 0; } - 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 += Common::DisassembleX64(block.entrypoint, reinterpret_cast(block.entrypoint) + block.size); - return result; - } - void PerformCacheInvalidation() { if (invalidate_entire_cache) { jit_state.ResetRSB(); @@ -324,8 +317,9 @@ void Jit::LoadContext(const Context& ctx) { impl->jit_state.TransferJitState(ctx.impl->jit_state, reset_rsb); } -std::string Jit::Disassemble() const { - return Common::DisassembleX64(impl->block_of_code.GetCodeBegin(), impl->block_of_code.getCurr()); +void Jit::DumpDisassembly() const { + const size_t size = (const char*)impl->block_of_code.getCurr() - (const char*)impl->block_of_code.GetCodeBegin(); + Common::DumpDisassembledX64(impl->block_of_code.GetCodeBegin(), size); } } // namespace Dynarmic::A32 diff --git a/src/dynarmic/backend/x64/a64_interface.cpp b/src/dynarmic/backend/x64/a64_interface.cpp index 940797d8..4dc68c2f 100644 --- a/src/dynarmic/backend/x64/a64_interface.cpp +++ b/src/dynarmic/backend/x64/a64_interface.cpp @@ -14,8 +14,8 @@ #include "dynarmic/backend/x64/devirtualize.h" #include "dynarmic/backend/x64/jitstate_info.h" #include "dynarmic/common/assert.h" -#include "dynarmic/common/llvm_disassemble.h" #include "dynarmic/common/scope_exit.h" +#include "dynarmic/common/x64_disassemble.h" #include "dynarmic/frontend/A64/translate/translate.h" #include "dynarmic/interface/A64/a64.h" #include "dynarmic/ir/basic_block.h" @@ -199,8 +199,9 @@ public: return is_executing; } - std::string Disassemble() const { - return Common::DisassembleX64(block_of_code.GetCodeBegin(), block_of_code.getCurr()); + void DumpDisassembly() const { + const size_t size = (const char*)block_of_code.getCurr() - (const char*)block_of_code.GetCodeBegin(); + Common::DumpDisassembledX64(block_of_code.GetCodeBegin(), size); } private: @@ -397,8 +398,8 @@ bool Jit::IsExecuting() const { return impl->IsExecuting(); } -std::string Jit::Disassemble() const { - return impl->Disassemble(); +void Jit::DumpDisassembly() const { + return impl->DumpDisassembly(); } } // namespace Dynarmic::A64 diff --git a/src/dynarmic/common/llvm_disassemble.cpp b/src/dynarmic/common/llvm_disassemble.cpp index ef02d601..614dff4f 100644 --- a/src/dynarmic/common/llvm_disassemble.cpp +++ b/src/dynarmic/common/llvm_disassemble.cpp @@ -13,6 +13,7 @@ #endif #include "dynarmic/common/assert.h" +#include "dynarmic/common/cast_util.h" #include "dynarmic/common/common_types.h" #include "dynarmic/common/llvm_disassemble.h" @@ -48,7 +49,7 @@ std::string DisassembleX64(const void* begin, const void* end) { LLVMDisasmDispose(llvm_ctx); #else result += fmt::format("(recompile with DYNARMIC_USE_LLVM=ON to disassemble the generated x86_64 code)\n"); - result += fmt::format("start: {:016x}, end: {:016x}\n", begin, end); + result += fmt::format("start: {:016x}, end: {:016x}\n", BitCast(begin), BitCast(end)); #endif return result; diff --git a/src/dynarmic/interface/A32/a32.h b/src/dynarmic/interface/A32/a32.h index 26d55539..99a823e5 100644 --- a/src/dynarmic/interface/A32/a32.h +++ b/src/dynarmic/interface/A32/a32.h @@ -88,11 +88,8 @@ public: return is_executing; } - /** - * Debugging: Disassemble all of compiled code. - * @return A string containing disassembly of all host machine code produced. - */ - std::string Disassemble() const; + /// Debugging: Dump a disassembly all compiled code to the console. + void DumpDisassembly() const; private: bool is_executing = false; diff --git a/src/dynarmic/interface/A64/a64.h b/src/dynarmic/interface/A64/a64.h index f098dcea..384ad239 100644 --- a/src/dynarmic/interface/A64/a64.h +++ b/src/dynarmic/interface/A64/a64.h @@ -114,11 +114,8 @@ public: */ bool IsExecuting() const; - /** - * Debugging: Disassemble all of compiled code. - * @return A string containing disassembly of all host machine code produced. - */ - std::string Disassemble() const; + /// Debugging: Dump a disassembly all of compiled code to the console. + void DumpDisassembly() const; private: struct Impl; diff --git a/tests/A32/fuzz_arm.cpp b/tests/A32/fuzz_arm.cpp index c25eb9f8..1fd8fb52 100644 --- a/tests/A32/fuzz_arm.cpp +++ b/tests/A32/fuzz_arm.cpp @@ -372,7 +372,7 @@ static void RunTestInstance(Dynarmic::A32::Jit& jit, fmt::print("\n"); fmt::print("x86_64:\n"); - fmt::print("{}\n", jit.Disassemble()); + jit.DumpDisassembly(); fmt::print("Interrupts:\n"); for (const auto& i : uni_env.interrupts) { diff --git a/tests/A32/fuzz_thumb.cpp b/tests/A32/fuzz_thumb.cpp index 85094c79..6638d16f 100644 --- a/tests/A32/fuzz_thumb.cpp +++ b/tests/A32/fuzz_thumb.cpp @@ -183,7 +183,8 @@ static void RunInstance(size_t run_number, ThumbTestEnv& test_env, A32Unicorn