private void DebuggerKill() { lock (_lock) { try { if (!(iOSDebuggerProcess?.HasExited ?? true)) { iOSDebuggerProcess?.StandardInput?.WriteLine("\r\n"); iOSDebuggerProcess?.Kill(); iOSDebuggerProcess = null; } } catch (Exception ex) { Console.WriteLine(ex); } if (_session != null) { _debuggeeExecuting = true; if (!_session.HasExited) { _session.Exit(); } _session.Dispose(); _session = null; } } }
public override void Disconnect(Response response, dynamic args) { try { if (!(iOSDebuggerProcess?.HasExited ?? true)) { iOSDebuggerProcess?.StandardInput?.WriteLine("\r\n"); iOSDebuggerProcess?.Kill(); iOSDebuggerProcess = null; } } catch (Exception ex) { Console.WriteLine(ex); } IDEManager.Shared.StopMonitoring(); if (_attachMode) { lock (_lock) { if (_session != null) { _debuggeeExecuting = true; _breakpoints.Clear(); _session.Breakpoints.Clear(); _session.Continue(); _session = null; } } } else { // Let's not leave dead Mono processes behind... if (_process != null) { _process.Kill(); _process = null; } else { PauseDebugger(); DebuggerKill(); while (!_debuggeeKilled) { System.Threading.Thread.Sleep(10); } } } SendResponse(response); }
private void DebuggerKill() { lock (_lock) { if (_session != null) { _debuggeeExecuting = true; if (!_session.HasExited) { _session.Exit(); } _session.Dispose(); _session = null; } } }
private void DebuggerKill() { lock (m_Lock) { if (m_Session != null) { m_DebuggeeExecuting = true; if (!m_Session.HasExited) { m_Session.Exit(); } m_Session.Dispose(); m_Session = null; } } }
public override void Disconnect(Response response, dynamic args) { if (_attachMode) { lock (_lock) { if (_session != null) { _debuggeeExecuting = true; _breakpoints.Clear(); _session.Breakpoints.Clear(); _session.Continue(); _session.Detach(); _session = null; } } } else { // Let's not leave dead Mono processes behind... if (_process != null) { _process.Kill(); _process = null; } else { PauseDebugger(); DebuggerKill(); while (!_debuggeeKilled) { System.Threading.Thread.Sleep(10); } } } SendResponse(response); }
public override void Disconnect(Response response, dynamic args) { if (unityDebugConnector != null) { unityDebugConnector.OnDisconnect(); unityDebugConnector = null; } lock (m_Lock) { if (m_Session != null) { m_DebuggeeExecuting = true; m_Breakpoints = null; m_Session.Breakpoints.Clear(); m_Session.Continue(); m_Session.Detach(); m_Session.Adaptor.Dispose(); m_Session = null; } } SendOutput("stdout", "UnityDebug: Disconnected"); SendResponse(response); }
public MonoDebugSession() : base() { _variableHandles = new Handles <ObjectValue[]>(); _frameHandles = new Handles <Mono.Debugging.Client.StackFrame>(); _seenThreads = new Dictionary <int, Thread>(); _debuggerSessionOptions = new DebuggerSessionOptions { EvaluationOptions = EvaluationOptions.DefaultOptions }; _session = new XamarinDebuggerSession(); _session.Breakpoints = new BreakpointStore(); _breakpoints = new SortedDictionary <long, BreakEvent>(); _catchpoints = new List <Catchpoint>(); DebuggerLoggingService.CustomLogger = new CustomLogger(); _session.ExceptionHandler = ex => { return(true); }; _session.LogWriter = (isStdErr, text) => { }; _session.TargetStopped += (sender, e) => { Stopped(); SendEvent(CreateStoppedEvent("step", e.Thread)); _resumeEvent.Set(); }; _session.TargetHitBreakpoint += (sender, e) => { Stopped(); SendEvent(CreateStoppedEvent("breakpoint", e.Thread)); _resumeEvent.Set(); }; _session.TargetExceptionThrown += (sender, e) => { Stopped(); var ex = DebuggerActiveException(); if (ex != null) { _exception = ex.Instance; SendEvent(CreateStoppedEvent("exception", e.Thread, ex.Message)); } _resumeEvent.Set(); }; _session.TargetUnhandledException += (sender, e) => { Stopped(); var ex = DebuggerActiveException(); if (ex != null) { _exception = ex.Instance; SendEvent(CreateStoppedEvent("exception", e.Thread, ex.Message)); } _resumeEvent.Set(); }; _session.TargetStarted += (sender, e) => { _activeFrame = null; }; _session.TargetReady += (sender, e) => { _activeProcess = _session.GetProcesses().SingleOrDefault(); }; _session.TargetExited += (sender, e) => { DebuggerKill(); _debuggeeKilled = true; Terminate("target exited"); _resumeEvent.Set(); }; _session.TargetInterrupted += (sender, e) => { _resumeEvent.Set(); }; _session.TargetEvent += (sender, e) => { }; _session.TargetThreadStarted += (sender, e) => { int tid = (int)e.Thread.Id; lock (_seenThreads) { _seenThreads[tid] = new Thread(tid, e.Thread.Name); } SendEvent(new ThreadEvent("started", tid)); }; _session.TargetThreadStopped += (sender, e) => { int tid = (int)e.Thread.Id; lock (_seenThreads) { _seenThreads.Remove(tid); } SendEvent(new ThreadEvent("exited", tid)); }; _session.OutputWriter = (isStdErr, text) => { SendOutput(isStdErr ? "stderr" : "stdout", text); }; }
public UnityDebugSession() : base() { m_VariableHandles = new Handles <ObjectValue[]>(); m_FrameHandles = new Handles <Mono.Debugging.Client.StackFrame>(); m_SeenThreads = new Dictionary <int, VSCodeDebug.Thread>(); m_DebuggerSessionOptions = new DebuggerSessionOptions { EvaluationOptions = EvaluationOptions.DefaultOptions }; m_Session = new UnityDebuggerSession(); m_Session.Breakpoints = new BreakpointStore(); m_Catchpoints = new List <Catchpoint>(); DebuggerLoggingService.CustomLogger = new CustomLogger(); m_Session.ExceptionHandler = ex => { return(true); }; m_Session.LogWriter = (isStdErr, text) => { }; m_Session.TargetStopped += (sender, e) => { if (e.Backtrace != null) { Frame = e.Backtrace.GetFrame(0); } else { SendOutput("stdout", "e.Bracktrace is null"); } Stopped(); SendEvent(CreateStoppedEvent("step", e.Thread)); m_ResumeEvent.Set(); }; m_Session.TargetHitBreakpoint += (sender, e) => { Frame = e.Backtrace.GetFrame(0); Stopped(); SendEvent(CreateStoppedEvent("breakpoint", e.Thread)); m_ResumeEvent.Set(); }; m_Session.TargetExceptionThrown += (sender, e) => { Frame = e.Backtrace.GetFrame(0); for (var i = 0; i < e.Backtrace.FrameCount; i++) { if (!e.Backtrace.GetFrame(i).IsExternalCode) { Frame = e.Backtrace.GetFrame(i); break; } } Stopped(); var ex = DebuggerActiveException(); if (ex != null) { m_Exception = ex.Instance; SendEvent(CreateStoppedEvent("exception", e.Thread, ex.Message)); } m_ResumeEvent.Set(); }; m_Session.TargetUnhandledException += (sender, e) => { Stopped(); var ex = DebuggerActiveException(); if (ex != null) { m_Exception = ex.Instance; SendEvent(CreateStoppedEvent("exception", e.Thread, ex.Message)); } m_ResumeEvent.Set(); }; m_Session.TargetStarted += (sender, e) => { }; m_Session.TargetReady += (sender, e) => { m_ActiveProcess = m_Session.GetProcesses().SingleOrDefault(); }; m_Session.TargetExited += (sender, e) => { DebuggerKill(); Terminate("target exited"); m_ResumeEvent.Set(); }; m_Session.TargetInterrupted += (sender, e) => { m_ResumeEvent.Set(); }; m_Session.TargetEvent += (sender, e) => { }; m_Session.TargetThreadStarted += (sender, e) => { int tid = (int)e.Thread.Id; lock (m_SeenThreads) { m_SeenThreads[tid] = new VSCodeDebug.Thread(tid, e.Thread.Name); } SendEvent(new ThreadEvent("started", tid)); }; m_Session.TargetThreadStopped += (sender, e) => { int tid = (int)e.Thread.Id; lock (m_SeenThreads) { m_SeenThreads.Remove(tid); } SendEvent(new ThreadEvent("exited", tid)); }; m_Session.OutputWriter = (isStdErr, text) => { SendOutput(isStdErr ? "stderr" : "stdout", text); }; }