48 lines
1.0 KiB
Go
48 lines
1.0 KiB
Go
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
|
|||
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
||
|
|
|
||
|
|
//go:build linux && loong64
|
||
|
|
|
||
|
|
package debug
|
||
|
|
|
||
|
|
import "fmt"
|
||
|
|
|
||
|
|
// WatchpointType selects what triggers the watchpoint.
|
||
|
|
type WatchpointType int
|
||
|
|
|
||
|
|
const (
|
||
|
|
WatchWrite WatchpointType = 1
|
||
|
|
WatchRead WatchpointType = 3
|
||
|
|
)
|
||
|
|
|
||
|
|
// wpSlots tracks watchpoint slot occupancy.
|
||
|
|
var wpSlots [4]bool
|
||
|
|
|
||
|
|
func (s *Session) FindFreeWatchpointSlot() int {
|
||
|
|
for i := 0; i < 4; i++ {
|
||
|
|
if !wpSlots[i] {
|
||
|
|
return i
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return -1
|
||
|
|
}
|
||
|
|
|
||
|
|
func (s *Session) IsWatchpointSlotUsed(slot int) bool {
|
||
|
|
if slot < 0 || slot > 3 {
|
||
|
|
return false
|
||
|
|
}
|
||
|
|
return wpSlots[slot]
|
||
|
|
}
|
||
|
|
|
||
|
|
func (s *Session) SetWatchpoint(slot int, addr uint64, typ WatchpointType, size int) error {
|
||
|
|
return fmt.Errorf("debug: hardware watchpoints not yet implemented for loong64")
|
||
|
|
}
|
||
|
|
|
||
|
|
func (s *Session) ClearWatchpoint(slot int) error {
|
||
|
|
return fmt.Errorf("debug: hardware watchpoints not yet implemented for loong64")
|
||
|
|
}
|
||
|
|
|
||
|
|
func (s *Session) ClearAllWatchpoints() error {
|
||
|
|
return nil
|
||
|
|
}
|