Skip to content

Commit

Permalink
Debugger: Fixed elapsed cycle counter sometimes giving an incorrect v…
Browse files Browse the repository at this point in the history
…alue when "refresh while running" is enabled
  • Loading branch information
SourMesen committed Jun 18, 2024
1 parent 8270b57 commit b3e4bc8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions UI/Debugger/StatusViews/BaseConsoleStatusViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public abstract class BaseConsoleStatusViewModel : ViewModelBase
private bool _isUpdatingUi = false;
private bool _needUpdate = false;

private UInt64 _lastBreakCycleCount = 0;
private bool _isRunning = false;

public BaseConsoleStatusViewModel()
{
PropertyChanged += BaseConsoleStatusViewModel_PropertyChanged;
Expand All @@ -34,19 +37,29 @@ private void BaseConsoleStatusViewModel_PropertyChanged(object? sender, Property

public void UpdateCycleCount(UInt64 newCycleCount)
{
if(newCycleCount > CycleCount) {
ElapsedCycles = newCycleCount - CycleCount;
CycleCount = newCycleCount;

if(_isRunning) {
//Don't reset elapsed value if refresh done because "refresh while running" is enabled
return;
}

if(newCycleCount > _lastBreakCycleCount) {
ElapsedCycles = newCycleCount - _lastBreakCycleCount;
} else {
ElapsedCycles = 0;
}
CycleCount = newCycleCount;

_lastBreakCycleCount = newCycleCount;
}

public void UpdateUiState()
public void UpdateUiState(bool isRunning = false)
{
_isUpdatingUi = true;
_needUpdate = false;
_isRunning = isRunning;
InternalUpdateUiState();
_isRunning = false;
_isUpdatingUi = false;
_needUpdate = false;
}
Expand Down
2 changes: 1 addition & 1 deletion UI/Debugger/ViewModels/DebuggerWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public void UpdateDebugger(bool forBreak = false, BreakEvent? evt = null)

public void PartialRefresh(bool refreshWatch)
{
ConsoleStatus?.UpdateUiState();
ConsoleStatus?.UpdateUiState(true);
MemoryMappings?.Refresh();
if(refreshWatch) {
WatchList.UpdateWatch();
Expand Down

0 comments on commit b3e4bc8

Please sign in to comment.