Add Deep Trace option that trace all registers

This commit is contained in:
rkx1209 2018-06-08 03:29:49 +09:00
parent dcefef20ac
commit b95e1b66ec
6 changed files with 19 additions and 8 deletions

View file

@ -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");
}

View file

@ -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) {

View file

@ -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);
}
}

View file

@ -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] <nso-binary>\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();
}

View file

@ -87,7 +87,7 @@ void RunLoop();
void Dump();
void DumpJson(FILE *fp);
void DumpJson(FILE *fp, bool deep);
uint64_t GetTls();

View file

@ -21,6 +21,7 @@ State GetState();
void DumpMachine();
extern FILE *TraceOut;
extern bool DeepTrace;
}
#endif