void PIC::runCode() { int pc=getPC(); //CodeModel* codeModel=this->parent()->findChild<CodeModel *>(QString("codeModel")); while( pc< m_CmdList.size() && (!stop || singleStep) /* && codeModel->code[codeModel->findPCIdx(pc)][0].isEmpty()*/) { decodeCmd(pc); pc=getPC(); if(singleStep==true) qDebug()<<"---------------------------------------------------------------------------Single Step"; singleStep=false; int zeile=codeModel->findPCIdx(pc); if(!codeModel->code[zeile][0].isEmpty()) { qDebug() << "Breakpoint bei Programmzeile : "<<pc; stop=true; emit breakPoint(); } } }
void asys::CallInfo::updateBreakPoint(Machine* machine, int callIndex) { auto pFunRuntime = &machine->m_funRuntimes[callIndex]; const auto& instructions = pFunRuntime->m_pFunction->m_instructions; if (pFunRuntime->m_curIp >= static_cast<int>(instructions.size())) { m_pCurBreakpoint = nullptr; } else { auto instruction = instructions[pFunRuntime->m_curIp]; m_pCurBreakpoint = &instruction->breakPoint(); } }
void breakUnitigs(UnitigVector &unitigs, char *output_prefix, bool enableIntersectionBreaking) { writeLog("==> BREAKING UNITIGS.\n"); intersectionList *ilist = new intersectionList(unitigs); // Stop when we've seen all current unitigs. Replace tiMax // in the for loop below with unitigs.size() to recursively // split unitigs. uint32 tiMax = unitigs.size(); for (uint32 ti=0; ti<tiMax; ti++) { Unitig *tig = unitigs[ti]; if (tig == NULL) continue; vector<breakPoint> breaks; for (uint32 fi=0; fi<tig->ufpath.size(); fi++) { ufNode *frg = &tig->ufpath[fi]; intersectionPoint *isect = ilist->getIntersection(frg->ident, 0); if (isect == NULL) continue; for (; isect->isectFrg == frg->ident; isect++) { assert(tig->id() == Unitig::fragIn(isect->isectFrg)); // Grab the invading unitig Unitig *inv = unitigs[Unitig::fragIn(isect->invadFrg)]; assert(inv->id() == Unitig::fragIn(isect->invadFrg)); // Grab the best edges off the invading fragment. BestEdgeOverlap *best5 = OG->getBestEdgeOverlap(isect->invadFrg, false); BestEdgeOverlap *best3 = OG->getBestEdgeOverlap(isect->invadFrg, true); // Check if the incoming tig is a spur, and we should just ignore it immediately if ((inv->ufpath.size() == 1) && ((best5->fragId() == 0) || (best3->fragId() == 0))) { if (logFileFlagSet(LOG_INTERSECTION_BREAKING)) writeLog("unitig %d frag %d end %c' into unitig %d frag %d end %c' -- IS A SPUR, skip it\n", inv->id(), isect->invadFrg, isect->invad3p ? '3' : '5', tig->id(), isect->isectFrg, isect->isect3p ? '3' : '5'); continue; } // Keep only significant intersections if ((inv->getLength() > MIN_BREAK_LENGTH) && (inv->ufpath.size() > MIN_BREAK_FRAGS)) { if (logFileFlagSet(LOG_INTERSECTION_BREAKING)) writeLog("unitig %d frag %d end %c' into unitig %d frag %d end %c'\n", inv->id(), isect->invadFrg, isect->invad3p ? '3' : '5', tig->id(), isect->isectFrg, isect->isect3p ? '3' : '5'); breaks.push_back(breakPoint(isect->isectFrg, isect->isect3p, true, false)); } } // Over all incoming fragments // If this is the last fragment, terminate the break point list with a 'fakeEnd' (in AS_BAT_Breaking.cc) break point // at the end of the unitig. if ((fi+1 == tig->ufpath.size()) && (breaks.size() > 0)) { breaks.push_back(breakPoint(frg->ident, (frg->position.bgn < frg->position.end), true, false)); } } // Over all fragments in the unitig if (breaks.size() == 0) continue; // Report where breaks occur. 'breaks' is a list, not a vector. #if 0 // We've lost the fields in breaks[i] -- but the reports above aren't updated yet. if (logFileFlagSet(LOG_INTERSECTION_BREAKING) || logFileFlagSet(LOG_MATE_SPLIT_COVERAGE_PLOT)) for (uint32 i=0; i<breaks.size(); i++) writeLog("BREAK unitig %d at position %d,%d from inSize %d inFrags %d.\n", tig->id(), breaks[i].fragPos.bgn, breaks[i].fragPos.end, breaks[i].inSize, breaks[i].inFrags); #endif // Actually do the breaking. if (enableIntersectionBreaking) breakUnitigAt(unitigs, tig, breaks, true); breaks.clear(); } // Over all unitigs }
void CtrlDisAsmView::paintEvent(QPaintEvent *) { QPainter painter(this); painter.setBrush(Qt::white); painter.setPen(Qt::white); painter.drawRect(rect()); struct branch { int src,dst,srcAddr; bool conditional; }; branch branches[256]; int numBranches=0; int width = rect().width(); int numRows=(rect().height()/rowHeight); QColor bgColor(0xFFFFFFFF); QPen nullPen(bgColor); QPen currentPen(QColor(0,0,0)); QPen selPen(QColor(0xFF808080)); QPen condPen(QColor(0xFFFF3020)); QBrush lbr; lbr.setColor(bgColor); QBrush currentBrush(QColor(0xFFFFEfE8)); QBrush pcBrush(QColor(0xFF70FF70)); QFont normalFont("Arial", 10); QFont boldFont("Arial", 10); QFont alignedFont("Monospace", 10); alignedFont.setStyleHint(QFont::Monospace); boldFont.setBold(true); painter.setFont(normalFont); QImage breakPoint(":/resources/breakpoint.ico"); int i; curAddress&=~(align-1); align=(debugger->getInstructionSize(0)); for (i=0; i<=numRows; i++) { unsigned int address=curAddress + (i-(numRows/2))*align; int rowY1 = rect().top() + rowHeight*i; int rowY2 = rect().top() + rowHeight*i + rowHeight - 1; lbr.setColor((unsigned int)marker == address ? QColor(0xFFFFEEE0) : QColor(debugger->getColor(address))); QColor bg = lbr.color(); painter.setBrush(currentBrush); painter.setPen(nullPen); painter.drawRect(0,rowY1,16-1,rowY2-rowY1); if (selecting && address == (unsigned int)selection) painter.setPen(selPen); else { if(i==numRows/2) painter.setPen(currentPen); else painter.setPen(bg); } painter.setBrush(QBrush(bg)); if (address == debugger->getPC()) { painter.setBrush(pcBrush); } painter.drawRect(16,rowY1,width-16-1,rowY2-rowY1); painter.setBrush(currentBrush); QPen textPen(QColor(halfAndHalf(bg.rgba(),0))); painter.setPen(textPen); painter.setFont(alignedFont); painter.drawText(17,rowY1-3+rowHeight,QString("%1").arg(address,8,16,QChar('0'))); painter.setFont(normalFont); textPen.setColor(QColor(0xFF000000)); painter.setPen(textPen); if (debugger->isAlive()) { const char *dizz = debugger->disasm(address, align); char dis[512]; strcpy(dis, dizz); char *dis2 = strchr(dis,'\t'); char desc[256]=""; if (dis2) { *dis2=0; dis2++; const char *mojs=strstr(dis2,"->$"); if (mojs) { for (int i=0; i<8; i++) { bool found=false; for (int j=0; j<22; j++) { if (mojs[i+3]=="0123456789ABCDEFabcdef"[j]) found=true; } if (!found) { mojs=0; break; } } } if (mojs) { int offs; sscanf(mojs+3,"%08x",&offs); branches[numBranches].src=rowY1 + rowHeight/2; branches[numBranches].srcAddr=address/align; branches[numBranches].dst=(int)(rowY1+((s64)offs-(s64)address)*rowHeight/align + rowHeight/2); branches[numBranches].conditional = (dis[1]!=0); //unconditional 'b' branch numBranches++; const char *t = debugger->getDescription(offs).c_str(); if (memcmp(t,"z_",2)==0) t+=2; if (memcmp(t,"zz_",3)==0) t+=3; sprintf(desc,"-->%s", t); textPen.setColor(QColor(0xFF600060)); painter.setPen(textPen); } else { textPen.setColor(QColor(0xFF000000)); painter.setPen(textPen); } painter.drawText(149,rowY1-3+rowHeight,QString(dis2)); } textPen.setColor(QColor(0xFF007000)); painter.setPen(textPen); painter.setFont(boldFont); painter.drawText(84,rowY1-3+rowHeight,QString(dis)); painter.setFont(normalFont); if (desc[0]==0) { const char *t = debugger->getDescription(address).c_str(); if (memcmp(t,"z_",2)==0) t+=2; if (memcmp(t,"zz_",3)==0) t+=3; strcpy(desc,t); } if (memcmp(desc,"-->",3) == 0) { textPen.setColor(QColor(0xFF0000FF)); painter.setPen(textPen); } else { textPen.setColor(halfAndHalf(halfAndHalf(bg.rgba(),0),bg.rgba())); painter.setPen(textPen); } if (strlen(desc)) painter.drawText(std::max(280,width/3+190),rowY1-3+rowHeight,QString(desc)); if (debugger->isBreakpoint(address)) { painter.drawImage(2,rowY1+2,breakPoint); } } } for (i=0; i<numBranches; i++) { painter.setPen(branches[i].conditional ? condPen : currentPen); int x=280+(branches[i].srcAddr%9)*8; QPoint curPos(x-2,branches[i].src); if (branches[i].dst<rect().bottom()+200 && branches[i].dst>-200) { painter.drawLine(curPos, QPoint(x+2,branches[i].src)); curPos = QPoint(x+2,branches[i].src); painter.drawLine(curPos, QPoint(x+2,branches[i].dst)); curPos = QPoint(x+2,branches[i].dst); painter.drawLine(curPos, QPoint(x-4,branches[i].dst)); curPos = QPoint(x,branches[i].dst-4); painter.drawLine(curPos, QPoint(x-4,branches[i].dst)); curPos = QPoint(x-4,branches[i].dst); painter.drawLine(curPos, QPoint(x+1,branches[i].dst+5)); } else { painter.drawLine(curPos, QPoint(x+4,branches[i].src)); } } }
void DisView::OnPaint(wxPaintEvent &evt) { wxPaintDC dc(this); // Initialize tools wxBrush infoBrush(wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_INACTIVECAPTION), wxBRUSHSTYLE_SOLID); wxBrush arrowBrush(wxColour(0xF7, 0xEA, 0x59)); wxBrush breakBrush(wxColour(0xFC, 0x0D, 0x00)); wxFont infoFont(wxSystemSettings::GetFont(wxSystemFont::wxSYS_SYSTEM_FONT)); wxFont codeFont(wxSystemSettings::GetFont(wxSystemFont::wxSYS_ANSI_FIXED_FONT)); wxPen transparentPen(wxColour(), 0, wxPenStyle::wxPENSTYLE_TRANSPARENT); wxPen infoTextPen(wxSystemSettings::GetColour(wxSystemColour::wxSYS_COLOUR_INFOTEXT)); wxPen codeTextPen = infoTextPen; dc.SetFont(infoFont); dc.SetPen(infoTextPen); // Initialize sizes wxRect clientRect(dc.GetSize()); wxRect codeRect = clientRect; wxPoint infoCorner(20, dc.GetCharHeight() + 10); wxRect addressLabelRect(infoCorner.x, 0, 0, infoCorner.y); wxRect rawLabelRect = addressLabelRect; wxRect instrLabelRect = rawLabelRect; codeRect.SetTopLeft(infoCorner); addressLabelRect.SetWidth(dc.GetFontMetrics().averageWidth*16); rawLabelRect.Offset(addressLabelRect.GetWidth(), 0); rawLabelRect.SetWidth(dc.GetFontMetrics().averageWidth * 18); instrLabelRect.SetLeft(rawLabelRect.GetRight()); instrLabelRect.SetRight(codeRect.GetRight()); wxRect addressRect = addressLabelRect; wxRect rawRect = rawLabelRect; wxRect instrRect = instrLabelRect; addressRect.Offset(0, addressLabelRect.GetHeight()); rawRect.Offset(0, rawRect.GetHeight()); instrRect.Offset(0, instrRect.GetHeight()); dc.SetFont(codeFont); _startingY = infoCorner.y; _lineHeight = dc.GetCharHeight(); addressRect.SetHeight(_lineHeight); rawRect.SetHeight(_lineHeight); instrRect.SetHeight(_lineHeight); // Clear background //ClearBackground(); // Paint info bars dc.SetBrush(infoBrush); dc.SetFont(infoFont); dc.SetPen(transparentPen); dc.DrawRectangle(0,0, dc.GetSize().GetWidth(), infoCorner.y); dc.DrawRectangle(0, infoCorner.y, infoCorner.x, clientRect.GetHeight()-infoCorner.y); dc.SetPen(infoTextPen); wxPoint labelVertCenterOffset(0,(addressLabelRect.GetHeight() - dc.GetCharHeight())/2); dc.DrawText(_("Address:"), addressLabelRect.GetLeftTop() + labelVertCenterOffset); dc.DrawText(_("Raw:"), rawLabelRect.GetLeftTop() + labelVertCenterOffset); dc.DrawText(_("Instruction:"), instrLabelRect.GetLeftTop() + labelVertCenterOffset); // Paint code section dc.SetFont(codeFont); dc.SetPen(codeTextPen); if (_emu->emu != NULL && _numberOfLines > 0) { unsigned int address = _startingLine; while (addressRect.GetBottom() < codeRect.GetBottom()) { // Draw a line const char *raw; const char *instr; char size = _emu->emu->Disassemble(_emu->handle, address, &raw, &instr); if (address == _currentLine) // Draw currentLine icon { dc.SetBrush(arrowBrush); dc.SetPen(transparentPen); wxPoint arrowPoint(0, addressRect.GetTop()+2); dc.DrawRoundedRectangle(arrowPoint, wxSize(infoCorner.x, _lineHeight-4), 3); dc.DrawRectangle(addressRect); dc.DrawRectangle(rawRect); dc.DrawRectangle(instrRect); dc.SetPen(codeTextPen); } if (_emu->emu->IsBreakpoint(_emu->handle, address)) { // Breakpoint wxPoint breakPoint(infoCorner.x / 2, addressRect.GetTop() + _lineHeight / 2); dc.SetBrush(breakBrush); dc.SetPen(transparentPen); dc.DrawCircle(breakPoint, _lineHeight / 2); dc.SetPen(codeTextPen); } dc.DrawText(wxString::Format("0x%08X", address), addressRect.GetLeftTop()); dc.DrawText(raw, rawRect.GetLeftTop()); dc.DrawText(instr, instrRect.GetLeftTop()); address += size; address %= _numberOfLines; addressRect.Offset(0, addressRect.GetHeight()); rawRect.Offset(0, rawRect.GetHeight()); instrRect.Offset(0, instrRect.GetHeight()); } _endingLine = address; } else { // Draw no emulator loaded text wxPoint centerCode(codeRect.GetBottomLeft()); centerCode.y -= codeRect.GetHeight()/2; dc.DrawText(_("There is no emulator loaded"),centerCode); } }