From b95e1b66ece14a678102c626ad225568e8c56cab Mon Sep 17 00:00:00 2001 From: rkx1209 Date: Fri, 8 Jun 2018 03:29:49 +0900 Subject: [PATCH] Add Deep Trace option that trace all registers --- ARMv8/ARMv8.cpp | 8 +++++++- ARMv8/Interpreter.cpp | 2 +- Cpu.cpp | 3 ++- Main.cpp | 11 +++++++---- include/ARMv8/ARMv8.hpp | 2 +- include/Cpu.hpp | 1 + 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ARMv8/ARMv8.cpp b/ARMv8/ARMv8.cpp index 107eded..28d9eb3 100644 --- a/ARMv8/ARMv8.cpp +++ b/ARMv8/ARMv8.cpp @@ -44,13 +44,19 @@ void Dump() { } static uint64_t counter; -void DumpJson(FILE *fp) { +void DumpJson(FILE *fp, bool deep) { file_print (fp, "%lu : {\n", counter++); int r; for (r = 0; r <= PC_IDX; r++) { file_print (fp, "\"X%d\" : \"0x%016lx\",\n", r, X(r)); } file_print (fp, "\"X%d\" : \"0x%016x\"\n", r, NZCV); + if (deep) { + /* Dump Vector regs */ + for (r = 0; r < VREG_DUMMY; r++) { + file_print (fp, "\"V%d\" : \"0x%016lx%016lx\",\n", r, VREG(r).d[1], VREG(r).d[0]); + } + } file_print (fp, "},\n"); } diff --git a/ARMv8/Interpreter.cpp b/ARMv8/Interpreter.cpp index 15f7051..50aa25d 100644 --- a/ARMv8/Interpreter.cpp +++ b/ARMv8/Interpreter.cpp @@ -20,7 +20,7 @@ int Interpreter::SingleStep() { void Interpreter::Run() { debug_print ("Running with Interpreter\n"); static uint64_t counter = 0; - uint64_t estimate = 3500000, mx = 15000; + uint64_t estimate = 3500000, mx = 20000; //uint64_t estimate = 0, mx = 100000; while (Cpu::GetState () == Cpu::State::Running) { if (GdbStub::enabled) { diff --git a/Cpu.cpp b/Cpu.cpp index ecac5f2..f6935e1 100644 --- a/Cpu.cpp +++ b/Cpu.cpp @@ -4,6 +4,7 @@ namespace Cpu { static State state = State::PowerDown; FILE *TraceOut; +bool DeepTrace; void Init() { ARMv8::Init (); @@ -34,7 +35,7 @@ void DumpMachine() { ARMv8::Dump (); } if (TraceOut) - ARMv8::DumpJson (TraceOut); + ARMv8::DumpJson (TraceOut, DeepTrace); } } diff --git a/Main.cpp b/Main.cpp index a81ecee..2efab80 100644 --- a/Main.cpp +++ b/Main.cpp @@ -77,14 +77,15 @@ void Banner() { } enum optionIndex { - UNKNOWN, HELP, ENABLE_TRACE, ENABLE_GDB, ENABLE_DEBUG, + UNKNOWN, HELP, ENABLE_TRACE, ENABLE_DEEP, ENABLE_GDB, ENABLE_DEBUG, }; const option::Descriptor usage[] = { { UNKNOWN, 0, "", "", Arg::None, "USAGE: nsemu [options] \n\n" "Options:" }, - { HELP, 0, "", "help", Arg::None, " --help \tPrint help message" }, + { HELP, 0, "h", "help", Arg::None, " --help \tPrint help message" }, { ENABLE_TRACE, 0, "t","enable-trace", Arg::None, " --enable-trace, -t \tEnable Trace" }, + { ENABLE_DEEP, 0, "","deep-trace", Arg::None, " --deep-trace, -t \tEnable Deep Trace" }, { ENABLE_GDB, 0, "s","enable-gdb", Arg::None, " --enable-gdb -s \tEnable GDBServer" }, { ENABLE_DEBUG, 0, "d","enable-debug", Arg::None, " --enable-debug -d \tEnable debug mode" }, { 0, 0, nullptr, nullptr, nullptr, nullptr } @@ -117,9 +118,11 @@ printUsage: option::printUsage (cout, usage); return 0; } - if (options[ENABLE_TRACE].count () > 0) { + bool deep = options[ENABLE_DEEP].count () > 0; + if (options[ENABLE_TRACE].count () > 0 || deep) { InitTrace ("nsemu_trace.json"); - } + Cpu::DeepTrace = deep; + } if (options[ENABLE_GDB].count () > 0) { GdbStub::Init(); } diff --git a/include/ARMv8/ARMv8.hpp b/include/ARMv8/ARMv8.hpp index c2345f3..4446492 100644 --- a/include/ARMv8/ARMv8.hpp +++ b/include/ARMv8/ARMv8.hpp @@ -87,7 +87,7 @@ void RunLoop(); void Dump(); -void DumpJson(FILE *fp); +void DumpJson(FILE *fp, bool deep); uint64_t GetTls(); diff --git a/include/Cpu.hpp b/include/Cpu.hpp index 302373b..bd0d9b0 100644 --- a/include/Cpu.hpp +++ b/include/Cpu.hpp @@ -21,6 +21,7 @@ State GetState(); void DumpMachine(); extern FILE *TraceOut; +extern bool DeepTrace; } #endif