/// <summary> /// Attach an instance of JDbg to a VM listening on hostname:port /// </summary> /// <param name="hostname"></param> /// <param name="port"></param> /// <returns></returns> public static JDbg Attach(string hostname, int port) { JDbg jdbg = new JDbg(hostname, port); jdbg._jdwp = Jdwp.Attach(hostname, port); return(jdbg); }
void IPlatformAppLauncher.OnResume() { if (_jdbPortNumber == 0) { throw new InvalidOperationException(); } // We do not need to attach JDbg in an attach scneario if (!_launchOptions.IsAttach) { ThreadPool.QueueUserWorkItem(async(state) => { try { _jdbg = JDbg.JDbg.Attach(_jdbPortNumber); await _jdbg.Inititalize(); //we will let the Dispose method on the launcher detach and close m_jdbg _onResumeSucceeded = true; } catch (JDbg.JdwpException e) { MICore.Logger.WriteLine("JdwpException: {0}", e.Message); string message = LauncherResources.Warning_JDbgResumeFailure; if (e.ErrorCode == ErrorCode.VMUnavailable) { // NOTE: I have seen the following behaviors from Eclipse in this case // 1. The user could already be in the debug perspective and if the have breakpoints set, they might // have hit. In these cases they might not know to go back to Eclipse to resume. // 2. The user could be in the Java perspective but suddenly start debugging. However, Eclipse will // stay in the edit perspective so there may be no indication that they are debugging. Sometimes // the app just seems to run, so everything is good there. But sometimes the app doesn't resume // and so the user needs to either close Eclipse or every time switch to the debug perspective and // disconnect. message = string.Concat(message, " ", LauncherResources.Warning_JdbgVMUnavailable); } else if (e.InnerException != null) { message = string.Concat(message, " ", e.InnerException.Message); } _eventCallback.OnWarning(message); } catch (OperationCanceledException) { // Ignore failures if Close is called } }); } else { // For attach, just set succeeded _onResumeSucceeded = true; } if (_isUsingArmEmulator && !s_sentArmEmulatorWarning) { _eventCallback.OnWarning(LauncherResources.Warning_ArmEmulator); // Set this to true so that we don't spam the user, we will not show the warning again until we restart debugging s_sentArmEmulatorWarning = true; } }
void IPlatformAppLauncher.OnResume() { if (_jdbPortNumber == 0) { throw new InvalidOperationException(); } // We do not need to attach JDbg in an attach scneario if (!_launchOptions.IsAttach) { ThreadPool.QueueUserWorkItem(async (state) => { try { _jdbg = JDbg.JDbg.Attach(_jdbPortNumber); await _jdbg.Inititalize(); //we will let the Dispose method on the launcher detach and close m_jdbg _onResumeSucceeded = true; } catch (JDbg.JdwpException e) { Logger.WriteLine("JdwpException: {0}", e.Message); string message = LauncherResources.Warning_JDbgResumeFailure; if (e.ErrorCode == ErrorCode.VMUnavailable) { // NOTE: I have seen the following behaviors from Eclipse in this case // 1. The user could already be in the debug perspective and if the have breakpoints set, they might // have hit. In these cases they might not know to go back to Eclipse to resume. // 2. The user could be in the Java perspective but suddenly start debugging. However, Eclipse will // stay in the edit perspective so there may be no indication that they are debugging. Sometimes // the app just seems to run, so everything is good there. But sometimes the app doesn't resume // and so the user needs to either close Eclipse or every time switch to the debug perspective and // disconnect. message = string.Concat(message, " ", LauncherResources.Warning_JdbgVMUnavailable); } else if (e.InnerException != null) { message = string.Concat(message, " ", e.InnerException.Message); } _eventCallback.OnWarning(message); } catch (OperationCanceledException) { // Ignore failures if Close is called } }); } else { // For attach, just set succeeded _onResumeSucceeded = true; } if (_isUsingArmEmulator && !s_sentArmEmulatorWarning) { _eventCallback.OnWarning(LauncherResources.Warning_ArmEmulator); // Set this to true so that we don't spam the user, we will not show the warning again until we restart debugging s_sentArmEmulatorWarning = true; } }
/// <summary> /// Attach an instance of JDbg to a VM listening on hostname:port /// </summary> /// <param name="hostname"></param> /// <param name="port"></param> /// <returns></returns> public static JDbg Attach(string hostname, int port) { JDbg jdbg = new JDbg(hostname, port); jdbg._jdwp = Jdwp.Attach(hostname, port); return jdbg; }