DebugWaitFor dbgClearBreakPoint(char *line, processPo p, termPo loc, insWord ins, void *cl) { BreakPoint bp; retCode ret = parseBreakPoint(line, uniStrLen(line), &bp); if (ret == Ok) ret = clearBreakPoint(&bp); if (ret != Ok) outMsg(debugOutChnnl, "Could not clear spy point on %s\n%_", line); else outMsg(debugOutChnnl, "spy point cleared on %s\n%_", line); return moreDebug; }
void Debugger::debugConsole(std::uint16_t address) { std::cout << "Debugger [" << pc_<< "]> "; std::string command; std::getline( std::cin, command); std::vector<std::string> command_list = split(command, ' '); if(command_list.front() == "help") { printHelp(); } else if (command_list.front() == "c") { continueExec(); return; } else if (command_list.front() == "pr") { printRegisters(); } else if (command_list.front() == "pm") { uint16_t addr = (command_list.size() == 2)? atoi(command_list[1].c_str()) : pc_; printMemory(addr); } else if (command_list.front() == "ps") { std::cout << "--Stack--" << std::endl; printStack(stack_); } else if (command_list.front() == "disa") { uint16_t addr = (command_list.size() == 2)? atoi(command_list[1].c_str()) : pc_; printCodeBlockAt(addr); } else if(command_list.front() == "br") { uint16_t addr = (command_list.size() == 2)? atoi(command_list[1].c_str()) : pc_; setBreakPoint(addr); } else if(command_list.front() == "cbr") { uint16_t addr = (command_list.size() == 2)? atoi(command_list[1].c_str()) : pc_; clearBreakPoint(addr); } else if(command_list.front() == "setr") { setRegester(atoi(command_list[1].c_str()), atoi(command_list[2].c_str())); } else if(command_list.front() == "setm") { setMemeory(atoi(command_list[1].c_str()), atoi(command_list[2].c_str())); } else if(command_list.front() == "push") { stack_.push(atoi(command_list[1].c_str())); } else if(command_list.front() == "pop") { stack_.pop(); } else if (command_list.front() == "s") { return; } else { std::cout << "Unknowen command type 'help' for list of comamnds" << std::endl; } debugConsole(pc_); return; }
static logical shouldWeStopIns(processPo p, insWord ins) { if (focus == NULL || focus == p) { if (debugDebugging) { outMsg(logFile, "debug: traceDepth=%d, traceCount=%d, tracing=%s, ins: ", p->traceDepth, p->traceCount, (p->tracing ? "yes" : "no")); disass(logFile, p, p->prog, p->pc, p->fp, p->sp); outMsg(logFile, "\n%_"); } switch (p->waitFor) { case stepInto: if (p->traceCount > 0) p->traceCount--; return (logical) (p->traceCount == 0); case stepOver: case nextBreak: break; default: return False; } switch (ins) { case Ret: { switch (p->waitFor) { case stepOver: if (p->traceDepth > 0) p->traceDepth--; return (logical) (p->traceDepth == 0 && p->traceCount == 0); default: return False; } } case Call: case OCall: { switch (p->waitFor) { case stepOver: p->traceDepth++; return (logical) (p->traceCount == 0 && p->traceDepth == 1); default: return False; } } case Tail: case OTail: switch (p->waitFor) { case stepOver: return (logical) (p->traceDepth == 0 && p->traceCount == 0); default: return False; } case dLine: { termPo loc = findPcLocation(p->prog, insOffset(p->prog, p->pc)); breakPointPo bp = lineBreakPointHit(C_TERM(loc)); if (bp != Null) { p->waitFor = stepInto; p->tracing = True; p->traceDepth = p->traceCount = 0; if (isTempBreakPoint(bp)) clearBreakPoint(bp); return True; } else return False; } default: return False; } } else return False; }