// Copyright (c) 2026 Petr BalvĂ­n (https://petrbalvin.org) // SPDX-License-Identifier: BSD-3-Clause //go:build freebsd && riscv64 package debug import "fmt" // The architecture has hardware watchpoint triggers, but FreeBSD exposes // no PT_GETDBREGS request for riscv64, so there is no supported way to arm // one: the watchpoint layer is honestly empty here. // WatchpointType selects what triggers the watchpoint. type WatchpointType int const ( WatchWrite WatchpointType = 1 // trigger on write WatchRead WatchpointType = 3 // trigger on read or write ) // maxWatchpoints reports the number of hardware watchpoint slots the // platform provides: FreeBSD exposes none for riscv64. func maxWatchpoints() int { return 0 } // archStopTrace classifies a TRAP_TRACE stop; with no watchpoint layer a // trace stop is always a completed single step. func archStopTrace(s *Session, siAddr uint64) (StopReason, uint64) { return StopSingleStep, 0 } // FindFreeWatchpointSlot returns -1: no slots exist. func (s *Session) FindFreeWatchpointSlot() int { return -1 } // IsWatchpointSlotUsed reports whether slot currently holds a watchpoint. func (s *Session) IsWatchpointSlotUsed(slot int) bool { return false } // SetWatchpoint is unsupported: FreeBSD exposes no debug register request // for riscv64. func (s *Session) SetWatchpoint(slot int, addr uint64, typ WatchpointType, size int) error { return fmt.Errorf("debug: hardware watchpoints are not supported on freebsd/riscv64") } // ClearWatchpoint is unsupported for the same reason. func (s *Session) ClearWatchpoint(slot int) error { return fmt.Errorf("debug: hardware watchpoints are not supported on freebsd/riscv64") } // ClearAllWatchpoints is a no-op: no watchpoint can be armed. func (s *Session) ClearAllWatchpoints() error { return nil }