public DbgAppDomainImpl(DbgRuntimeImpl runtime, DbgInternalAppDomain internalAppDomain, string name, int id) { this.runtime = runtime ?? throw new ArgumentNullException(nameof(runtime)); InternalAppDomain = internalAppDomain ?? throw new ArgumentNullException(nameof(internalAppDomain)); this.name = name; this.id = id; }
public DbgObjectFactoryImpl(DbgManagerImpl owner, DbgRuntimeImpl runtime, DbgEngine engine, Lazy <BoundCodeBreakpointsService> boundCodeBreakpointsService) { this.owner = owner ?? throw new ArgumentNullException(nameof(owner)); this.runtime = runtime ?? throw new ArgumentNullException(nameof(runtime)); this.engine = engine ?? throw new ArgumentNullException(nameof(engine)); this.boundCodeBreakpointsService = boundCodeBreakpointsService ?? throw new ArgumentNullException(nameof(boundCodeBreakpointsService)); }
public EngineInfo(DbgEngine engine, DbgRuntimeImpl runtime) { Engine = engine; Runtime = runtime; Debugging = engine.Debugging ?? Array.Empty <string>(); IsPaused = false; }
void SetCurrentRuntime_DbgThread(DbgRuntimeImpl newRuntime) { Dispatcher.VerifyAccess(); if (!(newRuntime?.Process is DbgProcessImpl newProcess) || newProcess.State != DbgProcessState.Paused || newRuntime.IsClosed) { return; } DbgCurrentObjectChangedEventArgs <DbgProcess> processEventArgs; DbgCurrentObjectChangedEventArgs <DbgRuntime> runtimeEventArgs; DbgCurrentObjectChangedEventArgs <DbgThread> threadEventArgs; lock (lockObj) { var newCurrentProcess = new CurrentObject <DbgProcessImpl>(newProcess, dbgCurrentProcess.currentProcess.Break); newProcess.SetCurrentRuntime_DbgThread(newRuntime); var newCurrentRuntime = newProcess.CurrentRuntime; Debug.Assert(newCurrentRuntime.Current == newRuntime); var newCurrentThread = newCurrentRuntime.Current?.CurrentThread ?? default; processEventArgs = new DbgCurrentObjectChangedEventArgs <DbgProcess>(currentChanged: dbgCurrentProcess.currentProcess.Current != newCurrentProcess.Current, breakChanged: dbgCurrentProcess.currentProcess.Break != newCurrentProcess.Break); runtimeEventArgs = new DbgCurrentObjectChangedEventArgs <DbgRuntime>(currentChanged: dbgCurrentRuntime.currentRuntime.Current != newCurrentRuntime.Current, breakChanged: dbgCurrentRuntime.currentRuntime.Break != newCurrentRuntime.Break); threadEventArgs = new DbgCurrentObjectChangedEventArgs <DbgThread>(currentChanged: dbgCurrentThread.currentThread.Current != newCurrentThread.Current, breakChanged: dbgCurrentThread.currentThread.Break != newCurrentThread.Break); dbgCurrentProcess.currentProcess = newCurrentProcess; dbgCurrentRuntime.currentRuntime = newCurrentRuntime; dbgCurrentThread.currentThread = newCurrentThread; } RaiseCurrentObjectEvents_DbgThread(processEventArgs, runtimeEventArgs, threadEventArgs); }
public DbgBoundCodeBreakpointImpl(DbgRuntimeImpl runtime, DbgCodeBreakpoint breakpoint, DbgModule?module, ulong address, DbgBoundCodeBreakpointMessage message) { lockObj = new object(); this.runtime = runtime ?? throw new ArgumentNullException(nameof(runtime)); this.breakpoint = breakpoint ?? throw new ArgumentNullException(nameof(breakpoint)); this.module = module; this.address = address; this.message = message; }
// DbgManager thread void UpdateRuntime_DbgThread(DbgRuntimeImpl runtime) { owner.Dispatcher.VerifyAccess(); lock (lockObj) { var newCurrent = GetRuntime_NoLock(currentRuntime.Current, runtime); var newBreak = GetRuntime_NoLock(currentRuntime.Break, runtime); currentRuntime = new CurrentObject <DbgRuntimeImpl>(newCurrent, newBreak); } }
DbgRuntimeImpl GetRuntime_NoLock(DbgRuntimeImpl runtime, DbgRuntimeImpl defaultRuntime) { if (runtime != null) { var info = engineInfos.First(a => a.Runtime == runtime); if (info.IsPaused || owner.GetDelayedIsRunning_DbgThread(info.Engine) == false) { return(runtime); } } return(defaultRuntime ?? engineInfos.FirstOrDefault(a => a.IsPaused)?.Runtime); }
// DbgManager thread internal void SetRunning_DbgThread(DbgRuntimeImpl runtime) { owner.Dispatcher.VerifyAccess(); if (runtime == null) { return; } lock (lockObj) { var info = engineInfos.First(a => a.Runtime == runtime); info.IsPaused = false; UpdateRuntime_DbgThread(null); } }
public DbgModuleImpl(DbgRuntimeImpl runtime, DbgAppDomainImpl 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) { lockObj = new object(); this.runtime = runtime ?? throw new ArgumentNullException(nameof(runtime)); this.appDomain = appDomain; InternalModule = internalModule ?? throw new ArgumentNullException(nameof(internalModule)); this.isExe = isExe; this.address = address; this.size = size; this.imageLayout = imageLayout; this.name = name; this.filename = filename; this.isDynamic = isDynamic; this.isInMemory = isInMemory; this.isOptimized = isOptimized; this.order = order; this.timestamp = timestamp?.ToUniversalTime(); this.version = version; }
internal void RemoveBoundCodeBreakpoints_DbgThread(DbgRuntimeImpl runtime, DbgEngineBoundCodeBreakpointImpl[] breakpoints) { Dispatcher.VerifyAccess(); Debug.Assert(IsOurEngine(runtime.Engine)); if (!owner.IsOurEngine(runtime.Engine)) { foreach (var bp in breakpoints) { bp.BoundCodeBreakpoint.Close(Dispatcher); } return; } var bps = breakpoints.Select(a => a.BoundCodeBreakpoint).ToArray(); BoundCodeBreakpointsService.RemoveBoundBreakpoints_DbgThread(bps); foreach (var bp in bps) { bp.Close(Dispatcher); } }
internal (DbgRuntimeImpl runtime, bool hasMoreRuntimes) Remove_DbgThread(DbgEngine engine) { DbgRuntimeImpl runtime = null; bool hasMoreRuntimes; lock (lockObj) { for (int i = 0; i < engineInfos.Count; i++) { var info = engineInfos[i]; if (info.Engine == engine) { UpdateRuntime_DbgThread(null); runtime = info.Runtime; engineInfos.RemoveAt(i); break; } } hasMoreRuntimes = engineInfos.Count > 0; } return(runtime, hasMoreRuntimes); }
internal void Add_DbgThread(DbgEngine engine, DbgRuntimeImpl runtime, DbgProcessState newState) { bool raiseStateChanged, raiseDebuggingChanged, raiseIsRunningChanged; DbgThread[] addedThreads; lock (lockObj) { engineInfos.Add(new EngineInfo(engine, runtime)); var newDebugging = CalculateDebugging_NoLock(); raiseStateChanged = state != newState; raiseDebuggingChanged = !StringArrayEquals(debugging, newDebugging); state = newState; if (raiseDebuggingChanged) { debugging = newDebugging; } var newIsRunning = CalculateIsRunning_NoLock(); raiseIsRunningChanged = cachedIsRunning != newIsRunning; cachedIsRunning = newIsRunning; addedThreads = runtime.Threads; runtime.ThreadsChanged += DbgRuntime_ThreadsChanged; } RuntimesChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgRuntime>(runtime, added: true)); if (addedThreads.Length != 0) { ThreadsChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgThread>(addedThreads, added: true)); } if (raiseStateChanged) { OnPropertyChanged(nameof(State)); } if (raiseIsRunningChanged) { IsRunningChanged?.Invoke(this, EventArgs.Empty); } if (raiseDebuggingChanged) { OnPropertyChanged(nameof(Debugging)); } }
internal void AddBoundCodeBreakpoints_DbgThread(DbgRuntimeImpl runtime, DbgEngineBoundCodeBreakpointImpl[] breakpoints) { Dispatcher.VerifyAccess(); Debug.Assert(IsOurEngine(runtime.Engine)); if (!IsOurEngine(runtime.Engine)) { foreach (var bp in breakpoints) { bp.BoundCodeBreakpoint.Close(Dispatcher); } return; } var bpsToKeep = new List <DbgBoundCodeBreakpoint>(breakpoints.Length); foreach (var bp in breakpoints) { var bound = bp.BoundCodeBreakpoint; if (bound.Runtime.IsClosed || bound.Module?.IsClosed == true || bound.Breakpoint.IsClosed) { bound.Close(Dispatcher); } else { bpsToKeep.Add(bound); } } if (bpsToKeep.Count > 0) { var objsToClose = BoundCodeBreakpointsService.AddBoundBreakpoints_DbgThread(bpsToKeep); foreach (var bp in objsToClose) { bp.Close(Dispatcher); } } }
// DbgManager thread internal void SetCurrentRuntime_DbgThread(DbgRuntimeImpl runtime) { owner.Dispatcher.VerifyAccess(); currentRuntime = new CurrentObject <DbgRuntimeImpl>(runtime, currentRuntime.Break); }
public DbgBoundCodeBreakpointImpl(DbgRuntimeImpl runtime, DbgCodeBreakpoint breakpoint, DbgModule module, ulong address, in DbgBoundCodeBreakpointMessage message)