internal void Remove_DbgThread(DbgModuleImpl module, DbgEngineMessageFlags messageFlags) { Dispatcher.VerifyAccess(); lock (lockObj) { bool b = modules.Remove(module); if (!b) { return; } } owner.RemoveModule_DbgThread(this, module, messageFlags); ModulesChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgModule>(module, added: false)); module.Close(Dispatcher); }
internal void Remove_DbgThread(DbgThreadImpl thread, DbgEngineMessageFlags messageFlags) { Dispatcher.VerifyAccess(); lock (lockObj) { bool b = threads.Remove(thread); if (!b) { return; } } owner.RemoveThread_DbgThread(this, thread, messageFlags); ThreadsChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgThread>(thread, added: false)); thread.Close(Dispatcher); }
/// <summary> /// Creates an exception. The engine has paused the program. /// </summary> /// <typeparam name="T">Type of data</typeparam> /// <param name="id">Exception id</param> /// <param name="flags">Exception event flags</param> /// <param name="message">Exception message or null if it's not available</param> /// <param name="thread">Thread where exception was thrown or null if it's unknown</param> /// <param name="module">Module where exception was thrown or null if it's unknown</param> /// <param name="messageFlags">Message flags</param> /// <param name="data">Data to add to the <see cref="DbgException"/> or null if nothing gets added</param> /// <param name="onCreated">Called right after creating the exception but before adding it to internal data structures. This can be null.</param> /// <returns></returns> public abstract DbgException CreateException <T>(DbgExceptionId id, DbgExceptionEventFlags flags, string message, DbgThread thread, DbgModule module, DbgEngineMessageFlags messageFlags, T data, Action <DbgException> onCreated = null) where T : class;
/// <summary> /// Creates a thread. The engine has paused the program. /// </summary> /// <typeparam name="T">Type of data</typeparam> /// <param name="appDomain">New <see cref="DbgThread.AppDomain"/> value</param> /// <param name="kind">New <see cref="DbgThread.Kind"/> value</param> /// <param name="id">New <see cref="DbgThread.Id"/> value</param> /// <param name="managedId">New <see cref="DbgThread.ManagedId"/> value</param> /// <param name="name">New <see cref="DbgThread.Name"/> value</param> /// <param name="suspendedCount">New <see cref="DbgThread.SuspendedCount"/> value</param> /// <param name="state">New <see cref="DbgThread.State"/> value</param> /// <param name="messageFlags">Message flags</param> /// <param name="data">Data to add to the <see cref="DbgThread"/> or null if nothing gets added</param> /// <param name="onCreated">Called right after creating the thread but before adding it to internal data structures. This can be null.</param> /// <returns></returns> public abstract DbgEngineThread CreateThread <T>(DbgAppDomain appDomain, string kind, ulong id, ulong?managedId, string name, int suspendedCount, ReadOnlyCollection <DbgStateInfo> state, DbgEngineMessageFlags messageFlags, T data, Action <DbgEngineThread> onCreated = null) where T : class;
/// <summary> /// Creates an exception. The engine has paused the program. /// </summary> /// <param name="id">Exception id</param> /// <param name="flags">Exception event flags</param> /// <param name="message">Exception message or null if it's not available</param> /// <param name="thread">Thread where exception was thrown or null if it's unknown</param> /// <param name="module">Module where exception was thrown or null if it's unknown</param> /// <param name="messageFlags">Message flags</param> /// <returns></returns> public DbgException CreateException(DbgExceptionId id, DbgExceptionEventFlags flags, string message, DbgThread thread, DbgModule module, DbgEngineMessageFlags messageFlags) => CreateException <object>(id, flags, message, thread, module, messageFlags, null, null);
/// <summary> /// Constructor /// </summary> /// <param name="exitCode">Exit code</param> /// <param name="messageFlags">Message flags</param> public DbgMessageDisconnected(int exitCode, DbgEngineMessageFlags messageFlags) : base(messageFlags) => ExitCode = exitCode;
/// <summary> /// Creates a thread. The engine has paused the program. /// </summary> /// <param name="appDomain">New <see cref="DbgThread.AppDomain"/> value</param> /// <param name="kind">New <see cref="DbgThread.Kind"/> value</param> /// <param name="id">New <see cref="DbgThread.Id"/> value</param> /// <param name="managedId">New <see cref="DbgThread.ManagedId"/> value</param> /// <param name="name">New <see cref="DbgThread.Name"/> value</param> /// <param name="suspendedCount">New <see cref="DbgThread.SuspendedCount"/> value</param> /// <param name="state">New <see cref="DbgThread.State"/> value</param> /// <param name="messageFlags">Message flags</param> /// <returns></returns> public DbgEngineThread CreateThread(DbgAppDomain appDomain, string kind, ulong id, ulong?managedId, string name, int suspendedCount, ReadOnlyCollection <DbgStateInfo> state, DbgEngineMessageFlags messageFlags) => CreateThread <object>(appDomain, kind, id, managedId, name, suspendedCount, state, messageFlags, null, null);
/// <summary> /// Creates a module. The engine has paused the program. /// </summary> /// <param name="appDomain">New <see cref="DbgModule.AppDomain"/> value</param> /// <param name="internalModule">Module object created by the debug engine</param> /// <param name="isExe">New <see cref="DbgModule.IsExe"/> value</param> /// <param name="address">New <see cref="DbgModule.Address"/> value</param> /// <param name="size">New <see cref="DbgModule.Size"/> value</param> /// <param name="imageLayout">New <see cref="DbgModule.ImageLayout"/> value</param> /// <param name="name">New <see cref="DbgModule.Name"/> value</param> /// <param name="filename">New <see cref="DbgModule.Filename"/> value</param> /// <param name="isDynamic">New <see cref="DbgModule.IsDynamic"/> value</param> /// <param name="isInMemory">New <see cref="DbgModule.IsInMemory"/> value</param> /// <param name="isOptimized">New <see cref="DbgModule.IsOptimized"/> value</param> /// <param name="order">New <see cref="DbgModule.Order"/> value</param> /// <param name="timestamp">New <see cref="DbgModule.Timestamp"/> value</param> /// <param name="version">New <see cref="DbgModule.Version"/> value</param> /// <param name="messageFlags">Message flags</param> /// <returns></returns> public DbgEngineModule CreateModule(DbgAppDomain appDomain, DbgInternalModule internalModule, bool isExe, ulong address, uint size, DbgImageLayout imageLayout, string name, string filename, bool isDynamic, bool isInMemory, bool?isOptimized, int order, DateTime?timestamp, string version, DbgEngineMessageFlags messageFlags) => CreateModule <object>(appDomain, internalModule, isExe, address, size, imageLayout, name, filename, isDynamic, isInMemory, isOptimized, order, timestamp, version, messageFlags, null, null);
/// <summary> /// Constructor /// </summary> /// <param name="message">Message</param> /// <param name="thread">Thread or null if it's not known</param> /// <param name="messageFlags">Message flags</param> public DbgMessageProgramMessage(string message, DbgThread thread, DbgEngineMessageFlags messageFlags) : base(messageFlags) { Message = message ?? throw new ArgumentNullException(nameof(message)); Thread = thread; }
internal void Remove(DbgEngineMessageFlags messageFlags) => Dispatcher.BeginInvoke(() => runtime.Remove_DbgThread(this, messageFlags));
internal void Remove_DbgThread(DbgAppDomainImpl appDomain, DbgEngineMessageFlags messageFlags) { Dispatcher.VerifyAccess(); List <DbgThread>?threadsToRemove = null; List <DbgModule>?modulesToRemove = null; lock (lockObj) { bool b = appDomains.Remove(appDomain); if (!b) { return; } for (int i = threads.Count - 1; i >= 0; i--) { var thread = threads[i]; if (thread.AppDomain == appDomain) { if (threadsToRemove is null) { threadsToRemove = new List <DbgThread>(); } threadsToRemove.Add(thread); threads.RemoveAt(i); } } for (int i = modules.Count - 1; i >= 0; i--) { var module = modules[i]; if (module.AppDomain == appDomain) { if (modulesToRemove is null) { modulesToRemove = new List <DbgModule>(); } modulesToRemove.Add(module); modules.RemoveAt(i); } } } if (threadsToRemove is not null && threadsToRemove.Count != 0) { ThreadsChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgThread>(threadsToRemove, added: false)); } if (modulesToRemove is not null && modulesToRemove.Count != 0) { ModulesChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgModule>(modulesToRemove, added: false)); } owner.RemoveAppDomain_DbgThread(this, appDomain, messageFlags); AppDomainsChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgAppDomain>(appDomain, added: false)); if (threadsToRemove is not null) { foreach (var thread in threadsToRemove) { thread.Close(Dispatcher); } } if (modulesToRemove is not null) { foreach (var module in modulesToRemove) { module.Close(Dispatcher); } } appDomain.Close(Dispatcher); }
/// <summary> /// Constructor /// </summary> /// <param name="messageFlags">Message flags</param> protected DbgEngineMessage(DbgEngineMessageFlags messageFlags) => MessageFlags = messageFlags;
/// <summary> /// Constructor /// </summary> /// <param name="processId">Process id</param> /// <param name="messageFlags">Message flags</param> public DbgMessageConnected(int processId, DbgEngineMessageFlags messageFlags) : base(messageFlags) => ProcessId = processId;
/// <summary> /// Constructor /// </summary> /// <param name="thread">Thread or null if it's not known</param> /// <param name="framesInvalidated">true if all frames in the thread have been invalidated</param> /// <param name="error">Error string or null if none</param> /// <param name="messageFlags">Message flags</param> public DbgMessageSetIPComplete(DbgThread thread, bool framesInvalidated, string error, DbgEngineMessageFlags messageFlags) : base(messageFlags) { Thread = thread ?? throw new ArgumentNullException(nameof(thread)); FramesInvalidated = framesInvalidated; Error = error; }
/// <summary> /// Constructor /// </summary> /// <param name="thread">Thread or null if it's not known</param> /// <param name="messageFlags">Message flags</param> public DbgMessageProgramBreak(DbgThread thread, DbgEngineMessageFlags messageFlags) : base(messageFlags) => Thread = thread;
/// <summary> /// Constructor /// </summary> /// <param name="boundBreakpoint">Breakpoint</param> /// <param name="thread">Thread or null if it's not known</param> /// <param name="messageFlags">Message flags</param> public DbgMessageBreakpoint(DbgBoundCodeBreakpoint boundBreakpoint, DbgThread thread, DbgEngineMessageFlags messageFlags) : base(messageFlags) { BoundBreakpoint = boundBreakpoint ?? throw new ArgumentNullException(nameof(boundBreakpoint)); Thread = thread; }
/// <summary> /// Creates an app domain. The engine has paused the program. /// </summary> /// <param name="internalAppDomain">App domain object created by the debug engine</param> /// <param name="name">New <see cref="DbgAppDomain.Name"/> value</param> /// <param name="id">New <see cref="DbgAppDomain.Id"/> value</param> /// <param name="messageFlags">Message flags</param> /// <returns></returns> public DbgEngineAppDomain CreateAppDomain(DbgInternalAppDomain internalAppDomain, string name, int id, DbgEngineMessageFlags messageFlags) => CreateAppDomain <object>(internalAppDomain, name, id, messageFlags, null, null);
public override DbgException CreateException <T>(DbgExceptionId id, DbgExceptionEventFlags flags, string message, DbgThread thread, DbgModule module, DbgEngineMessageFlags messageFlags, T data, Action <DbgException> onCreated) { if (id.IsDefaultId) { throw new ArgumentException(); } var exception = new DbgExceptionImpl(runtime, id, flags, message, thread, module); if (data != null) { exception.GetOrCreateData(() => data); } onCreated?.Invoke(exception); owner.Dispatcher.BeginInvoke(() => owner.AddException_DbgThread(runtime, exception, messageFlags)); return(exception); }
/// <summary> /// Creates an app domain. The engine has paused the program. /// </summary> /// <typeparam name="T">Type of data</typeparam> /// <param name="internalAppDomain">App domain object created by the debug engine</param> /// <param name="name">New <see cref="DbgAppDomain.Name"/> value</param> /// <param name="id">New <see cref="DbgAppDomain.Id"/> value</param> /// <param name="messageFlags">Message flags</param> /// <param name="data">Data to add to the <see cref="DbgAppDomain"/> or null if nothing gets added</param> /// <param name="onCreated">Called right after creating the app domain but before adding it to internal data structures. This can be null.</param> /// <returns></returns> public abstract DbgEngineAppDomain CreateAppDomain <T>(DbgInternalAppDomain internalAppDomain, string name, int id, DbgEngineMessageFlags messageFlags, T data, Action <DbgEngineAppDomain> onCreated = null) where T : class;
public override DbgEngineModule CreateModule <T>(DbgAppDomain appDomain, DbgInternalModule internalModule, bool isExe, ulong address, uint size, DbgImageLayout imageLayout, string name, string filename, bool isDynamic, bool isInMemory, bool?isOptimized, int order, DateTime?timestamp, string version, DbgEngineMessageFlags messageFlags, T data, Action <DbgEngineModule> onCreated) { if (disposed) { throw new ObjectDisposedException(nameof(DbgObjectFactoryImpl)); } var module = new DbgModuleImpl(runtime, VerifyOptionalAppDomain(appDomain), internalModule, isExe, address, size, imageLayout, name, filename, isDynamic, isInMemory, isOptimized, order, timestamp, version); if (data != null) { module.GetOrCreateData(() => data); } var engineModule = new DbgEngineModuleImpl(module); onCreated?.Invoke(engineModule); owner.Dispatcher.BeginInvoke(() => owner.AddModule_DbgThread(runtime, module, messageFlags)); return(engineModule); }
public override DbgEngineThread CreateThread <T>(DbgAppDomain appDomain, string kind, ulong id, ulong?managedId, string name, int suspendedCount, ReadOnlyCollection <DbgStateInfo> state, DbgEngineMessageFlags messageFlags, T data, Action <DbgEngineThread> onCreated) { if (disposed) { throw new ObjectDisposedException(nameof(DbgObjectFactoryImpl)); } var thread = new DbgThreadImpl(runtime, VerifyOptionalAppDomain(appDomain), kind, id, managedId, name, suspendedCount, state); if (data != null) { thread.GetOrCreateData(() => data); } var engineThread = new DbgEngineThreadImpl(thread); onCreated?.Invoke(engineThread); owner.Dispatcher.BeginInvoke(() => owner.AddThread_DbgThread(runtime, thread, messageFlags)); return(engineThread); }
/// <summary> /// Constructor /// </summary> /// <param name="thread">Thread or null if it's not known</param> /// <param name="messageFlags">Message flags</param> public DbgMessageEntryPointBreak(DbgThread thread, DbgEngineMessageFlags messageFlags) : base(messageFlags) => Thread = thread;
public override DbgEngineAppDomain CreateAppDomain <T>(DbgInternalAppDomain internalAppDomain, string name, int id, DbgEngineMessageFlags messageFlags, T data, Action <DbgEngineAppDomain> onCreated) { if (disposed) { throw new ObjectDisposedException(nameof(DbgObjectFactoryImpl)); } var appDomain = new DbgAppDomainImpl(runtime, internalAppDomain, name, id); if (data != null) { appDomain.GetOrCreateData(() => data); } var engineAppDomain = new DbgEngineAppDomainImpl(appDomain); onCreated?.Invoke(engineAppDomain); owner.Dispatcher.BeginInvoke(() => owner.AddAppDomain_DbgThread(runtime, appDomain, messageFlags)); return(engineAppDomain); }
/// <summary> /// Creates a module. The engine has paused the program. /// </summary> /// <typeparam name="T">Type of data</typeparam> /// <param name="appDomain">New <see cref="DbgModule.AppDomain"/> value</param> /// <param name="internalModule">Module object created by the debug engine</param> /// <param name="isExe">New <see cref="DbgModule.IsExe"/> value</param> /// <param name="address">New <see cref="DbgModule.Address"/> value</param> /// <param name="size">New <see cref="DbgModule.Size"/> value</param> /// <param name="imageLayout">New <see cref="DbgModule.ImageLayout"/> value</param> /// <param name="name">New <see cref="DbgModule.Name"/> value</param> /// <param name="filename">New <see cref="DbgModule.Filename"/> value</param> /// <param name="isDynamic">New <see cref="DbgModule.IsDynamic"/> value</param> /// <param name="isInMemory">New <see cref="DbgModule.IsInMemory"/> value</param> /// <param name="isOptimized">New <see cref="DbgModule.IsOptimized"/> value</param> /// <param name="order">New <see cref="DbgModule.Order"/> value</param> /// <param name="timestamp">New <see cref="DbgModule.Timestamp"/> value</param> /// <param name="version">New <see cref="DbgModule.Version"/> value</param> /// <param name="messageFlags">Message flags</param> /// <param name="data">Data to add to the <see cref="DbgModule"/> or null if nothing gets added</param> /// <param name="onCreated">Called right after creating the module but before adding it to internal data structures. This can be null.</param> /// <returns></returns> public abstract DbgEngineModule CreateModule <T>(DbgAppDomain appDomain, DbgInternalModule internalModule, bool isExe, ulong address, uint size, DbgImageLayout imageLayout, string name, string filename, bool isDynamic, bool isInMemory, bool?isOptimized, int order, DateTime?timestamp, string version, DbgEngineMessageFlags messageFlags, T data, Action <DbgEngineModule> onCreated = null) where T : class;
/// <summary> /// Removes the thread and disposes of it. The engine has paused the program. /// </summary> /// <param name="messageFlags">Message flags</param> public abstract void Remove(DbgEngineMessageFlags messageFlags);
/// <summary> /// Constructor /// </summary> /// <param name="thread">Thread or null if it's not known</param> /// <param name="messageFlags">Message flags</param> public DbgMessageBreak(DbgThread?thread, DbgEngineMessageFlags messageFlags) : base(messageFlags) => Thread = thread;