Added tests for Task.WhenAll w/ empty list
[mono.git] / mcs / class / Mono.Debugger.Soft / Mono.Debugger.Soft / VirtualMachine.cs
1 using System;
2 using System.IO;
3 using System.Threading;
4 using System.Net;
5 using System.Diagnostics;
6 using System.Collections;
7 using System.Collections.Generic;
8 using Mono.Cecil.Metadata;
9
10 namespace Mono.Debugger.Soft
11 {
12         public class VirtualMachine : Mirror
13         {
14                 Queue queue;
15                 object queue_monitor;
16                 object startup_monitor;
17                 AppDomainMirror root_domain;
18                 Dictionary<int, EventRequest> requests;
19                 ITargetProcess process;
20
21                 internal Connection conn;
22
23                 VersionInfo version;
24
25                 internal VirtualMachine (ITargetProcess process, Connection conn) : base () {
26                         SetVirtualMachine (this);
27                         queue = new Queue ();
28                         queue_monitor = new Object ();
29                         startup_monitor = new Object ();
30                         requests = new Dictionary <int, EventRequest> ();
31                         this.conn = conn;
32                         this.process = process;
33                         conn.ErrorHandler += ErrorHandler;
34                 }
35
36                 // The standard output of the process is available normally through Process
37                 public StreamReader StandardOutput { get; set; }
38                 public StreamReader StandardError { get; set; }
39
40                 
41                 public Process Process {
42                         get {
43                                 ProcessWrapper pw = process as ProcessWrapper;
44                                 if (pw == null)
45                                     throw new InvalidOperationException ("Process instance not available");
46                                 return pw.Process;
47                         }
48                 }
49
50                 public ITargetProcess TargetProcess {
51                         get {
52                                 return process;
53                         }
54                 }
55
56                 public AppDomainMirror RootDomain {
57                         get {
58                                 return root_domain;
59                         }
60             }
61
62                 public EndPoint EndPoint {
63                         get {
64                                 var tcpConn = conn as TcpConnection;
65                                 if (tcpConn != null)
66                                         return tcpConn.EndPoint;
67                                 return null;
68                         }
69                 }
70
71                 public VersionInfo Version {
72                         get {
73                                 return version;
74                         }
75                 }
76
77                 EventSet current_es;
78                 int current_es_index;
79
80                 /*
81                  * It is impossible to determine when to resume when using this method, since
82                  * the debuggee is suspended only once per event-set, not event.
83                  */
84                 [Obsolete ("Use GetNextEventSet () instead")]
85                 public Event GetNextEvent () {
86                         lock (queue_monitor) {
87                                 if (current_es == null || current_es_index == current_es.Events.Length) {
88                                         if (queue.Count == 0)
89                                                 Monitor.Wait (queue_monitor);
90                                         current_es = (EventSet)queue.Dequeue ();
91                                         current_es_index = 0;
92                                 }
93                                 return current_es.Events [current_es_index ++];
94                         }
95                 }
96
97                 public Event GetNextEvent (int timeout) {
98                         throw new NotImplementedException ();
99                 }
100
101                 public EventSet GetNextEventSet () {
102                         lock (queue_monitor) {
103                                 if (queue.Count == 0)
104                                         Monitor.Wait (queue_monitor);
105
106                                 current_es = null;
107                                 current_es_index = 0;
108
109                                 return (EventSet)queue.Dequeue ();
110                         }
111                 }
112
113                 [Obsolete ("Use GetNextEventSet () instead")]
114                 public T GetNextEvent<T> () where T : Event {
115                         return GetNextEvent () as T;
116                 }
117
118                 public void Suspend () {
119                         conn.VM_Suspend ();
120             }
121
122                 public void Resume () {
123                         try {
124                                 conn.VM_Resume ();
125                         } catch (CommandException ex) {
126                                 if (ex.ErrorCode == ErrorCode.NOT_SUSPENDED)
127                                         throw new InvalidOperationException ("The vm is not suspended.");
128                                 else
129                                         throw;
130                         }
131             }
132
133                 public void Exit (int exitCode) {
134                         conn.VM_Exit (exitCode);
135                 }
136
137                 public void Detach () {
138                         conn.VM_Dispose ();
139                         conn.Close ();
140                         notify_vm_event (EventType.VMDisconnect, SuspendPolicy.None, 0, 0, null);
141                 }
142
143                 [Obsolete ("This method was poorly named; use the Detach() method instead")]
144                 public void Dispose ()
145                 {
146                         Detach ();
147                 }
148
149                 public void ForceDisconnect ()
150                 {
151                         conn.ForceDisconnect ();
152                 }
153
154                 public IList<ThreadMirror> GetThreads () {
155                         long[] ids = vm.conn.VM_GetThreads ();
156                         ThreadMirror[] res = new ThreadMirror [ids.Length];
157                         for (int i = 0; i < ids.Length; ++i)
158                                 res [i] = GetThread (ids [i]);
159                         return res;
160                 }
161
162                 // Same as the mirrorOf methods in JDI
163                 public PrimitiveValue CreateValue (object value) {
164                         if (value == null)
165                                 return new PrimitiveValue (vm, null);
166
167                         if (!value.GetType ().IsPrimitive)
168                                 throw new ArgumentException ("value must be of a primitive type instead of '" + value.GetType () + "'", "value");
169
170                         return new PrimitiveValue (vm, value);
171                 }
172
173                 public EnumMirror CreateEnumMirror (TypeMirror type, PrimitiveValue value) {
174                         return new EnumMirror (this, type, value);
175                 }
176
177                 //
178                 // Enable send and receive timeouts on the connection and send a keepalive event
179                 // every 'keepalive_interval' milliseconds.
180                 //
181
182                 public void SetSocketTimeouts (int send_timeout, int receive_timeout, int keepalive_interval)
183                 {
184                         conn.SetSocketTimeouts (send_timeout, receive_timeout, keepalive_interval);
185                 }
186
187                 //
188                 // Methods to create event request objects
189                 //
190                 public BreakpointEventRequest CreateBreakpointRequest (MethodMirror method, long il_offset) {
191                         return new BreakpointEventRequest (this, method, il_offset);
192                 }
193
194                 public BreakpointEventRequest CreateBreakpointRequest (Location loc) {
195                         if (loc == null)
196                                 throw new ArgumentNullException ("loc");
197                         CheckMirror (loc);
198                         return new BreakpointEventRequest (this, loc.Method, loc.ILOffset);
199                 }
200
201                 public StepEventRequest CreateStepRequest (ThreadMirror thread) {
202                         return new StepEventRequest (this, thread);
203                 }
204
205                 public MethodEntryEventRequest CreateMethodEntryRequest () {
206                         return new MethodEntryEventRequest (this);
207                 }
208
209                 public MethodExitEventRequest CreateMethodExitRequest () {
210                         return new MethodExitEventRequest (this);
211                 }
212
213                 public ExceptionEventRequest CreateExceptionRequest (TypeMirror exc_type) {
214                         return new ExceptionEventRequest (this, exc_type, true, true);
215                 }
216
217                 public ExceptionEventRequest CreateExceptionRequest (TypeMirror exc_type, bool caught, bool uncaught) {
218                         return new ExceptionEventRequest (this, exc_type, caught, uncaught);
219                 }
220
221                 public AssemblyLoadEventRequest CreateAssemblyLoadRequest () {
222                         return new AssemblyLoadEventRequest (this);
223                 }
224
225                 public TypeLoadEventRequest CreateTypeLoadRequest () {
226                         return new TypeLoadEventRequest (this);
227                 }
228
229                 public void EnableEvents (params EventType[] events) {
230                         foreach (EventType etype in events) {
231                                 if (etype == EventType.Breakpoint)
232                                         throw new ArgumentException ("Breakpoint events cannot be requested using EnableEvents", "events");
233                                 conn.EnableEvent (etype, SuspendPolicy.All, null);
234                         }
235                 }
236
237                 public BreakpointEventRequest SetBreakpoint (MethodMirror method, long il_offset) {
238                         BreakpointEventRequest req = CreateBreakpointRequest (method, il_offset);
239
240                         req.Enable ();
241
242                         return req;
243                 }
244
245                 public void ClearAllBreakpoints () {
246                         conn.ClearAllBreakpoints ();
247                 }
248                 
249                 public void Disconnect () {
250                         conn.Close ();
251                 }
252
253                 //
254                 // Return a list of TypeMirror objects for all loaded types which reference the
255                 // source file FNAME. Might return false positives.
256                 // Since protocol version 2.7.
257                 //
258                 public IList<TypeMirror> GetTypesForSourceFile (string fname, bool ignoreCase) {
259                         long[] ids = conn.VM_GetTypesForSourceFile (fname, ignoreCase);
260                         var res = new TypeMirror [ids.Length];
261                         for (int i = 0; i < ids.Length; ++i)
262                                 res [i] = GetType (ids [i]);
263                         return res;
264                 }
265
266                 //
267                 // Return a list of TypeMirror objects for all loaded types named 'NAME'.
268                 // NAME should be in the the same for as with Assembly.GetType ().
269                 // Since protocol version 2.9.
270                 //
271                 public IList<TypeMirror> GetTypes (string name, bool ignoreCase) {
272                         long[] ids = conn.VM_GetTypes (name, ignoreCase);
273                         var res = new TypeMirror [ids.Length];
274                         for (int i = 0; i < ids.Length; ++i)
275                                 res [i] = GetType (ids [i]);
276                         return res;
277                 }
278                 
279                 internal void queue_event_set (EventSet es) {
280                         lock (queue_monitor) {
281                                 queue.Enqueue (es);
282                                 Monitor.Pulse (queue_monitor);
283                         }
284                 }
285
286                 internal void ErrorHandler (object sender, ErrorHandlerEventArgs args) {
287                         switch (args.ErrorCode) {
288                         case ErrorCode.INVALID_OBJECT:
289                                 throw new ObjectCollectedException ();
290                         case ErrorCode.INVALID_FRAMEID:
291                                 throw new InvalidStackFrameException ();
292                         case ErrorCode.NOT_SUSPENDED:
293                                 throw new InvalidOperationException ("The vm is not suspended.");
294                         case ErrorCode.NOT_IMPLEMENTED:
295                                 throw new NotSupportedException ("This request is not supported by the protocol version implemented by the debuggee.");
296                         case ErrorCode.ABSENT_INFORMATION:
297                                 throw new AbsentInformationException ();
298                         case ErrorCode.NO_SEQ_POINT_AT_IL_OFFSET:
299                                 throw new ArgumentException ("Cannot set breakpoint on the specified IL offset.");
300                         default:
301                                 throw new CommandException (args.ErrorCode);
302                         }
303                 }
304
305                 /* Wait for the debuggee to start up and connect to it */
306                 internal void connect () {
307                         conn.Connect ();
308
309                         // Test the connection
310                         version = conn.Version;
311                         if (version.MajorVersion != Connection.MAJOR_VERSION)
312                                 throw new NotSupportedException (String.Format ("The debuggee implements protocol version {0}.{1}, while {2}.{3} is required.", version.MajorVersion, version.MinorVersion, Connection.MAJOR_VERSION, Connection.MINOR_VERSION));
313
314                         long root_domain_id = conn.RootDomain;
315                         root_domain = GetDomain (root_domain_id);
316                 }
317
318                 internal void notify_vm_event (EventType evtype, SuspendPolicy spolicy, int req_id, long thread_id, string vm_uri) {
319                         //Console.WriteLine ("Event: " + evtype + "(" + vm_uri + ")");
320
321                         switch (evtype) {
322                         case EventType.VMStart:
323                                 /* Notify the main thread that the debuggee started up */
324                                 lock (startup_monitor) {
325                                         Monitor.Pulse (startup_monitor);
326                                 }
327                                 queue_event_set (new EventSet (this, spolicy, new Event[] { new VMStartEvent (vm, req_id, thread_id) }));
328                                 break;
329                         case EventType.VMDeath:
330                                 queue_event_set (new EventSet (this, spolicy, new Event[] { new VMDeathEvent (vm, req_id) }));
331                                 break;
332                         case EventType.VMDisconnect:
333                                 queue_event_set (new EventSet (this, spolicy, new Event[] { new VMDisconnectEvent (vm, req_id) }));
334                                 break;
335                         default:
336                                 throw new Exception ();
337                         }
338                 }
339
340                 //
341                 // Methods to create instances of mirror objects
342                 //
343
344                 /*
345                 class MirrorCache<T> {
346                         static Dictionary <long, T> mirrors;
347                         static object mirror_lock = new object ();
348
349                         internal static T GetMirror (VirtualMachine vm, long id) {
350                                 lock (mirror_lock) {
351                                 if (mirrors == null)
352                                         mirrors = new Dictionary <long, T> ();
353                                 T obj;
354                                 if (!mirrors.TryGetValue (id, out obj)) {
355                                         obj = CreateMirror (vm, id);
356                                         mirrors [id] = obj;
357                                 }
358                                 return obj;
359                                 }
360                         }
361
362                         internal static T CreateMirror (VirtualMachine vm, long id) {
363                         }
364                 }
365                 */
366
367                 // FIXME: When to remove items from the cache ?
368
369                 Dictionary <long, MethodMirror> methods;
370                 object methods_lock = new object ();
371
372                 internal MethodMirror GetMethod (long id) {
373                         lock (methods_lock) {
374                                 if (methods == null)
375                                         methods = new Dictionary <long, MethodMirror> ();
376                                 MethodMirror obj;
377                                 if (id == 0)
378                                         return null;
379                                 if (!methods.TryGetValue (id, out obj)) {
380                                         obj = new MethodMirror (this, id);
381                                         methods [id] = obj;
382                                 }
383                                 return obj;
384                         }
385             }
386
387                 Dictionary <long, AssemblyMirror> assemblies;
388                 object assemblies_lock = new object ();
389
390                 internal AssemblyMirror GetAssembly (long id) {
391                         lock (assemblies_lock) {
392                                 if (assemblies == null)
393                                         assemblies = new Dictionary <long, AssemblyMirror> ();
394                                 AssemblyMirror obj;
395                                 if (id == 0)
396                                         return null;
397                                 if (!assemblies.TryGetValue (id, out obj)) {
398                                         obj = new AssemblyMirror (this, id);
399                                         assemblies [id] = obj;
400                                 }
401                                 return obj;
402                         }
403             }
404
405                 Dictionary <long, ModuleMirror> modules;
406                 object modules_lock = new object ();
407
408                 internal ModuleMirror GetModule (long id) {
409                         lock (modules_lock) {
410                                 if (modules == null)
411                                         modules = new Dictionary <long, ModuleMirror> ();
412                                 ModuleMirror obj;
413                                 if (id == 0)
414                                         return null;
415                                 if (!modules.TryGetValue (id, out obj)) {
416                                         obj = new ModuleMirror (this, id);
417                                         modules [id] = obj;
418                                 }
419                                 return obj;
420                         }
421             }
422
423                 Dictionary <long, AppDomainMirror> domains;
424                 object domains_lock = new object ();
425
426                 internal AppDomainMirror GetDomain (long id) {
427                         lock (domains_lock) {
428                                 if (domains == null)
429                                         domains = new Dictionary <long, AppDomainMirror> ();
430                                 AppDomainMirror obj;
431                                 if (id == 0)
432                                         return null;
433                                 if (!domains.TryGetValue (id, out obj)) {
434                                         obj = new AppDomainMirror (this, id);
435                                         domains [id] = obj;
436                                 }
437                                 return obj;
438                         }
439             }
440
441                 Dictionary <long, TypeMirror> types;
442                 object types_lock = new object ();
443
444                 internal TypeMirror GetType (long id) {
445                         lock (types_lock) {
446                                 if (types == null)
447                                         types = new Dictionary <long, TypeMirror> ();
448                                 TypeMirror obj;
449                                 if (id == 0)
450                                         return null;
451                                 if (!types.TryGetValue (id, out obj)) {
452                                         obj = new TypeMirror (this, id);
453                                         types [id] = obj;
454                                 }
455                                 return obj;
456                         }
457             }
458
459                 internal TypeMirror[] GetTypes (long[] ids) {
460                         var res = new TypeMirror [ids.Length];
461                         for (int i = 0; i < ids.Length; ++i)
462                                 res [i] = GetType (ids [i]);
463                         return res;
464                 }
465
466                 Dictionary <long, ObjectMirror> objects;
467                 object objects_lock = new object ();
468
469                 internal T GetObject<T> (long id, long domain_id, long type_id) where T : ObjectMirror {
470                         lock (objects_lock) {
471                                 if (objects == null)
472                                         objects = new Dictionary <long, ObjectMirror> ();
473                                 ObjectMirror obj;
474                                 if (!objects.TryGetValue (id, out obj)) {
475                                         /*
476                                          * Obtain the domain/type of the object to determine the type of
477                                          * object we need to create.
478                                          */
479                                         if (domain_id == 0 || type_id == 0) {
480                                                 if (conn.Version.AtLeast (2, 5)) {
481                                                         var info = conn.Object_GetInfo (id);
482                                                         domain_id = info.domain_id;
483                                                         type_id = info.type_id;
484                                                 } else {
485                                                         if (domain_id == 0)
486                                                                 domain_id = conn.Object_GetDomain (id);
487                                                         if (type_id == 0)
488                                                                 type_id = conn.Object_GetType (id);
489                                                 }
490                                         }
491                                         AppDomainMirror d = GetDomain (domain_id);
492                                         TypeMirror t = GetType (type_id);
493
494                                         if (t.Assembly == d.Corlib && t.Namespace == "System.Threading" && t.Name == "Thread")
495                                                 obj = new ThreadMirror (this, id, t, d);
496                                         else if (t.Assembly == d.Corlib && t.Namespace == "System" && t.Name == "String")
497                                                 obj = new StringMirror (this, id, t, d);
498                                         else if (typeof (T) == typeof (ArrayMirror))
499                                                 obj = new ArrayMirror (this, id, t, d);
500                                         else
501                                                 obj = new ObjectMirror (this, id, t, d);
502                                         objects [id] = obj;
503                                 }
504                                 return (T)obj;
505                         }
506             }
507
508                 internal T GetObject<T> (long id) where T : ObjectMirror {
509                         return GetObject<T> (id, 0, 0);
510                 }
511
512                 internal ObjectMirror GetObject (long objid) {
513                         return GetObject<ObjectMirror> (objid);
514                 }
515
516                 internal ThreadMirror GetThread (long id) {
517                         return GetObject <ThreadMirror> (id);
518                 }
519
520                 object requests_lock = new object ();
521
522                 internal void AddRequest (EventRequest req, int id) {
523                         lock (requests_lock) {
524                                 requests [id] = req;
525                         }
526                 }
527
528                 internal void RemoveRequest (EventRequest req, int id) {
529                         lock (requests_lock) {
530                                 requests.Remove (id);
531                         }
532                 }
533
534                 internal EventRequest GetRequest (int id) {
535                         lock (requests_lock) {
536                                 return requests [id];
537                         }
538                 }
539
540                 internal Value DecodeValue (ValueImpl v) {
541                         if (v.Value != null)
542                                 return new PrimitiveValue (this, v.Value);
543
544                         switch (v.Type) {
545                         case ElementType.Void:
546                                 return null;
547                         case ElementType.SzArray:
548                         case ElementType.Array:
549                                 return GetObject<ArrayMirror> (v.Objid);
550                         case ElementType.String:
551                                 return GetObject<StringMirror> (v.Objid);
552                         case ElementType.Class:
553                         case ElementType.Object:
554                                 return GetObject (v.Objid);
555                         case ElementType.ValueType:
556                                 if (v.IsEnum)
557                                         return new EnumMirror (this, GetType (v.Klass), DecodeValues (v.Fields));
558                                 else
559                                         return new StructMirror (this, GetType (v.Klass), DecodeValues (v.Fields));
560                         case (ElementType)ValueTypeId.VALUE_TYPE_ID_NULL:
561                                 return new PrimitiveValue (this, null);
562                         default:
563                                 throw new NotImplementedException ("" + v.Type);
564                         }
565                 }
566
567                 internal Value[] DecodeValues (ValueImpl[] values) {
568                         Value[] res = new Value [values.Length];
569                         for (int i = 0; i < values.Length; ++i)
570                                 res [i] = DecodeValue (values [i]);
571                         return res;
572                 }
573
574                 internal ValueImpl EncodeValue (Value v) {
575                         if (v is PrimitiveValue) {
576                                 object val = (v as PrimitiveValue).Value;
577                                 if (val == null)
578                                         return new ValueImpl { Type = (ElementType)ValueTypeId.VALUE_TYPE_ID_NULL, Objid = 0 };
579                                 else
580                                         return new ValueImpl { Value = val };
581                         } else if (v is ObjectMirror) {
582                                 return new ValueImpl { Type = ElementType.Object, Objid = (v as ObjectMirror).Id };
583                         } else if (v is StructMirror) {
584                                 return new ValueImpl { Type = ElementType.ValueType, Klass = (v as StructMirror).Type.Id, Fields = EncodeValues ((v as StructMirror).Fields) };
585                         } else {
586                                 throw new NotSupportedException ();
587                         }
588                 }
589
590                 internal ValueImpl[] EncodeValues (IList<Value> values) {
591                         ValueImpl[] res = new ValueImpl [values.Count];
592                         for (int i = 0; i < values.Count; ++i)
593                                 res [i] = EncodeValue (values [i]);
594                         return res;
595                 }
596
597                 internal void CheckProtocolVersion (int major, int minor) {
598                         if (!conn.Version.AtLeast (major, minor))
599                                 throw new NotSupportedException ("This request is not supported by the protocol version implemented by the debuggee.");
600                 }
601     }
602
603         class EventHandler : MarshalByRefObject, IEventHandler
604         {               
605                 VirtualMachine vm;
606
607                 public EventHandler (VirtualMachine vm) {
608                         this.vm = vm;
609                 }
610
611                 public void Events (SuspendPolicy suspend_policy, EventInfo[] events) {
612                         var l = new List<Event> ();
613
614                         for (int i = 0; i < events.Length; ++i) {
615                                 EventInfo ei = events [i];
616                                 int req_id = ei.ReqId;
617                                 long thread_id = ei.ThreadId;
618                                 long id = ei.Id;
619                                 long loc = ei.Location;
620
621                                 switch (ei.EventType) {
622                                 case EventType.VMStart:
623                                         vm.notify_vm_event (EventType.VMStart, suspend_policy, req_id, thread_id, null);
624                                         break;
625                                 case EventType.VMDeath:
626                                         vm.notify_vm_event (EventType.VMDeath, suspend_policy, req_id, thread_id, null);
627                                         break;
628                                 case EventType.ThreadStart:
629                                         l.Add (new ThreadStartEvent (vm, req_id, id));
630                                         break;
631                                 case EventType.ThreadDeath:
632                                         l.Add (new ThreadDeathEvent (vm, req_id, id));
633                                         break;
634                                 case EventType.AssemblyLoad:
635                                         l.Add (new AssemblyLoadEvent (vm, req_id, thread_id, id));
636                                         break;
637                                 case EventType.AssemblyUnload:
638                                         l.Add (new AssemblyUnloadEvent (vm, req_id, thread_id, id));
639                                         break;
640                                 case EventType.TypeLoad:
641                                         l.Add (new TypeLoadEvent (vm, req_id, thread_id, id));
642                                         break;
643                                 case EventType.MethodEntry:
644                                         l.Add (new MethodEntryEvent (vm, req_id, thread_id, id));
645                                         break;
646                                 case EventType.MethodExit:
647                                         l.Add (new MethodExitEvent (vm, req_id, thread_id, id));
648                                         break;
649                                 case EventType.Breakpoint:
650                                         l.Add (new BreakpointEvent (vm, req_id, thread_id, id, loc));
651                                         break;
652                                 case EventType.Step:
653                                         l.Add (new StepEvent (vm, req_id, thread_id, id, loc));
654                                         break;
655                                 case EventType.Exception:
656                                         l.Add (new ExceptionEvent (vm, req_id, thread_id, id, loc));
657                                         break;
658                                 case EventType.AppDomainCreate:
659                                         l.Add (new AppDomainCreateEvent (vm, req_id, thread_id, id));
660                                         break;
661                                 case EventType.AppDomainUnload:
662                                         l.Add (new AppDomainUnloadEvent (vm, req_id, thread_id, id));
663                                         break;
664                                 case EventType.UserBreak:
665                                         l.Add (new UserBreakEvent (vm, req_id, thread_id));
666                                         break;
667                                 case EventType.UserLog:
668                                         l.Add (new UserLogEvent (vm, req_id, thread_id, ei.Level, ei.Category, ei.Message));
669                                         break;
670                                 default:
671                                         break;
672                                 }
673                         }
674                         
675                         if (l.Count > 0)
676                                 vm.queue_event_set (new EventSet (vm, suspend_policy, l.ToArray ()));
677                 }
678
679                 public void VMDisconnect (int req_id, long thread_id, string vm_uri) {
680                         vm.notify_vm_event (EventType.VMDisconnect, SuspendPolicy.None, req_id, thread_id, vm_uri);
681         }
682     }
683
684         public class CommandException : Exception {
685
686                 internal CommandException (ErrorCode error_code) : base ("Debuggee returned error code " + error_code + ".") {
687                         ErrorCode = error_code;
688                 }
689
690                 public ErrorCode ErrorCode {
691                         get; set;
692                 }
693         }
694 }