// Do the wire protocol handshake internal void Connect() { byte[] buf = new byte [HANDSHAKE_STRING.Length]; char[] cbuf = new char [buf.Length]; // FIXME: Add a timeout int n = Receive (buf, 0, buf.Length); if (n == 0) throw new IOException ("DWP Handshake failed."); for (int i = 0; i < buf.Length; ++i) cbuf [i] = (char)buf [i]; if (new String (cbuf) != HANDSHAKE_STRING) throw new IOException ("DWP Handshake failed."); TransportSend (buf, 0, buf.Length); receiver_thread = new Thread (new ThreadStart (receiver_thread_main)); receiver_thread.Name = "SDB Receiver"; receiver_thread.IsBackground = true; receiver_thread.Start (); Version = VM_GetVersion (); // // Tell the debuggee our protocol version, so newer debuggees can work // with older clients // // // Older debuggees might not support this request EventHandler<ErrorHandlerEventArgs> OrigErrorHandler = ErrorHandler; ErrorHandler = null; ErrorHandler += delegate (object sender, ErrorHandlerEventArgs args) { throw new NotSupportedException (); }; try { VM_SetProtocolVersion (MAJOR_VERSION, MINOR_VERSION); } catch (NotSupportedException) { } ErrorHandler = OrigErrorHandler; }
/* * Implementation of debugger commands */ internal VersionInfo VM_GetVersion() { var res = SendReceive (CommandSet.VM, (int)CmdVM.VERSION, null); VersionInfo info = new VersionInfo (); info.VMVersion = res.ReadString (); info.MajorVersion = res.ReadInt (); info.MinorVersion = res.ReadInt (); return info; }