/*
Copyright (C) 2014-2019 de4dot@gmail.com
This file is part of dnSpy
dnSpy is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
dnSpy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with dnSpy. If not, see .
*/
using System;
using System.Collections.ObjectModel;
namespace dnSpy.Contracts.Debugger.Breakpoints.Modules {
///
/// Module breakpoints service
///
public abstract class DbgModuleBreakpointsService {
///
/// Modifies a breakpoint
///
/// Breakpoint
/// New settings
public void Modify(DbgModuleBreakpoint breakpoint, DbgModuleBreakpointSettings settings) =>
Modify(new[] { new DbgModuleBreakpointAndSettings(breakpoint, settings) });
///
/// Modifies breakpoints
///
/// New settings
public abstract void Modify(DbgModuleBreakpointAndSettings[] settings);
///
/// Raised when breakpoints are modified
///
public abstract event EventHandler? BreakpointsModified;
///
/// Gets all breakpoints
///
public abstract DbgModuleBreakpoint[] Breakpoints { get; }
///
/// Raised when is changed
///
public abstract event EventHandler>? BreakpointsChanged;
///
/// Adds a breakpoint
///
/// Breakpoint settings
///
public DbgModuleBreakpoint Add(DbgModuleBreakpointSettings settings) => Add(new[] { settings })[0];
///
/// Adds breakpoints
///
/// Breakpoint settings
///
public abstract DbgModuleBreakpoint[] Add(DbgModuleBreakpointSettings[] settings);
///
/// Removes a breakpoint
///
/// Breakpoint to remove
public void Remove(DbgModuleBreakpoint breakpoint) => Remove(new[] { breakpoint ?? throw new ArgumentNullException(nameof(breakpoint)) });
///
/// Removes breakpoints
///
/// Breakpoints to remove
public abstract void Remove(DbgModuleBreakpoint[] breakpoints);
///
/// Removes all module breakpoints
///
public abstract void Clear();
///
/// Finds breakpoints
///
/// Module
///
public abstract DbgModuleBreakpoint[] Find(in DbgModuleBreakpointInfo module);
///
/// Checks if matches at least one breakpoint
///
/// Module
///
public abstract bool IsMatch(in DbgModuleBreakpointInfo module);
}
///
/// Breakpoint and old settings
///
public readonly struct DbgModuleBreakpointAndOldSettings {
///
/// Gets the breakpoint
///
public DbgModuleBreakpoint Breakpoint { get; }
///
/// Gets the old settings
///
public DbgModuleBreakpointSettings OldSettings { get; }
///
/// Constructor
///
/// Breakpoint
/// Old settings
public DbgModuleBreakpointAndOldSettings(DbgModuleBreakpoint breakpoint, DbgModuleBreakpointSettings oldSettings) {
Breakpoint = breakpoint ?? throw new ArgumentNullException(nameof(breakpoint));
OldSettings = oldSettings;
}
}
///
/// Breakpoints modified event args
///
public readonly struct DbgBreakpointsModifiedEventArgs {
///
/// Gets the breakpoints
///
public ReadOnlyCollection Breakpoints { get; }
///
/// Constructor
///
/// Breakpoints and old settings
public DbgBreakpointsModifiedEventArgs(ReadOnlyCollection breakpoints) =>
Breakpoints = breakpoints ?? throw new ArgumentNullException(nameof(breakpoints));
}
///
/// Breakpoint and settings
///
public readonly struct DbgModuleBreakpointAndSettings {
///
/// Gets the breakpoint
///
public DbgModuleBreakpoint Breakpoint { get; }
///
/// Gets the new settings
///
public DbgModuleBreakpointSettings Settings { get; }
///
/// Constructor
///
/// Breakpoint
/// New settings
public DbgModuleBreakpointAndSettings(DbgModuleBreakpoint breakpoint, DbgModuleBreakpointSettings settings) {
Breakpoint = breakpoint ?? throw new ArgumentNullException(nameof(breakpoint));
Settings = settings;
}
}
}