mirror of
https://github.com/RKX1209/nsemu.git
synced 2024-05-11 00:55:24 -04:00
Add Deep Trace option that trace all registers
This commit is contained in:
parent
dcefef20ac
commit
b95e1b66ec
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
3
Cpu.cpp
3
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
11
Main.cpp
11
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] <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();
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ void RunLoop();
|
|||
|
||||
void Dump();
|
||||
|
||||
void DumpJson(FILE *fp);
|
||||
void DumpJson(FILE *fp, bool deep);
|
||||
|
||||
uint64_t GetTls();
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ State GetState();
|
|||
void DumpMachine();
|
||||
|
||||
extern FILE *TraceOut;
|
||||
extern bool DeepTrace;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue