/// <summary> /// New JDWP process found, attach debugger to it. /// </summary> private void OnDebuggableProcessAdded(IDevice device, int pid) { // Did we see the pid before? lock (processedPidsLock) { if (!processedPids.Add(pid)) { outputPane.LogLine(string.Format("Found debuggable process {0} again, ignoring", pid)); return; } } // Wait a while, it can be a very short lived process Thread.Sleep(500); // Cancelled? if (token.IsCancellationRequested) { DLog.Debug(DContext.VSDebuggerLauncher, "Cancel requested"); return; } // Check if pid still exists var monitor = jdwpMonitor; if ((monitor == null) || !monitor.ContainsProcess(pid)) { DLog.Debug(DContext.VSDebuggerLauncher, "JDWP process gone {0}", pid); return; } // Create and attach debugger outputPane.LogLine(string.Format("Found debuggable process {0}", pid)); var debugger = new XDebugger(ide.GetFrameworkTypeMap(apiLevel)); debuggers.Add(debugger); debugger.JdwpEvent += OnDebuggerDalvikEvent; debugger.Connect(device, pid, new MapFile(), apkPath); ide.CurrentDevice = device; ide.CurrentProcessId = pid; }
/// <summary> /// Record the given log entry if the level is sufficient. /// </summary> protected override void Write(Levels level, DContext context, string url, int column, int lineNr, string msg, Exception exception, object[] args) { if (level < Levels.Error) { return; } if ((msg == null) && (exception != null)) { msg = exception.Message; } if (msg == null) { return; } if (!Show(level, context)) { return; } outputPane.EnsureLoaded(); outputPane.LogLine(FormatLevel(level) + FormatContext(context) + string.Format(msg, args)); }
/// <summary> /// Write a message to the output pane. /// </summary> private void LogLine(string message) { outputPane.LogLine(message); }