public override Task <DebugResult> Threads() { var threads = new List <OpenDebug.Thread>(); var process = Debugger.ActiveProcess; if (process != null) { Dictionary <int, OpenDebug.Thread> d; lock (_seenThreads) { d = new Dictionary <int, OpenDebug.Thread>(_seenThreads); } foreach (var t in process.GetThreads()) { int tid = (int)t.Id; d[tid] = new OpenDebug.Thread(tid, t.Name); } threads = d.Values.ToList(); } return(Task.FromResult(new DebugResult(new ThreadsResponseBody(threads)))); }
public UnityDebugSession(Action <DebugEvent> callback) : base(true) { _variableHandles = new Handles <ObjectValue[]>(); _frameHandles = new Handles <Mono.Debugging.Client.StackFrame>(); _seenThreads = new Dictionary <int, OpenDebug.Thread>(); Configuration.Current.MaxConnectionAttempts = 10; Configuration.Current.ConnectionAttemptInterval = 500; Debugger.Callback = (type, sourceLocation, threadinfo) => { int tid; switch (type) { case "TargetStopped": Stopped(); callback.Invoke(CreateStoppedEvent("step", sourceLocation, threadinfo)); break; case "TargetHitBreakpoint": Stopped(); callback.Invoke(CreateStoppedEvent("breakpoint", sourceLocation, threadinfo)); break; case "TargetExceptionThrown": case "TargetUnhandledException": Stopped(); ExceptionInfo ex = Debugger.ActiveException; if (ex != null) { _exception = ex.Instance; } callback.Invoke(CreateStoppedEvent("exception", sourceLocation, threadinfo, Debugger.ActiveException.Message)); break; case "TargetExited": callback.Invoke(new TerminatedEvent()); break; case "TargetThreadStarted": tid = (int)threadinfo.Id; lock (_seenThreads) { _seenThreads[tid] = new OpenDebug.Thread(tid, threadinfo.Name); } callback.Invoke(new ThreadEvent("started", tid)); break; case "TargetThreadStopped": tid = (int)threadinfo.Id; lock (_seenThreads) { _seenThreads.Remove(tid); } callback.Invoke(new ThreadEvent("exited", tid)); break; default: callback.Invoke(new DebugEvent(type)); break; } }; // the Soft Debugger is ready to accept breakpoints immediately (so it doesn't have to wait until the target is known) callback.Invoke(new InitializedEvent()); }
public UnityDebugSession (Action<DebugEvent> callback) : base(true) { _variableHandles = new Handles<ObjectValue[]>(); _frameHandles = new Handles<Mono.Debugging.Client.StackFrame>(); _seenThreads = new Dictionary<int, OpenDebug.Thread>(); Configuration.Current.MaxConnectionAttempts = 10; Configuration.Current.ConnectionAttemptInterval = 500; Debugger.Callback = (type, sourceLocation, threadinfo) => { int tid; switch (type) { case "TargetStopped": Stopped(); callback.Invoke(CreateStoppedEvent("step", sourceLocation, threadinfo)); break; case "TargetHitBreakpoint": Stopped(); callback.Invoke(CreateStoppedEvent("breakpoint", sourceLocation, threadinfo)); break; case "TargetExceptionThrown": case "TargetUnhandledException": Stopped(); ExceptionInfo ex = Debugger.ActiveException; if (ex != null) { _exception = ex.Instance; } callback.Invoke(CreateStoppedEvent("exception", sourceLocation, threadinfo, Debugger.ActiveException.Message)); break; case "TargetExited": callback.Invoke(new TerminatedEvent()); break; case "TargetThreadStarted": tid = (int)threadinfo.Id; lock (_seenThreads) { _seenThreads[tid] = new OpenDebug.Thread(tid, threadinfo.Name); } callback.Invoke(new ThreadEvent("started", tid)); break; case "TargetThreadStopped": tid = (int)threadinfo.Id; lock (_seenThreads) { _seenThreads.Remove(tid); } callback.Invoke(new ThreadEvent("exited", tid)); break; default: callback.Invoke(new DebugEvent(type)); break; } }; // the Soft Debugger is ready to accept breakpoints immediately (so it doesn't have to wait until the target is known) callback.Invoke(new InitializedEvent()); }
public override Task<DebugResult> Threads() { var threads = new List<OpenDebug.Thread>(); var process = Debugger.ActiveProcess; if (process != null) { Dictionary<int, OpenDebug.Thread> d; lock (_seenThreads) { d = new Dictionary<int, OpenDebug.Thread>(_seenThreads); } foreach (var t in process.GetThreads()) { int tid = (int)t.Id; d[tid] = new OpenDebug.Thread(tid, t.Name); } threads = d.Values.ToList(); } return Task.FromResult(new DebugResult(new ThreadsResponseBody(threads))); }
public ThreadsResponseBody(List<Thread> vars = null) { if (vars == null) threads = new Thread[0]; else threads = vars.ToArray<Thread>(); }