// Copyright (C) 2026 SharpEmu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later namespace SharpEmu.Debugger.Breakpoints; /// /// A single breakpoint or watchpoint. Instances are immutable; the owning /// replaces an entry to change its enabled state. /// public sealed class Breakpoint { public Breakpoint(int id, BreakpointKind kind, ulong address, ulong length = 1, bool enabled = true) { if (length == 0) { throw new ArgumentOutOfRangeException(nameof(length), "Breakpoint length must be at least one byte."); } Id = id; Kind = kind; Address = address; Length = length; Enabled = enabled; } /// The store-assigned identifier used by clients to reference it. public int Id { get; } public BreakpointKind Kind { get; } /// The first guest address the breakpoint covers. public ulong Address { get; } /// /// The number of bytes the breakpoint covers. Always one for /// ; the watch kinds may span a range. /// public ulong Length { get; } public bool Enabled { get; } /// True when falls within this breakpoint. public bool Covers(ulong address) => address >= Address && address < Address + Length; /// Returns a copy with a different enabled state. public Breakpoint WithEnabled(bool enabled) => enabled == Enabled ? this : new Breakpoint(Id, Kind, Address, Length, enabled); }