@@ -376,33 +376,40 @@ void Debugger::showBreakpoints(Font& font, const int lineSpacing)
376376 BeginTableView (area.height - (10 * 14 .0f + 6 ), 3 , &scroll);
377377 SetRowHeight (11 );
378378 int count = -1 ;
379+ bool foundTriggeredBP = false ;
379380 for (const auto & [address, bpinfo] : _breakpointCache) {
380381 auto execUnit = _core->executionUnit (bpinfo->unit );
381382 auto isChip8 = dynamic_cast <emu::IChip8Emulator*>(execUnit) != nullptr ;
382383 ++count;
383- if (bpinfo->isEnabled && _isBreakpointTriggered && execUnit->getPC () == address)
384- _selectedBreakpoint = count;
384+ // if (bpinfo->isEnabled && _triggeredBreakpointAddress == address && execUnit->getPC() == address)
385+ // _selectedBreakpoint = count;
385386 TableNextRow (11 .0f , count == _selectedBreakpoint ? StyleManager::getStyleColor (gui::Style::BORDER_COLOR_NORMAL): Color{0 ,0 ,0 ,0 });
386- TableNextColumn (16 , [&](Rectangle rect){
387+ TableNextColumn (24 , [&](Rectangle rect){
388+ GuiDrawIcon (address == _triggeredBreakpointAddress ? ICON_ARROW_RIGHT_FILL_SMALL : ICON_NONE, rect.x - 2 , rect.y - 3 , 1 , YELLOW);
389+ if (address == _triggeredBreakpointAddress && execUnit->getPC () == address)
390+ foundTriggeredBP = true ;
387391 if (!GuiIsLocked () && IsMouseButtonPressed (0 ) && CheckCollisionPointRec (GetMousePosition (), rect)) {
388392 bpinfo->isEnabled = !bpinfo->isEnabled ;
389- _selectedBreakpoint = count;
393+ selectBreakpoint ( count) ;
390394 }
391- GuiDrawIcon (bpinfo->isEnabled ? ICON_BREAKPOINT : ICON_BREAKPOINT_OFF, rect.x , rect.y - 3 , 1 , RED);
395+ GuiDrawIcon (bpinfo->isEnabled ? ICON_BREAKPOINT : ICON_BREAKPOINT_OFF, rect.x + 6 , rect.y - 3 , 1 , RED);
392396 });
393397 TableNextColumn (32 , [&](Rectangle rect){
394398 if (!GuiIsLocked () && IsMouseButtonPressed (0 ) && CheckCollisionPointRec (GetMousePosition (), rect)) {
395- _selectedBreakpoint = count;
399+ selectBreakpoint ( count) ;
396400 }
397401 DrawTextClipped (font, fmt::format (" {:04x}" , address).c_str (), {rect.x + 2 , rect.y + 2 }, WHITE);
398402 });
399403 TableNextColumn (area.width - 50 , [&](Rectangle rect){
400404 if (!GuiIsLocked () && IsMouseButtonPressed (0 ) && CheckCollisionPointRec (GetMousePosition (), rect)) {
401- _selectedBreakpoint = count;
405+ selectBreakpoint ( count) ;
402406 }
403407 DrawTextClipped (font, fmt::format (" {} breakpoint" , isChip8 ? " CHIP-8" : execUnit->name ()).c_str (), {rect.x + 2 , rect.y + 2 }, WHITE);
404408 });
405409 }
410+ if (!foundTriggeredBP) {
411+ setBreakpointTriggered (false );
412+ }
406413 EndTableView ();
407414 SetRowHeight (14 );
408415 if (_selectedBreakpoint >= 0 && _selectedBreakpoint < _breakpointCache.size ()) {
@@ -460,6 +467,17 @@ void Debugger::showBreakpoints(Font& font, const int lineSpacing)
460467 Space (GetContentAvailable ().height );
461468}
462469
470+ void Debugger::selectBreakpoint (int idx)
471+ {
472+ if (idx < 0 || idx >= _breakpointCache.size ()) {
473+ _selectedBreakpoint = -1 ;
474+ _bpHitCount = " " ;
475+ return ;
476+ }
477+ _selectedBreakpoint = idx;
478+ _bpHitCount = fmt::format (" {}" , _breakpointCache[idx].second ->numHits );
479+ }
480+
463481void Debugger::showGenericRegs (emu::GenericCpu& cpu, const RegPack& regs, const RegPack& oldRegs, Font& font, const int lineSpacing, const Vector2& pos) const
464482{
465483 using namespace gui ;
@@ -512,7 +530,7 @@ void Debugger::refreshBreakpoints()
512530 return a.first < b.first ;
513531 }
514532 );
515- _selectedBreakpoint = _breakpointCache.empty () ? -1 : 0 ;
533+ selectBreakpoint ( _breakpointCache.empty () ? -1 : 0 ) ;
516534}
517535
518536const std::vector<std::pair<uint32_t ,std::string>>& Debugger::disassembleNLinesBackwardsGeneric (emu::GenericCpu& cpu, uint32_t addr, int n)
@@ -544,6 +562,7 @@ void Debugger::toggleBreakpoint(emu::GenericCpu& cpu, uint32_t address)
544562 else {
545563 cpu.setBreakpoint (address, {.label = fmt::format (" BP@{:x}" , address), .type = emu::GenericCpu::BreakpointInfo::eTRANSIENT, .isEnabled = true , .unit = static_cast <uint8_t >(_activeInstructionsTab)});
546564 }
565+ selectBreakpoint (-1 );
547566 refreshBreakpoints ();
548567}
549568
@@ -568,10 +587,31 @@ void Debugger::updateOctoBreakpoints(const emu::OctoCompiler& compiler)
568587 }
569588 }
570589 }
590+ selectBreakpoint (-1 );
571591 refreshBreakpoints ();
572592}
573593
574594bool Debugger::supportsStepOver () const
575595{
576596 return _core->focussedExecutionUnit ()->cpuID () != 1802 ;
577597}
598+
599+ void Debugger::setBreakpointTriggered (bool triggered)
600+ {
601+ _isBreakpointTriggered = triggered;
602+ if (triggered) {
603+ int count = -1 ;
604+ for (const auto & [address, bpinfo] : _breakpointCache) {
605+ auto execUnit = _core->executionUnit (bpinfo->unit );
606+ auto isChip8 = dynamic_cast <emu::IChip8Emulator*>(execUnit) != nullptr ;
607+ ++count;
608+ if (bpinfo->isEnabled && execUnit->getPC () == address) {
609+ _triggeredBreakpointAddress = address;
610+ _selectedBreakpoint = count;
611+ }
612+ }
613+ }
614+ else {
615+ _triggeredBreakpointAddress = ~0 ;
616+ }
617+ }
0 commit comments