Merge pull request #1949 from lewurm/fixtype
[mono.git] / mcs / class / Mono.Debugger.Soft / Mono.Debugger.Soft / Connection.cs
index 5350491dc0be8e5288cf2915ef9e765049223ac9..05ea6bcdaf44aa4a2714b2c8758767164ffb0170 100644 (file)
@@ -382,7 +382,8 @@ namespace Mono.Debugger.Soft
                ERR_UNLOADED = 103,
                ERR_NO_INVOCATION = 104,
                ABSENT_INFORMATION = 105,
-               NO_SEQ_POINT_AT_IL_OFFSET = 106
+               NO_SEQ_POINT_AT_IL_OFFSET = 106,
+               INVOKE_ABORTED = 107
        }
 
        public class ErrorHandlerEventArgs : EventArgs {
@@ -417,7 +418,7 @@ namespace Mono.Debugger.Soft
                 * with newer runtimes, and vice versa.
                 */
                internal const int MAJOR_VERSION = 2;
-               internal const int MINOR_VERSION = 39;
+               internal const int MINOR_VERSION = 42;
 
                enum WPSuspendPolicy {
                        NONE = 0,
@@ -801,6 +802,13 @@ namespace Mono.Debugger.Soft
                                return res;
                        }
 
+                       public string ReadUTF16String () {
+                               int len = decode_int (packet, ref offset);
+                               string res = new String (Encoding.Unicode.GetChars (packet, offset, len));
+                               offset += len;
+                               return res;
+                       }
+
                        public ValueImpl ReadValue () {
                                ElementType etype = (ElementType)ReadByte ();
 
@@ -1216,6 +1224,8 @@ namespace Mono.Debugger.Soft
 
                bool disconnected;
 
+               internal ManualResetEvent DisconnectedEvent = new ManualResetEvent (false);
+
                void receiver_thread_main () {
                        while (!closed) {
                                try {
@@ -1232,6 +1242,7 @@ namespace Mono.Debugger.Soft
 
                        lock (reply_packets_monitor) {
                                disconnected = true;
+                               DisconnectedEvent.Set ();
                                Monitor.PulseAll (reply_packets_monitor);
                                TransportClose ();
                        }
@@ -1635,13 +1646,14 @@ namespace Mono.Debugger.Soft
                        SendReceive (CommandSet.VM, (int)CmdVM.SET_PROTOCOL_VERSION, new PacketWriter ().WriteInt (major).WriteInt (minor));
                }
 
-               internal long[] VM_GetThreads () {
-                       var res = SendReceive (CommandSet.VM, (int)CmdVM.ALL_THREADS, null);
-                       int len = res.ReadInt ();
-                       long[] arr = new long [len];
-                       for (int i = 0; i < len; ++i)
-                               arr [i] = res.ReadId ();
-                       return arr;
+               internal void VM_GetThreads (Action<long[]> resultCallaback) {
+                       Send (CommandSet.VM, (int)CmdVM.ALL_THREADS, null, (res) => {
+                               int len = res.ReadInt ();
+                               long[] arr = new long [len];
+                               for (int i = 0; i < len; ++i)
+                                       arr [i] = res.ReadId ();
+                               resultCallaback(arr);
+                       }, 1);
                }
 
                internal void VM_Suspend () {
@@ -2414,7 +2426,16 @@ namespace Mono.Debugger.Soft
                 * STRINGS
                 */
                internal string String_GetValue (long id) {
-                       return SendReceive (CommandSet.STRING_REF, (int)CmdStringRef.GET_VALUE, new PacketWriter ().WriteId (id)).ReadString ();
+                       var r = SendReceive (CommandSet.STRING_REF, (int)CmdStringRef.GET_VALUE, new PacketWriter ().WriteId (id));
+
+                       bool is_utf16 = false;
+                       if (Version.AtLeast (2, 41))
+                               is_utf16 = r.ReadByte () == 1;
+
+                       if (is_utf16)
+                               return r.ReadUTF16String ();
+                       else
+                               return r.ReadString ();
                }                       
 
                internal int String_GetLength (long id) {
@@ -2475,6 +2496,7 @@ namespace Mono.Debugger.Soft
                {
                        closed = true;
                        disconnected = true;
+                       DisconnectedEvent.Set ();
                        TransportClose ();
                }
        }