Skip to content

Commit

Permalink
PAUSE notification returns breakpoint address instead of breakpoint ID.
Browse files Browse the repository at this point in the history
Priorization of temp breakpoints increased.
  • Loading branch information
maziac committed Apr 24, 2020
1 parent 521e033 commit d82153f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## 0.7.0
- DZRP v0.2.0: PAUSE notification returns breakpoint address instead breakpoint ID.

## 0.6.0
- Getting sprites clip window fixed.
Expand Down
39 changes: 15 additions & 24 deletions Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,30 +196,21 @@ protected static void DebuggerStopped()
// Guess break reason
BreakReason reason = BreakReason.MANUAL_BREAK;
string reasonString = "";
int bpId = 0;
ushort bpAddress = 0;
var regs = cspect.GetRegs();
var pc = regs.PC;
if (BreakpointMap.ContainsValue(pc))
// First check for temporary breakpoints
if (pc == TmpBreakpoint1 || pc == TmpBreakpoint2)
{
// Breakpoint hit
reason = BreakReason.BREAKPOINT_HIT;
// Get ID
foreach (var pair in BreakpointMap)
{
if(pair.Value == pc)
{
bpId = pair.Key;
if (Log.Enabled)
Log.WriteLine("Found BpID={0} for PC={1}", bpId, pc);
break;
}
}
reason = BreakReason.NO_REASON;
bpAddress = pc;
}
else
// Check for breakpoint
else if (BreakpointMap.ContainsValue(pc))
{
// Check temporary breakpoints
if (pc == TmpBreakpoint1 || pc == TmpBreakpoint2)
reason = BreakReason.NO_REASON;
// Breakpoint hit
reason = BreakReason.BREAKPOINT_HIT;
bpAddress = pc;
}

// Note: Watchpoint reasons cannot be safely recognized.
Expand All @@ -245,7 +236,7 @@ protected static void DebuggerStopped()
}
}
// Send break notification
SendPauseNotification(reason, bpId, reasonString);
SendPauseNotification(reason, bpAddress, reasonString);

// "Undefine" temporary breakpoints
TmpBreakpoint1 = -1;
Expand Down Expand Up @@ -839,7 +830,7 @@ public static void SetBorder()
/**
* Sends the pause notification.
*/
protected static void SendPauseNotification(BreakReason reason, int bpId, string reasonString)
protected static void SendPauseNotification(BreakReason reason, ushort bpAddress, string reasonString)
{
// Convert strign to byte array
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
Expand All @@ -861,9 +852,9 @@ protected static void SendPauseNotification(BreakReason reason, int bpId, string
(byte)DZRP_NTF.NTF_PAUSE,
// Reason
(byte)reason,
// Breakpoint ID
(byte)(bpId & 0xFF),
(byte)((bpId >> 8) & 0xFF),
// Breakpoint address
(byte)(bpAddress & 0xFF),
(byte)((bpAddress >> 8) & 0xFF),
};
int firstLen = dataWoString.Length;
byte[] data = new byte[firstLen + stringLen];
Expand Down
2 changes: 1 addition & 1 deletion Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace DeZogPlugin
{
/**
* The plugin implements a socket to communitate with [DeZog](https://github.com/maziac/DeZog).
* The plugin implements a socket to communicate with [DeZog](https://github.com/maziac/DeZog).
* The received commands are executed and control the CSpect debugger.
*/
public class Main : iPlugin
Expand Down

0 comments on commit d82153f

Please sign in to comment.