docs: document watchpoint slot tracking and update debugger commands
This commit is contained in:
@@ -271,3 +271,53 @@ func TestBreakpointInfo(t *testing.T) {
|
||||
t.Errorf("Info %q does not contain label", info)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWatchpointSlotTracking(t *testing.T) {
|
||||
s := &Session{}
|
||||
|
||||
// All four slots are free initially.
|
||||
for i := 0; i < 4; i++ {
|
||||
if s.IsWatchpointSlotUsed(i) {
|
||||
t.Errorf("slot %d should be free initially", i)
|
||||
}
|
||||
}
|
||||
if got := s.FindFreeWatchpointSlot(); got != 0 {
|
||||
t.Errorf("FindFreeWatchpointSlot() = %d, want 0", got)
|
||||
}
|
||||
|
||||
// Manually mark slots 0 and 2 as used (simulating successful SetWatchpoint).
|
||||
s.wpSlots[0] = true
|
||||
s.wpSlots[2] = true
|
||||
|
||||
if !s.IsWatchpointSlotUsed(0) {
|
||||
t.Error("slot 0 should be in use")
|
||||
}
|
||||
if s.IsWatchpointSlotUsed(1) {
|
||||
t.Error("slot 1 should be free")
|
||||
}
|
||||
if !s.IsWatchpointSlotUsed(2) {
|
||||
t.Error("slot 2 should be in use")
|
||||
}
|
||||
if s.IsWatchpointSlotUsed(3) {
|
||||
t.Error("slot 3 should be free")
|
||||
}
|
||||
if got := s.FindFreeWatchpointSlot(); got != 1 {
|
||||
t.Errorf("FindFreeWatchpointSlot() = %d, want 1", got)
|
||||
}
|
||||
|
||||
// Out-of-range slot queries return false.
|
||||
if s.IsWatchpointSlotUsed(-1) {
|
||||
t.Error("slot -1 should be reported as free (out of range)")
|
||||
}
|
||||
if s.IsWatchpointSlotUsed(4) {
|
||||
t.Error("slot 4 should be reported as free (out of range)")
|
||||
}
|
||||
|
||||
// Mark all slots used: FindFreeWatchpointSlot returns -1.
|
||||
for i := 0; i < 4; i++ {
|
||||
s.wpSlots[i] = true
|
||||
}
|
||||
if got := s.FindFreeWatchpointSlot(); got != -1 {
|
||||
t.Errorf("FindFreeWatchpointSlot() with all slots used = %d, want -1", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user