diff --git a/tests/A64/fuzz_with_unicorn.cpp b/tests/A64/fuzz_with_unicorn.cpp index 3b122070..4f87d618 100644 --- a/tests/A64/fuzz_with_unicorn.cpp +++ b/tests/A64/fuzz_with_unicorn.cpp @@ -8,6 +8,7 @@ #include +#include "common/scope_exit.h" #include "frontend/A64/location_descriptor.h" #include "frontend/A64/translate/translate.h" #include "frontend/ir/basic_block.h" @@ -16,6 +17,14 @@ #include "testenv.h" #include "unicorn_emu/unicorn.h" +// Needs to be declaerd before +static std::ostream& operator<<(std::ostream& o, const Dynarmic::A64::Vector& vec) { + return o << fmt::format("{:016x}'{:016x}", vec[1], vec[0]); +} + +#include +#include + using namespace Dynarmic; static Vector RandomVector() { @@ -73,12 +82,12 @@ static void RunTestInstance(const std::array& regs, const std::array& regs, const std::array(i), regs[i]); + for (size_t i = 0; i < vecs.size(); ++i) + fmt::print("{:3s}: {}\n", static_cast(i), vecs[i]); + fmt::print("sp : 08000000\n"); + fmt::print("pc : {:016x}\n", instructions_offset * 4); + fmt::print("p : {:08x}\n", pstate); + fmt::print("\n"); + + fmt::print("Final register listing:\n"); + fmt::print(" unicorn dynarmic\n"); + for (size_t i = 0; i < regs.size(); ++i) + fmt::print("{:3s}: {:016x} {:016x} {}\n", static_cast(i), uni.GetRegisters()[i], jit.GetRegisters()[i], uni.GetRegisters()[i] != jit.GetRegisters()[i] ? "*" : ""); + for (size_t i = 0; i < vecs.size(); ++i) + fmt::print("{:3s}: {} {} {}\n", static_cast(i), uni.GetVectors()[i], jit.GetVectors()[i], uni.GetVectors()[i] != jit.GetVectors()[i] ? "*" : ""); + fmt::print("sp : {:016x} {:016x} {}\n", uni.GetSP(), jit.GetSP(), uni.GetSP() != jit.GetSP() ? "*" : ""); + fmt::print("pc : {:016x} {:016x} {}\n", uni.GetPC(), jit.GetPC(), uni.GetPC() != jit.GetPC() ? "*" : ""); + fmt::print("p : {:08x} {:08x} {}\n", uni.GetPstate(), jit.GetPstate(), (uni.GetPstate() & 0xF0000000) != (jit.GetPstate() & 0xF0000000) ? "*" : ""); + fmt::print("\n"); + + fmt::print("Modified memory:\n"); + fmt::print(" uni dyn\n"); + auto uni_iter = uni_env.modified_memory.begin(); + auto jit_iter = jit_env.modified_memory.begin(); + while (uni_iter != uni_env.modified_memory.end() || jit_iter != jit_env.modified_memory.end()) { + if (uni_iter == uni_env.modified_memory.end() || uni_iter->first > jit_iter->first) { + fmt::print("{:016x}: {:02x} *\n", jit_iter->first, jit_iter->second); + jit_iter++; + } else if (jit_iter == jit_env.modified_memory.end() || jit_iter->first > uni_iter->first) { + fmt::print("{:016x}: {:02x} *\n", uni_iter->first, uni_iter->second); + uni_iter++; + } else if (uni_iter->first == jit_iter->first) { + fmt::print("{:016x}: {:02x} {:02x} {}\n", uni_iter->first, uni_iter->second, jit_iter->second, uni_iter->second != jit_iter->second ? "*" : ""); + uni_iter++; + jit_iter++; + } + } + fmt::print("\n"); + + fmt::print("x86_64:\n"); + fmt::print("{}\n", jit.Disassemble()); + }; + REQUIRE(uni.GetPC() == jit.GetPC()); REQUIRE(uni.GetRegisters() == jit.GetRegisters()); REQUIRE(uni.GetVectors() == jit.GetVectors());