-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Internal Debugger: All breakpoints can be created (including I/O ports breakpoints) + QoL improvements #998
Draft
maximilien-noal
wants to merge
12
commits into
master
Choose a base branch
from
feature/debugger_features
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b1ada26
refactor: Remove unused ctor parameter
maximilien-noal cc7b0b5
feat: Stack Memory tab
maximilien-noal b17c160
refactor: Use UIDispatcher as a precaution
maximilien-noal 734bf0c
refactor: UI methods are public for users
maximilien-noal 9b516aa
refactor: Status bar collapses after 5 secs
maximilien-noal bebd5e2
Basic breakpoint form creation UI
maximilien-noal 7eafe82
feature: debugger address userControl
maximilien-noal cc17ea1
feature: All breakpoints type creation UI
maximilien-noal c94a97e
fix: AddressAutoCompleteBox bindings
maximilien-noal 6cc44cf
refactor: Finishing touches of debugger UI improvements
maximilien-noal de3f910
feat: hexadecimal textbox and messages
maximilien-noal c53e03f
WIP, reworking all addresses textboxes...
maximilien-noal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,50 +2,59 @@ | |
|
||
using CommunityToolkit.Mvvm.ComponentModel; | ||
|
||
using Spice86.Core.Emulator.VM; | ||
using Spice86.Core.Emulator.VM.Breakpoint; | ||
using Spice86.Models.Debugging; | ||
|
||
public partial class BreakpointViewModel : ViewModelBase { | ||
public partial class BreakpointViewModel : ViewModelBase | ||
{ | ||
private readonly Action _onReached; | ||
private readonly EmulatorBreakpointsManager _emulatorBreakpointsManager; | ||
private AddressBreakPoint? _breakPoint; | ||
private BreakPoint? _breakPoint; | ||
|
||
public BreakpointViewModel( | ||
BreakpointsViewModel breakpointsViewModel, | ||
EmulatorBreakpointsManager emulatorBreakpointsManager, | ||
uint address, | ||
BreakPointType type, | ||
bool isRemovedOnTrigger, | ||
Action onReached, | ||
string comment = "") { | ||
long addressOrIoPortOrCyclesOrInterruptNumber, | ||
BreakPointType type, | ||
bool isRemovedOnTrigger, | ||
Action onReached, | ||
string comment = "") | ||
{ | ||
_emulatorBreakpointsManager = emulatorBreakpointsManager; | ||
Address = address; | ||
Address = addressOrIoPortOrCyclesOrInterruptNumber; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe |
||
Type = type; | ||
IsRemovedOnTrigger = isRemovedOnTrigger; | ||
if(IsRemovedOnTrigger) { | ||
_onReached = () => { | ||
if (IsRemovedOnTrigger) | ||
{ | ||
_onReached = () => | ||
{ | ||
breakpointsViewModel.RemoveBreakpointInternal(this); | ||
onReached(); | ||
}; | ||
} else { | ||
} | ||
else | ||
{ | ||
_onReached = onReached; | ||
} | ||
Check notice Code scanning / CodeQL Missed ternary opportunity Note
Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.
|
||
Comment = comment; | ||
Enable(); | ||
} | ||
|
||
public BreakPointType Type { get; } | ||
|
||
//Can't get out of sync since GDB can't be used at the same time as the internal debugger | ||
private bool _isEnabled; | ||
|
||
public bool IsEnabled { | ||
public bool IsEnabled | ||
{ | ||
get => _isEnabled; | ||
set { | ||
if (value) { | ||
set | ||
{ | ||
if (value) | ||
{ | ||
Enable(); | ||
} else { | ||
} | ||
else | ||
{ | ||
Disable(); | ||
} | ||
SetProperty(ref _isEnabled, value); | ||
|
@@ -54,48 +63,60 @@ | |
|
||
public bool IsRemovedOnTrigger { get; } | ||
|
||
public uint Address { get; } | ||
public long Address { get; } | ||
|
||
public void Toggle() { | ||
if (IsEnabled) { | ||
public void Toggle() | ||
{ | ||
if (IsEnabled) | ||
{ | ||
Disable(); | ||
} else { | ||
} | ||
else | ||
{ | ||
Enable(); | ||
} | ||
} | ||
|
||
[ObservableProperty] | ||
private string? _comment; | ||
|
||
private AddressBreakPoint GetOrCreateBreakpoint() { | ||
_breakPoint ??= | ||
new AddressBreakPoint( | ||
Type, | ||
Address, | ||
(_) => _onReached(), | ||
private BreakPoint GetOrCreateBreakpoint() { | ||
_breakPoint ??= new AddressBreakPoint(Type, | ||
Address, (_) => _onReached(), | ||
IsRemovedOnTrigger); | ||
return _breakPoint; | ||
} | ||
|
||
public void Enable() { | ||
if (IsEnabled) { | ||
public void Enable() | ||
{ | ||
if (IsEnabled) | ||
{ | ||
return; | ||
} | ||
_emulatorBreakpointsManager.ToggleBreakPoint(GetOrCreateBreakpoint(), on: true); | ||
_emulatorBreakpointsManager.ToggleBreakPoint(GetOrCreateBreakpoint(), | ||
on: true); | ||
_isEnabled = true; | ||
OnPropertyChanged(nameof(IsEnabled)); | ||
} | ||
|
||
public void Disable() { | ||
if (!IsEnabled) { | ||
public void Disable() | ||
{ | ||
if (!IsEnabled) | ||
{ | ||
return; | ||
} | ||
_emulatorBreakpointsManager.ToggleBreakPoint(GetOrCreateBreakpoint(), on: false); | ||
_emulatorBreakpointsManager.ToggleBreakPoint(GetOrCreateBreakpoint(), | ||
on: false); | ||
_isEnabled = false; | ||
OnPropertyChanged(nameof(IsEnabled)); | ||
} | ||
|
||
internal bool IsFor(CpuInstructionInfo instructionInfo) { | ||
return Address == instructionInfo.Address; | ||
internal bool IsFor(CpuInstructionInfo instructionInfo) | ||
{ | ||
return Address == instructionInfo.Address && | ||
(Type == BreakPointType.CPU_EXECUTION_ADDRESS || | ||
Type == BreakPointType.MEMORY_READ || | ||
Type == BreakPointType.MEMORY_WRITE || | ||
Type == BreakPointType.MEMORY_ACCESS); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do?