Add estimate counter for debug

This commit is contained in:
rkx1209 2018-03-17 23:18:35 +09:00
parent ecce10b623
commit bfbd53300d
3 changed files with 13 additions and 18 deletions

View file

@ -18,21 +18,21 @@ void RunLoop() {
void Dump() {
int cnt = 1;
ns_print ("CPU Dump:\n");
debug_print ("CPU Dump:\n");
for (int r = 0; r < GPR_DUMMY; r++) {
if (!X(r))
continue;
if (r == GPR_LR)
ns_print ("LR:\t");
debug_print ("LR:\t");
else if (r == GPR_SP)
ns_print ("SP:\t");
debug_print ("SP:\t");
else
ns_print ("X%d:\t", r);
ns_print ("0x%016lx%c", X(r), cnt % 3 == 0 ? '\n' : '\t');
debug_print ("X%d:\t", r);
debug_print ("0x%016lx%c", X(r), cnt % 3 == 0 ? '\n' : '\t');
cnt++;
}
ns_print ("PC:\t0x%016lx\n", PC);
ns_print ("NZCV:\t0x%016lx\n", NZCV);
debug_print ("PC:\t0x%016lx\n", PC);
debug_print ("NZCV:\t0x%016lx\n", NZCV);
}
static uint64_t counter;

View file

@ -17,21 +17,16 @@ int Interpreter::SingleStep() {
void Interpreter::Run() {
debug_print ("Running with Interpreter\n");
static uint64_t counter = 0;
uint64_t estimate = 3400000;
while (Cpu::GetState () == Cpu::State::Running) {
char c;
//scanf("%c", &c);
if (counter >= estimate) {
Cpu::DumpMachine ();
}
SingleStep ();
if (counter >= 241)
break;
counter++;
// if (PC == 0x2d54) {
// SingleStep ();
// Cpu::DumpMachine ();
// debug_print("Reach\n");
// break;
// }
}
Cpu::DumpMachine ();
}
/* ####### Callbacks ####### */

View file

@ -13,8 +13,8 @@ enum RunLevel {
RUN_LEVEL_DEBUG,
};
//static RunLevel curlevel = RUN_LEVEL_DEBUG;
static RunLevel curlevel = RUN_LEVEL_RELEASE;
static RunLevel curlevel = RUN_LEVEL_DEBUG;
//static RunLevel curlevel = RUN_LEVEL_RELEASE;
static void util_print(RunLevel level, FILE *fp, const char *format, ...) {
if (curlevel >= level) {