public WatchpointDescriptor(ulong address, SysbusAccessWidth width, Access access, BusHookDelegate hook) { Address = address; Width = width; Access = access; Hook = hook; }
private static IEnumerable <WatchpointDescriptor> CalculateAllCoveringAddressess(ulong address, uint kind, Access access, BusHookDelegate hook) { foreach (SysbusAccessWidth width in Enum.GetValues(typeof(SysbusAccessWidth))) { for (var offset = -(long)(address % (ulong)width); offset < kind; offset += (long)width) { yield return(new WatchpointDescriptor(address - (ulong)(-offset), width, access, hook)); } } }
private void RemoveWatchpointsCoveringMemoryArea(ulong address, uint kind, Access access, BusHookDelegate hook) { // we need to unregister hooks from all possible access widths convering memory fragment // [address, address + kind) referred by GDB foreach (var descriptor in CalculateAllCoveringAddressess(address, kind, access, hook)) { lock (watchpoints) { if (watchpoints[descriptor] > 1) { watchpoints[descriptor]--; } else { watchpoints.Remove(descriptor); manager.Machine.SystemBus.RemoveWatchpointHook(descriptor.Address, hook); } } } }
private void AddWatchpointsCoveringMemoryArea(ulong address, uint kind, Access access, BusHookDelegate hook) { // we need to register hooks for all possible access widths covering memory fragment // [address, address + kind) referred by GDB foreach (var descriptor in CalculateAllCoveringAddressess(address, kind, access, hook)) { lock (watchpoints) { if (watchpoints.ContainsKey(descriptor)) { watchpoints[descriptor]++; } else { watchpoints.Add(descriptor, 1); manager.Machine.SystemBus.AddWatchpointHook(descriptor.Address, descriptor.Width, access, hook); } } } }
public bool ContainsAction(BusHookDelegate actionToTest) { return(action == actionToTest); }
public BusHookHandler(BusHookDelegate action, SysbusAccessWidth width) { this.action = action; this.width = width; Enabled = true; }