Ejemplo n.º 1
0
        /// <summary>
        /// Disconnect from any connected VM.
        /// </summary>
        public void Disconnect()
        {
            var conn = connection;
            connection = null;
            prepared = false;
            pid = -1;
            var oldMonitor = jdwpMonitor;
            jdwpMonitor = null;
            if (oldMonitor != null)
            {
                oldMonitor.Stop();
                oldMonitor.Dispose();
            }

            if (conn != null)
            {
                try
                {
                    conn.Close();
                }
                catch
                {
                    // Ignore
                }
            }

            // Notify
            ConnectedChanged.Fire(this);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Attach the given JDWP monitor to this debugger.
 /// It will be stopped when this debugger is closed.
 /// </summary>
 public void Attach(JdwpMonitor jdwpMonitor)
 {
     var currentMonitor = this.jdwpMonitor;
     if ((currentMonitor != null) && (currentMonitor != jdwpMonitor))
     {
         currentMonitor.Stop();
         currentMonitor.Dispose();
         this.jdwpMonitor = null;
     }
     this.jdwpMonitor = jdwpMonitor;
     if (jdwpMonitor != null)
     {
         jdwpMonitor.ProcessRemoved += OnJdwpProcessRemoved;
     }
 }
Ejemplo n.º 3
0
            /// <summary>
            /// Debugger has connected.
            /// </summary>
            private void OnDebuggerDalvikEvent(object sender, JdwpEvent e)
            {
                DLog.Debug(DContext.VSDebuggerEvent, "DalvikEvent {0}", e);
                var debugger = (XDebugger)sender;
                if (!debugger.Connected || token.IsCancellationRequested)
                    return;

                if ((debugger.AppName == packageName) && !debuggerLaunched)
                {
                    // Inform status
                    debuggerLaunched = true;
                    outputPane.LogLine("Found process to debug");

                    // We've found the process to debug.
                    var currentMonitor = jdwpMonitor;
                    jdwpMonitor = null;
                    debugger.Attach(currentMonitor);
                    DisposeOtherDebuggers(debugger);

                    // Prepare the debugger
                    stateUpdate(LauncherStates.Attaching, string.Empty);
                    outputPane.LogLine("Preparing debugger launch");
                    try
                    {
                        LaunchVsDebugEngine(ide, apkPath, debugger, launchFlags, stateUpdate);
                    }
                    catch (Exception ex)
                    {
                        stateUpdate(LauncherStates.Error, ex.Message);
                    }
                }
            }
Ejemplo n.º 4
0
 /// <summary>
 /// Stop and close any open JDWP monitor.
 /// </summary>
 private void StopJdwpMonitor()
 {
     var monitor = jdwpMonitor;
     if (monitor != null)
     {
         jdwpMonitor = null;
         monitor.Stop();
         monitor.Dispose();
     }
 }
Ejemplo n.º 5
0
            public void Start()
            {
                // Start JDWP monitor
                jdwpMonitor = new JdwpMonitor(device);
                jdwpMonitor.Start();

                // Wait for initial update
                jdwpMonitor.WaitForInitialUpdate();
                jdwpMonitor.ProcessAdded += (s, x) => { DLog.Debug(DContext.VSDebuggerLauncher, "JDWP Process added {0}", x.Data); Task.Factory.StartNew(() => OnDebuggableProcessAdded(device, x.Data)); };
                jdwpMonitor.ProcessRemoved += (s, x) => DLog.Info(DContext.VSDebuggerLauncher, "JDWP process removed {0}", x.Data);                
            }