4 using System.Net.Sockets;
5 using System.Threading;
6 using System.Collections.Generic;
8 using Mono.Cecil.Metadata;
10 namespace Mono.Debugger.Soft
13 public string VMVersion {
17 public int MajorVersion {
21 public int MinorVersion {
27 public int max_il_offset;
28 public string filename;
29 public int[] il_offsets;
30 public int[] line_numbers;
37 public StackFrameFlags flags;
41 public string ns, name, full_name;
42 public long assembly, module, base_type, element_type;
43 public int token, rank, attributes;
44 public bool is_byref, is_pointer, is_primitive, is_valuetype, is_enum;
49 public int attributes, iattributes, token;
52 class MethodBodyInfo {
58 public int param_count;
59 public int generic_param_count;
61 public long[] param_types;
62 public string[] param_names;
67 public string[] names;
68 public int[] live_range_start;
69 public int[] live_range_end;
75 public long get_method, set_method;
79 class CattrNamedArgInfo {
80 public bool is_property;
82 public ValueImpl value;
87 public ValueImpl[] ctor_args;
88 public CattrNamedArgInfo[] named_args;
92 public bool is_thread_pool;
96 VALUE_TYPE_ID_NULL = 0xf0,
97 VALUE_TYPE_ID_TYPE = 0xf1
102 DISABLE_BREAKPOINTS = 0x1,
103 SINGLE_THREADED = 0x2
107 public ElementType Type; /* or one of the VALUE_TYPE_ID constants */
110 public long Klass; // For ElementType.ValueType
111 public ValueImpl[] Fields; // for ElementType.ValueType
112 public bool IsEnum; // For ElementType.ValueType
113 public long Id; /* For VALUE_TYPE_ID_TYPE */
117 public string Name, ScopeName, FQName, Guid;
118 public long Assembly;
129 enum StackFrameFlags {
133 class ResolvedToken {
134 public TokenType Type;
142 class CountModifier : Modifier {
148 class LocationModifier : Modifier {
153 public long Location {
158 class StepModifier : Modifier {
172 class ThreadModifier : Modifier {
178 class ExceptionModifier : Modifier {
185 public bool Uncaught {
190 class AssemblyModifier : Modifier {
191 public long[] Assemblies {
196 public enum ErrorCode {
199 INVALID_FIELDID = 25,
200 INVALID_FRAMEID = 30,
201 NOT_IMPLEMENTED = 100,
203 INVALID_ARGUMENT = 102,
205 ERR_NO_INVOCATION = 104
208 public class ErrorHandlerEventArgs : EventArgs {
210 public ErrorCode ErrorCode {
216 * Represents the connection to the debuggee
221 * The protocol and the packet format is based on JDWP, the differences
222 * are in the set of supported events, and the commands.
224 public const string HANDSHAKE_STRING = "DWP-Handshake";
226 public const int HEADER_LENGTH = 11;
229 * Th version of the wire-protocol implemented by the library. The library
230 * and the debuggee can communicate if they implement the same major version.
231 * If they implement a different minor version, they can communicate, but some
232 * features might not be available. This allows older clients to communicate
233 * with newer runtimes, and vice versa.
235 public const int MAJOR_VERSION = 2;
236 public const int MINOR_VERSION = 1;
238 enum WPSuspendPolicy {
265 APPDOMAIN_CREATE = 4, // Not in JDI
266 APPDOMAIN_UNLOAD = 5, // Not in JDI
294 SET_PROTOCOL_VERSION = 8,
307 /* FIXME: Merge into GET_INFO when the major protocol version is increased */
311 enum CmdEventRequest {
314 CLEAR_ALL_BREAKPOINTS = 3
319 GET_FRIENDLY_NAME = 2,
321 GET_ENTRY_ASSEMBLY = 4,
324 CREATE_BOXED_VALUE = 7
330 GET_MANIFEST_MODULE = 3,
342 GET_DECLARING_TYPE = 2,
357 GET_SOURCE_FILES = 6,
359 IS_ASSIGNABLE_FROM = 8,
362 GET_FIELD_CATTRS = 11,
363 GET_PROPERTY_CATTRS = 12
393 public int command_set;
398 public static int GetPacketLength (byte[] header) {
400 return decode_int (header, ref offset);
403 public static bool IsReplyPacket (byte[] packet) {
405 return decode_byte (packet, ref offset) == 0x80;
408 public static int GetPacketId (byte[] packet) {
410 return decode_int (packet, ref offset);
413 static int decode_byte (byte[] packet, ref int offset) {
414 return packet [offset++];
417 static int decode_short (byte[] packet, ref int offset) {
418 int res = ((int)packet [offset] << 8) | (int)packet [offset + 1];
423 static int decode_int (byte[] packet, ref int offset) {
424 int res = ((int)packet [offset] << 24) | ((int)packet [offset + 1] << 16) | ((int)packet [offset + 2] << 8) | (int)packet [offset + 3];
429 static long decode_id (byte[] packet, ref int offset) {
430 return decode_int (packet, ref offset);
433 static long decode_long (byte[] packet, ref int offset) {
434 uint high = (uint)decode_int (packet, ref offset);
435 uint low = (uint)decode_int (packet, ref offset);
437 return (long)(((ulong)high << 32) | (ulong)low);
440 public static SuspendPolicy decode_suspend_policy (int suspend_policy) {
441 switch ((WPSuspendPolicy)suspend_policy) {
442 case WPSuspendPolicy.NONE:
443 return SuspendPolicy.None;
444 case WPSuspendPolicy.EVENT_THREAD:
445 return SuspendPolicy.EventThread;
446 case WPSuspendPolicy.ALL:
447 return SuspendPolicy.All;
449 throw new NotImplementedException ();
453 static Header decode_command_header (byte[] packet) {
455 Header res = new Header ();
457 decode_int (packet, ref offset);
458 res.id = decode_int (packet, ref offset);
459 res.flags = decode_byte (packet, ref offset);
460 res.command_set = decode_byte (packet, ref offset);
461 res.command = decode_byte (packet, ref offset);
466 static void encode_byte (byte[] buf, int b, ref int offset) {
467 buf [offset] = (byte)b;
471 static void encode_int (byte[] buf, int i, ref int offset) {
472 buf [offset] = (byte)((i >> 24) & 0xff);
473 buf [offset + 1] = (byte)((i >> 16) & 0xff);
474 buf [offset + 2] = (byte)((i >> 8) & 0xff);
475 buf [offset + 3] = (byte)((i >> 0) & 0xff);
479 static void encode_id (byte[] buf, long id, ref int offset) {
480 encode_int (buf, (int)id, ref offset);
483 static void encode_long (byte[] buf, long l, ref int offset) {
484 encode_int (buf, (int)((l >> 32) & 0xffffffff), ref offset);
485 encode_int (buf, (int)(l & 0xffffffff), ref offset);
488 public static byte[] EncodePacket (int id, int commandSet, int command, byte[] data, int dataLen) {
489 byte[] buf = new byte [dataLen + 11];
492 encode_int (buf, buf.Length, ref offset);
493 encode_int (buf, id, ref offset);
494 encode_byte (buf, 0, ref offset);
495 encode_byte (buf, commandSet, ref offset);
496 encode_byte (buf, command, ref offset);
498 for (int i = 0; i < dataLen; ++i)
499 buf [offset + i] = data [i];
508 public PacketReader (byte[] packet) {
509 this.packet = packet;
512 Header header = decode_command_header (packet);
513 CommandSet = (CommandSet)header.command_set;
514 Command = header.command;
518 ReadInt (); // length
520 ReadByte (); // flags
521 ErrorCode = ReadShort ();
524 public CommandSet CommandSet {
532 public int ErrorCode {
542 public int ReadByte () {
543 return decode_byte (packet, ref offset);
546 public int ReadShort () {
547 return decode_short (packet, ref offset);
550 public int ReadInt () {
551 return decode_int (packet, ref offset);
554 public long ReadId () {
555 return decode_id (packet, ref offset);
558 public long ReadLong () {
559 return decode_long (packet, ref offset);
562 public float ReadFloat () {
563 float f = DataConverter.FloatFromBE (packet, offset);
568 public double ReadDouble () {
569 double d = DataConverter.DoubleFromBE (packet, offset);
574 public string ReadString () {
575 int len = decode_int (packet, ref offset);
576 string res = new String (Encoding.UTF8.GetChars (packet, offset, len));
581 public ValueImpl ReadValue () {
582 ElementType etype = (ElementType)ReadByte ();
585 case ElementType.Void:
586 return new ValueImpl { Type = etype };
588 return new ValueImpl { Type = etype, Value = (sbyte)ReadInt () };
590 return new ValueImpl { Type = etype, Value = (byte)ReadInt () };
591 case ElementType.Boolean:
592 return new ValueImpl { Type = etype, Value = ReadInt () != 0 };
594 return new ValueImpl { Type = etype, Value = (short)ReadInt () };
596 return new ValueImpl { Type = etype, Value = (ushort)ReadInt () };
597 case ElementType.Char:
598 return new ValueImpl { Type = etype, Value = (char)ReadInt () };
600 return new ValueImpl { Type = etype, Value = ReadInt () };
602 return new ValueImpl { Type = etype, Value = (uint)ReadInt () };
604 return new ValueImpl { Type = etype, Value = ReadLong () };
606 return new ValueImpl { Type = etype, Value = (ulong)ReadLong () };
608 return new ValueImpl { Type = etype, Value = ReadFloat () };
610 return new ValueImpl { Type = etype, Value = ReadDouble () };
613 case ElementType.Ptr:
614 // FIXME: The client and the debuggee might have different word sizes
615 return new ValueImpl { Type = etype, Value = ReadLong () };
616 case ElementType.String:
617 case ElementType.SzArray:
618 case ElementType.Class:
619 case ElementType.Array:
620 case ElementType.Object:
621 long objid = ReadId ();
622 return new ValueImpl () { Type = etype, Objid = objid };
623 case ElementType.ValueType:
624 bool is_enum = ReadByte () == 1;
625 long klass = ReadId ();
626 long nfields = ReadInt ();
627 ValueImpl[] fields = new ValueImpl [nfields];
628 for (int i = 0; i < nfields; ++i)
629 fields [i] = ReadValue ();
630 return new ValueImpl () { Type = etype, Klass = klass, Fields = fields, IsEnum = is_enum };
631 case (ElementType)ValueTypeId.VALUE_TYPE_ID_NULL:
632 return new ValueImpl { Type = etype };
633 case (ElementType)ValueTypeId.VALUE_TYPE_ID_TYPE:
634 return new ValueImpl () { Type = etype, Id = ReadId () };
636 throw new NotImplementedException ("Unable to handle type " + etype);
646 public PacketWriter () {
648 data = new byte [1024];
652 public PacketWriter WriteByte (byte val) {
653 encode_byte (data, val, ref offset);
657 public PacketWriter WriteInt (int val) {
658 encode_int (data, val, ref offset);
662 public PacketWriter WriteId (long id) {
663 encode_id (data, id, ref offset);
667 public PacketWriter WriteLong (long val) {
668 encode_long (data, val, ref offset);
672 public PacketWriter WriteFloat (float f) {
673 byte[] b = DataConverter.GetBytesBE (f);
674 for (int i = 0; i < 4; ++i)
675 data [offset + i] = b [i];
680 public PacketWriter WriteDouble (double d) {
681 byte[] b = DataConverter.GetBytesBE (d);
682 for (int i = 0; i < 8; ++i)
683 data [offset + i] = b [i];
688 public PacketWriter WriteInts (int[] ids) {
689 for (int i = 0; i < ids.Length; ++i)
694 public PacketWriter WriteIds (long[] ids) {
695 for (int i = 0; i < ids.Length; ++i)
700 public PacketWriter WriteString (string s) {
701 encode_int (data, s.Length, ref offset);
702 byte[] b = Encoding.UTF8.GetBytes (s);
703 Buffer.BlockCopy (b, 0, data, offset, b.Length);
708 public PacketWriter WriteBool (bool val) {
709 WriteByte (val ? (byte)1 : (byte)0);
713 public PacketWriter WriteValue (ValueImpl v) {
717 t = TypeCodeToElementType (Type.GetTypeCode (v.Value.GetType ()));
722 case ElementType.Boolean:
723 WriteInt ((bool)v.Value ? 1 : 0);
725 case ElementType.Char:
726 WriteInt ((int)(char)v.Value);
729 WriteInt ((int)(sbyte)v.Value);
732 WriteInt ((int)(byte)v.Value);
735 WriteInt ((int)(short)v.Value);
738 WriteInt ((int)(ushort)v.Value);
741 WriteInt ((int)(int)v.Value);
744 WriteInt ((int)(uint)v.Value);
747 WriteLong ((long)(long)v.Value);
750 WriteLong ((long)(ulong)v.Value);
753 WriteFloat ((float)v.Value);
756 WriteDouble ((double)v.Value);
758 case ElementType.String:
759 case ElementType.SzArray:
760 case ElementType.Class:
761 case ElementType.Array:
762 case ElementType.Object:
765 case ElementType.ValueType:
768 throw new NotImplementedException ();
771 WriteInt (v.Fields.Length);
772 for (int i = 0; i < v.Fields.Length; ++i)
773 WriteValue (v.Fields [i]);
775 case (ElementType)ValueTypeId.VALUE_TYPE_ID_NULL:
778 throw new NotImplementedException ();
784 public PacketWriter WriteValues (ValueImpl[] values) {
785 for (int i = 0; i < values.Length; ++i)
786 WriteValue (values [i]);
803 delegate void ReplyCallback (int packet_id, byte[] packet);
807 Thread receiver_thread;
808 Dictionary<int, byte[]> reply_packets;
809 Dictionary<int, ReplyCallback> reply_cbs;
810 object reply_packets_monitor;
812 public event EventHandler<ErrorHandlerEventArgs> ErrorHandler;
814 public Connection (Socket socket) {
815 this.socket = socket;
816 //socket.SetSocketOption (SocketOptionLevel.IP, SocketOptionName.NoDelay, 1);
818 reply_packets = new Dictionary<int, byte[]> ();
819 reply_cbs = new Dictionary<int, ReplyCallback> ();
820 reply_packets_monitor = new Object ();
823 int Receive (byte[] buf, int buf_offset, int len) {
826 while (offset < len) {
827 int n = socket.Receive (buf, buf_offset + offset, len - offset, SocketFlags.None);
837 public VersionInfo Version;
839 // Do the wire protocol handshake
840 public void Connect () {
841 byte[] buf = new byte [HANDSHAKE_STRING.Length];
842 char[] cbuf = new char [buf.Length];
844 // FIXME: Add a timeout
845 int n = Receive (buf, 0, buf.Length);
847 throw new IOException ("DWP Handshake failed.");
848 for (int i = 0; i < buf.Length; ++i)
849 cbuf [i] = (char)buf [i];
851 if (new String (cbuf) != HANDSHAKE_STRING)
852 throw new IOException ("DWP Handshake failed.");
856 receiver_thread = new Thread (new ThreadStart (receiver_thread_main));
857 receiver_thread.Start ();
859 Version = VM_GetVersion ();
862 // Tell the debuggee our protocol version, so newer debuggees can work
863 // with older clients
867 // Older debuggees might not support this request
868 EventHandler<ErrorHandlerEventArgs> OrigErrorHandler = ErrorHandler;
870 ErrorHandler += delegate (object sender, ErrorHandlerEventArgs args) {
871 throw new NotSupportedException ();
874 VM_SetProtocolVersion (MAJOR_VERSION, MINOR_VERSION);
875 } catch (NotSupportedException) {
877 ErrorHandler = OrigErrorHandler;
880 public EndPoint EndPoint {
882 return socket.RemoteEndPoint;
886 public byte[] ReadPacket () {
887 // FIXME: Throw ClosedConnectionException () if the connection is closed
888 // FIXME: Throw ClosedConnectionException () if another thread closes the connection
890 byte[] header = new byte [HEADER_LENGTH];
892 int len = Receive (header, 0, header.Length);
895 if (len != HEADER_LENGTH) {
897 throw new IOException ("Packet of length " + len + " is read.");
900 int packetLength = GetPacketLength (header);
901 if (packetLength < 11)
902 throw new IOException ("Invalid packet length.");
904 if (packetLength == 11) {
907 byte[] buf = new byte [packetLength];
908 for (int i = 0; i < header.Length; ++i)
909 buf [i] = header [i];
910 len = Receive (buf, header.Length, packetLength - header.Length);
911 if (len != packetLength - header.Length)
912 throw new IOException ();
917 public void WritePacket (byte[] packet) {
918 // FIXME: Throw ClosedConnectionException () if the connection is closed
919 // FIXME: Throw ClosedConnectionException () if another thread closes the connection
921 socket.Send (packet);
924 public void Close () {
928 public bool IsClosed {
936 void receiver_thread_main () {
939 bool res = ReceivePacket ();
942 } catch (Exception ex) {
943 Console.WriteLine (ex);
948 lock (reply_packets_monitor) {
950 Monitor.PulseAll (reply_packets_monitor);
952 EventHandler.VMDisconnect (0, 0, null);
955 bool ReceivePacket () {
956 byte[] packet = ReadPacket ();
958 if (packet.Length == 0) {
962 if (IsReplyPacket (packet)) {
963 int id = GetPacketId (packet);
964 ReplyCallback cb = null;
965 lock (reply_packets_monitor) {
966 reply_cbs.TryGetValue (id, out cb);
968 reply_packets [id] = packet;
969 Monitor.PulseAll (reply_packets_monitor);
974 cb.Invoke (id, packet);
976 PacketReader r = new PacketReader (packet);
978 if (r.CommandSet == CommandSet.EVENT && r.Command == (int)CmdEvent.COMPOSITE) {
979 r.ReadByte (); // suspend_policy
980 int nevents = r.ReadInt ();
982 for (int i = 0; i < nevents; ++i) {
983 EventKind kind = (EventKind)r.ReadByte ();
984 int req_id = r.ReadInt ();
986 if (kind == EventKind.VM_START) {
987 long thread_id = r.ReadId ();
988 EventHandler.VMStart (req_id, thread_id, null);
989 } else if (kind == EventKind.VM_DEATH) {
990 EventHandler.VMDeath (req_id, 0, null);
991 } else if (kind == EventKind.THREAD_START) {
992 long thread_id = r.ReadId ();
993 EventHandler.ThreadStart (req_id, thread_id, thread_id);
994 } else if (kind == EventKind.THREAD_DEATH) {
995 long thread_id = r.ReadId ();
996 EventHandler.ThreadDeath (req_id, thread_id, thread_id);
997 } else if (kind == EventKind.ASSEMBLY_LOAD) {
998 long thread_id = r.ReadId ();
999 long id = r.ReadId ();
1000 EventHandler.AssemblyLoad (req_id, thread_id, id);
1001 } else if (kind == EventKind.ASSEMBLY_UNLOAD) {
1002 long thread_id = r.ReadId ();
1003 long id = r.ReadId ();
1004 EventHandler.AssemblyUnload (req_id, thread_id, id);
1005 } else if (kind == EventKind.TYPE_LOAD) {
1006 long thread_id = r.ReadId ();
1007 long id = r.ReadId ();
1008 EventHandler.TypeLoad (req_id, thread_id, id);
1009 } else if (kind == EventKind.METHOD_ENTRY) {
1010 long thread_id = r.ReadId ();
1011 long id = r.ReadId ();
1012 EventHandler.MethodEntry (req_id, thread_id, id);
1013 } else if (kind == EventKind.METHOD_EXIT) {
1014 long thread_id = r.ReadId ();
1015 long id = r.ReadId ();
1016 EventHandler.MethodExit (req_id, thread_id, id);
1017 } else if (kind == EventKind.BREAKPOINT) {
1018 long thread_id = r.ReadId ();
1019 long id = r.ReadId ();
1020 long loc = r.ReadLong ();
1021 EventHandler.Breakpoint (req_id, thread_id, id, loc);
1022 } else if (kind == EventKind.STEP) {
1023 long thread_id = r.ReadId ();
1024 long id = r.ReadId ();
1025 long loc = r.ReadLong ();
1026 EventHandler.Step (req_id, thread_id, id, loc);
1027 } else if (kind == EventKind.EXCEPTION) {
1028 long thread_id = r.ReadId ();
1029 long id = r.ReadId ();
1030 long loc = 0; // FIXME
1031 EventHandler.Exception (req_id, thread_id, id, loc);
1032 } else if (kind == EventKind.APPDOMAIN_CREATE) {
1033 long thread_id = r.ReadId ();
1034 long id = r.ReadId ();
1035 EventHandler.AppDomainCreate (req_id, thread_id, id);
1036 } else if (kind == EventKind.APPDOMAIN_UNLOAD) {
1037 long thread_id = r.ReadId ();
1038 long id = r.ReadId ();
1039 EventHandler.AppDomainUnload (req_id, thread_id, id);
1041 throw new NotImplementedException ("Unknown event kind: " + kind);
1050 public IEventHandler EventHandler {
1054 /* Send a request and call cb when a result is received */
1055 int Send (CommandSet command_set, int command, PacketWriter packet, Action<PacketReader> cb) {
1056 int id = IdGenerator;
1058 lock (reply_packets_monitor) {
1059 reply_cbs [id] = delegate (int packet_id, byte[] p) {
1060 /* Run the callback on a tp thread to avoid blocking the receive thread */
1061 PacketReader r = new PacketReader (p);
1062 cb.BeginInvoke (r, null, null);
1067 WritePacket (EncodePacket (id, (int)command_set, command, null, 0));
1069 WritePacket (EncodePacket (id, (int)command_set, command, packet.Data, packet.Offset));
1074 PacketReader SendReceive (CommandSet command_set, int command, PacketWriter packet) {
1075 int id = IdGenerator;
1078 WritePacket (EncodePacket (id, (int)command_set, command, null, 0));
1080 WritePacket (EncodePacket (id, (int)command_set, command, packet.Data, packet.Offset));
1084 /* Wait for the reply packet */
1086 lock (reply_packets_monitor) {
1087 if (reply_packets.ContainsKey (packetId)) {
1088 byte[] reply = reply_packets [packetId];
1089 reply_packets.Remove (packetId);
1090 PacketReader r = new PacketReader (reply);
1091 if (r.ErrorCode != 0) {
1092 if (ErrorHandler != null)
1093 ErrorHandler (this, new ErrorHandlerEventArgs () { ErrorCode = (ErrorCode)r.ErrorCode });
1094 throw new NotImplementedException ("No error handler set.");
1100 throw new VMDisconnectedException ();
1101 Monitor.Wait (reply_packets_monitor);
1107 PacketReader SendReceive (CommandSet command_set, int command) {
1108 return SendReceive (command_set, command, null);
1111 int packet_id_generator;
1115 return Interlocked.Increment (ref packet_id_generator);
1119 CattrInfo[] ReadCattrs (PacketReader r) {
1120 CattrInfo[] res = new CattrInfo [r.ReadInt ()];
1121 for (int i = 0; i < res.Length; ++i) {
1122 CattrInfo info = new CattrInfo ();
1123 info.ctor_id = r.ReadId ();
1124 info.ctor_args = new ValueImpl [r.ReadInt ()];
1125 for (int j = 0; j < info.ctor_args.Length; ++j) {
1126 info.ctor_args [j] = r.ReadValue ();
1128 info.named_args = new CattrNamedArgInfo [r.ReadInt ()];
1129 for (int j = 0; j < info.named_args.Length; ++j) {
1130 CattrNamedArgInfo arg = new CattrNamedArgInfo ();
1131 int arg_type = r.ReadByte ();
1132 arg.is_property = arg_type == 0x54;
1133 arg.id = r.ReadId ();
1134 arg.value = r.ReadValue ();
1135 info.named_args [j] = arg;
1142 static ElementType TypeCodeToElementType (TypeCode c) {
1144 case TypeCode.Boolean:
1145 return ElementType.Boolean;
1147 return ElementType.Char;
1148 case TypeCode.SByte:
1149 return ElementType.I1;
1151 return ElementType.U1;
1152 case TypeCode.Int16:
1153 return ElementType.I2;
1154 case TypeCode.UInt16:
1155 return ElementType.U2;
1156 case TypeCode.Int32:
1157 return ElementType.I4;
1158 case TypeCode.UInt32:
1159 return ElementType.U4;
1160 case TypeCode.Int64:
1161 return ElementType.I8;
1162 case TypeCode.UInt64:
1163 return ElementType.U8;
1164 case TypeCode.Single:
1165 return ElementType.R4;
1166 case TypeCode.Double:
1167 return ElementType.R8;
1169 throw new NotImplementedException ();
1174 * Implementation of debugger commands
1177 public VersionInfo VM_GetVersion () {
1178 var res = SendReceive (CommandSet.VM, (int)CmdVM.VERSION, null);
1179 VersionInfo info = new VersionInfo ();
1180 info.VMVersion = res.ReadString ();
1181 info.MajorVersion = res.ReadInt ();
1182 info.MinorVersion = res.ReadInt ();
1186 public void VM_SetProtocolVersion (int major, int minor) {
1187 SendReceive (CommandSet.VM, (int)CmdVM.SET_PROTOCOL_VERSION, new PacketWriter ().WriteInt (major).WriteInt (minor));
1190 public long[] VM_GetThreads () {
1191 var res = SendReceive (CommandSet.VM, (int)CmdVM.ALL_THREADS, null);
1192 int len = res.ReadInt ();
1193 long[] arr = new long [len];
1194 for (int i = 0; i < len; ++i)
1195 arr [i] = res.ReadId ();
1199 public void VM_Suspend () {
1200 SendReceive (CommandSet.VM, (int)CmdVM.SUSPEND);
1203 public void VM_Resume () {
1204 SendReceive (CommandSet.VM, (int)CmdVM.RESUME);
1207 public void VM_Exit (int exitCode) {
1208 SendReceive (CommandSet.VM, (int)CmdVM.EXIT, new PacketWriter ().WriteInt (exitCode));
1211 public void VM_Dispose () {
1212 SendReceive (CommandSet.VM, (int)CmdVM.DISPOSE);
1215 public ValueImpl VM_InvokeMethod (long thread, long method, ValueImpl this_arg, ValueImpl[] arguments, InvokeFlags flags, out ValueImpl exc) {
1217 PacketReader r = SendReceive (CommandSet.VM, (int)CmdVM.INVOKE_METHOD, new PacketWriter ().WriteId (thread).WriteInt ((int)flags).WriteId (method).WriteValue (this_arg).WriteInt (arguments.Length).WriteValues (arguments));
1218 if (r.ReadByte () == 0) {
1219 exc = r.ReadValue ();
1222 return r.ReadValue ();
1226 public delegate void InvokeMethodCallback (ValueImpl v, ValueImpl exc, ErrorCode error, object state);
1228 public int VM_BeginInvokeMethod (long thread, long method, ValueImpl this_arg, ValueImpl[] arguments, InvokeFlags flags, InvokeMethodCallback callback, object state) {
1229 return Send (CommandSet.VM, (int)CmdVM.INVOKE_METHOD, new PacketWriter ().WriteId (thread).WriteInt ((int)flags).WriteId (method).WriteValue (this_arg).WriteInt (arguments.Length).WriteValues (arguments), delegate (PacketReader r) {
1232 if (r.ErrorCode != 0) {
1233 callback (null, null, (ErrorCode)r.ErrorCode, state);
1235 if (r.ReadByte () == 0) {
1236 exc = r.ReadValue ();
1243 callback (v, exc, 0, state);
1248 public void VM_AbortInvoke (long thread, int id)
1250 SendReceive (CommandSet.VM, (int)CmdVM.ABORT_INVOKE, new PacketWriter ().WriteId (thread).WriteInt (id));
1257 public long RootDomain {
1259 return SendReceive (CommandSet.APPDOMAIN, (int)CmdAppDomain.GET_ROOT_DOMAIN, null).ReadId ();
1263 public string Domain_GetName (long id) {
1264 return SendReceive (CommandSet.APPDOMAIN, (int)CmdAppDomain.GET_FRIENDLY_NAME, new PacketWriter ().WriteId (id)).ReadString ();
1267 public long[] Domain_GetAssemblies (long id) {
1268 var res = SendReceive (CommandSet.APPDOMAIN, (int)CmdAppDomain.GET_ASSEMBLIES, new PacketWriter ().WriteId (id));
1269 int count = res.ReadInt ();
1270 long[] assemblies = new long [count];
1271 for (int i = 0; i < count; ++i)
1272 assemblies [i] = res.ReadId ();
1276 public long Domain_GetEntryAssembly (long id) {
1277 return SendReceive (CommandSet.APPDOMAIN, (int)CmdAppDomain.GET_ENTRY_ASSEMBLY, new PacketWriter ().WriteId (id)).ReadId ();
1280 public long Domain_GetCorlib (long id) {
1281 return SendReceive (CommandSet.APPDOMAIN, (int)CmdAppDomain.GET_CORLIB, new PacketWriter ().WriteId (id)).ReadId ();
1284 public long Domain_CreateString (long id, string s) {
1285 return SendReceive (CommandSet.APPDOMAIN, (int)CmdAppDomain.CREATE_STRING, new PacketWriter ().WriteId (id).WriteString (s)).ReadId ();
1288 public long Domain_CreateBoxedValue (long id, long type_id, ValueImpl v) {
1289 return SendReceive (CommandSet.APPDOMAIN, (int)CmdAppDomain.CREATE_BOXED_VALUE, new PacketWriter ().WriteId (id).WriteId (type_id).WriteValue (v)).ReadId ();
1296 public string Method_GetName (long id) {
1297 return SendReceive (CommandSet.METHOD, (int)CmdMethod.GET_NAME, new PacketWriter ().WriteId (id)).ReadString ();
1300 public long Method_GetDeclaringType (long id) {
1301 return SendReceive (CommandSet.METHOD, (int)CmdMethod.GET_DECLARING_TYPE, new PacketWriter ().WriteId (id)).ReadId ();
1304 public DebugInfo Method_GetDebugInfo (long id) {
1305 var res = SendReceive (CommandSet.METHOD, (int)CmdMethod.GET_DEBUG_INFO, new PacketWriter ().WriteId (id));
1307 DebugInfo info = new DebugInfo ();
1308 info.max_il_offset = res.ReadInt ();
1309 info.filename = res.ReadString ();
1311 int n_il_offsets = res.ReadInt ();
1312 info.il_offsets = new int [n_il_offsets];
1313 info.line_numbers = new int [n_il_offsets];
1314 for (int i = 0; i < n_il_offsets; ++i) {
1315 info.il_offsets [i] = res.ReadInt ();
1316 info.line_numbers [i] = res.ReadInt ();
1322 public ParamInfo Method_GetParamInfo (long id) {
1323 var res = SendReceive (CommandSet.METHOD, (int)CmdMethod.GET_PARAM_INFO, new PacketWriter ().WriteId (id));
1325 ParamInfo info = new ParamInfo ();
1326 info.call_conv = res.ReadInt ();
1327 info.param_count = res.ReadInt ();
1328 info.generic_param_count = res.ReadInt ();
1329 info.ret_type = res.ReadId ();
1330 info.param_types = new long [info.param_count];
1331 for (int i = 0; i < info.param_count; ++i)
1332 info.param_types [i] = res.ReadId ();
1333 info.param_names = new string [info.param_count];
1334 for (int i = 0; i < info.param_count; ++i)
1335 info.param_names [i] = res.ReadString ();
1340 public LocalsInfo Method_GetLocalsInfo (long id) {
1341 var res = SendReceive (CommandSet.METHOD, (int)CmdMethod.GET_LOCALS_INFO, new PacketWriter ().WriteId (id));
1343 LocalsInfo info = new LocalsInfo ();
1344 int nlocals = res.ReadInt ();
1345 info.types = new long [nlocals];
1346 for (int i = 0; i < nlocals; ++i)
1347 info.types [i] = res.ReadId ();
1348 info.names = new string [nlocals];
1349 for (int i = 0; i < nlocals; ++i)
1350 info.names [i] = res.ReadString ();
1351 info.live_range_start = new int [nlocals];
1352 info.live_range_end = new int [nlocals];
1353 for (int i = 0; i < nlocals; ++i) {
1354 info.live_range_start [i] = res.ReadInt ();
1355 info.live_range_end [i] = res.ReadInt ();
1361 public MethodInfo Method_GetInfo (long id) {
1362 var res = SendReceive (CommandSet.METHOD, (int)CmdMethod.GET_INFO, new PacketWriter ().WriteId (id));
1364 MethodInfo info = new MethodInfo ();
1365 info.attributes = res.ReadInt ();
1366 info.iattributes = res.ReadInt ();
1367 info.token = res.ReadInt ();
1372 public MethodBodyInfo Method_GetBody (long id) {
1373 var res = SendReceive (CommandSet.METHOD, (int)CmdMethod.GET_BODY, new PacketWriter ().WriteId (id));
1375 MethodBodyInfo info = new MethodBodyInfo ();
1376 info.il = new byte [res.ReadInt ()];
1377 for (int i = 0; i < info.il.Length; ++i)
1378 info.il [i] = (byte)res.ReadByte ();
1383 public ResolvedToken Method_ResolveToken (long id, int token) {
1384 var res = SendReceive (CommandSet.METHOD, (int)CmdMethod.RESOLVE_TOKEN, new PacketWriter ().WriteId (id).WriteInt (token));
1386 TokenType type = (TokenType)res.ReadByte ();
1388 case TokenType.STRING:
1389 return new ResolvedToken () { Type = type, Str = res.ReadString () };
1390 case TokenType.TYPE:
1391 case TokenType.METHOD:
1392 case TokenType.FIELD:
1393 return new ResolvedToken () { Type = type, Id = res.ReadId () };
1394 case TokenType.UNKNOWN:
1395 return new ResolvedToken () { Type = type };
1397 throw new NotImplementedException ();
1405 public string Thread_GetName (long id) {
1406 return SendReceive (CommandSet.THREAD, (int)CmdThread.GET_NAME, new PacketWriter ().WriteId (id)).ReadString ();
1409 public FrameInfo[] Thread_GetFrameInfo (long id, int start_frame, int length) {
1410 var res = SendReceive (CommandSet.THREAD, (int)CmdThread.GET_FRAME_INFO, new PacketWriter ().WriteId (id).WriteInt (start_frame).WriteInt (length));
1411 int count = res.ReadInt ();
1413 var frames = new FrameInfo [count];
1414 for (int i = 0; i < count; ++i) {
1415 frames [i].id = res.ReadInt ();
1416 frames [i].method = res.ReadId ();
1417 frames [i].il_offset = res.ReadInt ();
1418 frames [i].flags = (StackFrameFlags)res.ReadByte ();
1423 public int Thread_GetState (long id) {
1424 return SendReceive (CommandSet.THREAD, (int)CmdThread.GET_STATE, new PacketWriter ().WriteId (id)).ReadInt ();
1427 public ThreadInfo Thread_GetInfo (long id) {
1428 PacketReader r = SendReceive (CommandSet.THREAD, (int)CmdThread.GET_INFO, new PacketWriter ().WriteId (id));
1430 ThreadInfo res = new ThreadInfo () { is_thread_pool = r.ReadByte () > 0 ? true : false };
1435 public long Thread_GetId (long id) {
1436 return SendReceive (CommandSet.THREAD, (int)CmdThread.GET_ID, new PacketWriter ().WriteId (id)).ReadLong ();
1443 public ModuleInfo Module_GetInfo (long id) {
1444 PacketReader r = SendReceive (CommandSet.MODULE, (int)CmdModule.GET_INFO, new PacketWriter ().WriteId (id));
1445 ModuleInfo info = new ModuleInfo { Name = r.ReadString (), ScopeName = r.ReadString (), FQName = r.ReadString (), Guid = r.ReadString (), Assembly = r.ReadId () };
1453 public string Assembly_GetLocation (long id) {
1454 return SendReceive (CommandSet.ASSEMBLY, (int)CmdAssembly.GET_LOCATION, new PacketWriter ().WriteId (id)).ReadString ();
1457 public long Assembly_GetEntryPoint (long id) {
1458 return SendReceive (CommandSet.ASSEMBLY, (int)CmdAssembly.GET_ENTRY_POINT, new PacketWriter ().WriteId (id)).ReadId ();
1461 public long Assembly_GetManifestModule (long id) {
1462 return SendReceive (CommandSet.ASSEMBLY, (int)CmdAssembly.GET_MANIFEST_MODULE, new PacketWriter ().WriteId (id)).ReadId ();
1465 public long Assembly_GetObject (long id) {
1466 return SendReceive (CommandSet.ASSEMBLY, (int)CmdAssembly.GET_OBJECT, new PacketWriter ().WriteId (id)).ReadId ();
1469 public long Assembly_GetType (long id, string name, bool ignoreCase) {
1470 return SendReceive (CommandSet.ASSEMBLY, (int)CmdAssembly.GET_TYPE, new PacketWriter ().WriteId (id).WriteString (name).WriteBool (ignoreCase)).ReadId ();
1473 public string Assembly_GetName (long id) {
1474 return SendReceive (CommandSet.ASSEMBLY, (int)CmdAssembly.GET_NAME, new PacketWriter ().WriteId (id)).ReadString ();
1481 public TypeInfo Type_GetInfo (long id) {
1482 PacketReader r = SendReceive (CommandSet.TYPE, (int)CmdType.GET_INFO, new PacketWriter ().WriteId (id));
1483 TypeInfo res = new TypeInfo ();
1485 res.ns = r.ReadString ();
1486 res.name = r.ReadString ();
1487 res.full_name = r.ReadString ();
1488 res.assembly = r.ReadId ();
1489 res.module = r.ReadId ();
1490 res.base_type = r.ReadId ();
1491 res.element_type = r.ReadId ();
1492 res.token = r.ReadInt ();
1493 res.rank = r.ReadByte ();
1494 res.attributes = r.ReadInt ();
1495 int b = r.ReadByte ();
1496 res.is_byref = (b & 1) != 0;
1497 res.is_pointer = (b & 2) != 0;
1498 res.is_primitive = (b & 4) != 0;
1499 res.is_valuetype = (b & 8) != 0;
1500 res.is_enum = (b & 16) != 0;
1502 int nested_len = r.ReadInt ();
1503 res.nested = new long [nested_len];
1504 for (int i = 0; i < nested_len; ++i)
1505 res.nested [i] = r.ReadId ();
1510 public long[] Type_GetMethods (long id) {
1511 PacketReader r = SendReceive (CommandSet.TYPE, (int)CmdType.GET_METHODS, new PacketWriter ().WriteId (id));
1513 int n = r.ReadInt ();
1514 long[] res = new long [n];
1515 for (int i = 0; i < n; ++i)
1516 res [i] = r.ReadId ();
1520 public long[] Type_GetFields (long id, out string[] names, out long[] types, out int[] attrs) {
1521 PacketReader r = SendReceive (CommandSet.TYPE, (int)CmdType.GET_FIELDS, new PacketWriter ().WriteId (id));
1523 int n = r.ReadInt ();
1524 long[] res = new long [n];
1525 names = new string [n];
1526 types = new long [n];
1527 attrs = new int [n];
1528 for (int i = 0; i < n; ++i) {
1529 res [i] = r.ReadId ();
1530 names [i] = r.ReadString ();
1531 types [i] = r.ReadId ();
1532 attrs [i] = r.ReadInt ();
1537 public PropInfo[] Type_GetProperties (long id) {
1538 PacketReader r = SendReceive (CommandSet.TYPE, (int)CmdType.GET_PROPERTIES, new PacketWriter ().WriteId (id));
1540 int n = r.ReadInt ();
1541 PropInfo[] res = new PropInfo [n];
1542 for (int i = 0; i < n; ++i) {
1543 res [i] = new PropInfo ();
1544 res [i].id = r.ReadId ();
1545 res [i].name = r.ReadString ();
1546 res [i].get_method = r.ReadId ();
1547 res [i].set_method = r.ReadId ();
1548 res [i].attrs = r.ReadInt ();
1554 public long Type_GetObject (long id) {
1555 return SendReceive (CommandSet.TYPE, (int)CmdType.GET_OBJECT, new PacketWriter ().WriteId (id)).ReadId ();
1558 public ValueImpl[] Type_GetValues (long id, long[] fields) {
1559 int len = fields.Length;
1560 PacketReader r = SendReceive (CommandSet.TYPE, (int)CmdType.GET_VALUES, new PacketWriter ().WriteId (id).WriteInt (len).WriteIds (fields));
1562 ValueImpl[] res = new ValueImpl [len];
1563 for (int i = 0; i < len; ++i)
1564 res [i] = r.ReadValue ();
1568 public void Type_SetValues (long id, long[] fields, ValueImpl[] values) {
1569 SendReceive (CommandSet.TYPE, (int)CmdType.SET_VALUES, new PacketWriter ().WriteId (id).WriteInt (fields.Length).WriteIds (fields).WriteValues (values));
1572 public string[] Type_GetSourceFiles (long id) {
1573 var r = SendReceive (CommandSet.TYPE, (int)CmdType.GET_SOURCE_FILES, new PacketWriter ().WriteId (id));
1574 int len = r.ReadInt ();
1575 string[] res = new string [len];
1576 for (int i = 0; i < len; ++i)
1577 res [i] = r.ReadString ();
1581 public bool Type_IsAssignableFrom (long id, long c_id) {
1582 return SendReceive (CommandSet.TYPE, (int)CmdType.IS_ASSIGNABLE_FROM, new PacketWriter ().WriteId (id).WriteId (c_id)).ReadByte () > 0;
1585 public CattrInfo[] Type_GetCustomAttributes (long id, long attr_type_id, bool inherit) {
1586 PacketReader r = SendReceive (CommandSet.TYPE, (int)CmdType.GET_CATTRS, new PacketWriter ().WriteId (id).WriteId (attr_type_id));
1587 return ReadCattrs (r);
1590 public CattrInfo[] Type_GetFieldCustomAttributes (long id, long field_id, long attr_type_id, bool inherit) {
1591 PacketReader r = SendReceive (CommandSet.TYPE, (int)CmdType.GET_FIELD_CATTRS, new PacketWriter ().WriteId (id).WriteId (field_id).WriteId (attr_type_id));
1592 return ReadCattrs (r);
1595 public CattrInfo[] Type_GetPropertyCustomAttributes (long id, long field_id, long attr_type_id, bool inherit) {
1596 PacketReader r = SendReceive (CommandSet.TYPE, (int)CmdType.GET_PROPERTY_CATTRS, new PacketWriter ().WriteId (id).WriteId (field_id).WriteId (attr_type_id));
1597 return ReadCattrs (r);
1604 public int EnableEvent (EventType etype, SuspendPolicy suspend_policy, List<Modifier> mods) {
1605 var w = new PacketWriter ().WriteByte ((byte)etype).WriteByte ((byte)suspend_policy);
1607 if (mods.Count > 255)
1608 throw new NotImplementedException ();
1609 w.WriteByte ((byte)mods.Count);
1610 foreach (Modifier mod in mods) {
1611 if (mod is CountModifier) {
1612 w.WriteByte ((byte)ModifierKind.COUNT);
1613 w.WriteInt ((mod as CountModifier).Count);
1614 } else if (mod is LocationModifier) {
1615 w.WriteByte ((byte)ModifierKind.LOCATION_ONLY);
1616 w.WriteId ((mod as LocationModifier).Method);
1617 w.WriteLong ((mod as LocationModifier).Location);
1618 } else if (mod is StepModifier) {
1619 w.WriteByte ((byte)ModifierKind.STEP);
1620 w.WriteId ((mod as StepModifier).Thread);
1621 w.WriteInt ((mod as StepModifier).Size);
1622 w.WriteInt ((mod as StepModifier).Depth);
1623 } else if (mod is ThreadModifier) {
1624 w.WriteByte ((byte)ModifierKind.THREAD_ONLY);
1625 w.WriteId ((mod as ThreadModifier).Thread);
1626 } else if (mod is ExceptionModifier) {
1627 var em = mod as ExceptionModifier;
1628 w.WriteByte ((byte)ModifierKind.EXCEPTION_ONLY);
1629 w.WriteId (em.Type);
1630 if (Version.MajorVersion > 2 || Version.MinorVersion > 0) {
1631 /* This is only supported in protocol version 2.1 */
1632 w.WriteBool (em.Caught);
1633 w.WriteBool (em.Uncaught);
1634 } else if (!em.Caught || !em.Uncaught) {
1635 throw new NotSupportedException ("This request is not supported by the protocol version implemented by the debuggee.");
1637 } else if (mod is AssemblyModifier) {
1638 w.WriteByte ((byte)ModifierKind.ASSEMBLY_ONLY);
1639 var amod = (mod as AssemblyModifier);
1640 w.WriteInt (amod.Assemblies.Length);
1641 foreach (var id in amod.Assemblies)
1644 throw new NotImplementedException ();
1650 return SendReceive (CommandSet.EVENT_REQUEST, (int)CmdEventRequest.SET, w).ReadInt ();
1653 public void ClearEventRequest (EventType etype, int req_id) {
1654 SendReceive (CommandSet.EVENT_REQUEST, (int)CmdEventRequest.CLEAR, new PacketWriter ().WriteByte ((byte)etype).WriteInt (req_id));
1657 public void ClearAllBreakpoints () {
1658 SendReceive (CommandSet.EVENT_REQUEST, (int)CmdEventRequest.CLEAR_ALL_BREAKPOINTS, new PacketWriter ());
1664 public ValueImpl StackFrame_GetThis (long thread_id, long id) {
1665 PacketReader r = SendReceive (CommandSet.STACK_FRAME, (int)CmdStackFrame.GET_THIS, new PacketWriter ().WriteId (thread_id).WriteId (id));
1666 return r.ReadValue ();
1669 public ValueImpl[] StackFrame_GetValues (long thread_id, long id, int[] pos) {
1670 /* pos < 0 -> argument at pos (-pos) - 1 */
1671 /* pos >= 0 -> local at pos */
1672 int len = pos.Length;
1673 PacketReader r = SendReceive (CommandSet.STACK_FRAME, (int)CmdStackFrame.GET_VALUES, new PacketWriter ().WriteId (thread_id).WriteId (id).WriteInt (len).WriteInts (pos));
1675 ValueImpl[] res = new ValueImpl [len];
1676 for (int i = 0; i < len; ++i)
1677 res [i] = r.ReadValue ();
1681 public void StackFrame_SetValues (long thread_id, long id, int[] pos, ValueImpl[] values) {
1682 /* pos < 0 -> argument at pos (-pos) - 1 */
1683 /* pos >= 0 -> local at pos */
1684 int len = pos.Length;
1685 SendReceive (CommandSet.STACK_FRAME, (int)CmdStackFrame.SET_VALUES, new PacketWriter ().WriteId (thread_id).WriteId (id).WriteInt (len).WriteInts (pos).WriteValues (values));
1691 public int[] Array_GetLength (long id, out int rank, out int[] lower_bounds) {
1692 var r = SendReceive (CommandSet.ARRAY_REF, (int)CmdArrayRef.GET_LENGTH, new PacketWriter ().WriteId (id));
1693 rank = r.ReadInt ();
1694 int[] res = new int [rank];
1695 lower_bounds = new int [rank];
1696 for (int i = 0; i < rank; ++i) {
1697 res [i] = r.ReadInt ();
1698 lower_bounds [i] = r.ReadInt ();
1703 public ValueImpl[] Array_GetValues (long id, int index, int len) {
1704 var r = SendReceive (CommandSet.ARRAY_REF, (int)CmdArrayRef.GET_VALUES, new PacketWriter ().WriteId (id).WriteInt (index).WriteInt (len));
1705 ValueImpl[] res = new ValueImpl [len];
1706 for (int i = 0; i < len; ++i)
1707 res [i] = r.ReadValue ();
1711 public void Array_SetValues (long id, int index, ValueImpl[] values) {
1712 SendReceive (CommandSet.ARRAY_REF, (int)CmdArrayRef.SET_VALUES, new PacketWriter ().WriteId (id).WriteInt (index).WriteInt (values.Length).WriteValues (values));
1718 public string String_GetValue (long id) {
1719 return SendReceive (CommandSet.STRING_REF, (int)CmdStringRef.GET_VALUE, new PacketWriter ().WriteId (id)).ReadString ();
1725 public long Object_GetType (long id) {
1726 return SendReceive (CommandSet.OBJECT_REF, (int)CmdObjectRef.GET_TYPE, new PacketWriter ().WriteId (id)).ReadId ();
1729 public long Object_GetDomain (long id) {
1730 return SendReceive (CommandSet.OBJECT_REF, (int)CmdObjectRef.GET_DOMAIN, new PacketWriter ().WriteId (id)).ReadId ();
1733 public ValueImpl[] Object_GetValues (long id, long[] fields) {
1734 int len = fields.Length;
1735 PacketReader r = SendReceive (CommandSet.OBJECT_REF, (int)CmdObjectRef.GET_VALUES, new PacketWriter ().WriteId (id).WriteInt (len).WriteIds (fields));
1737 ValueImpl[] res = new ValueImpl [len];
1738 for (int i = 0; i < len; ++i)
1739 res [i] = r.ReadValue ();
1743 public void Object_SetValues (long id, long[] fields, ValueImpl[] values) {
1744 SendReceive (CommandSet.OBJECT_REF, (int)CmdObjectRef.SET_VALUES, new PacketWriter ().WriteId (id).WriteInt (fields.Length).WriteIds (fields).WriteValues (values));
1747 public bool Object_IsCollected (long id) {
1748 return SendReceive (CommandSet.OBJECT_REF, (int)CmdObjectRef.IS_COLLECTED, new PacketWriter ().WriteId (id)).ReadInt () == 1;
1751 public long Object_GetAddress (long id) {
1752 return SendReceive (CommandSet.OBJECT_REF, (int)CmdObjectRef.GET_ADDRESS, new PacketWriter ().WriteId (id)).ReadLong ();
1757 /* This is the interface exposed by the debugger towards the debugger agent */
1758 interface IEventHandler
1760 void VMStart (int req_id, long thread_id, string vm_uri);
1762 void VMDeath (int req_id, long thread_id, string vm_uri);
1764 void VMDisconnect (int req_id, long thread_id, string vm_uri);
1766 void ThreadStart (int req_id, long thread_id, long id);
1768 void ThreadDeath (int req_id, long thread_id, long id);
1770 void AssemblyLoad (int req_id, long thread_id, long id);
1772 void AssemblyUnload (int req_id, long thread_id, long id);
1774 void TypeLoad (int req_id, long thread_id, long id);
1776 void MethodEntry (int req_id, long thread_id, long id);
1778 void MethodExit (int req_id, long thread_id, long id);
1780 void Breakpoint (int req_id, long thread_id, long method_id, long loc);
1782 void Step (int req_id, long thread_id, long method_id, long loc);
1784 void Exception (int req_id, long thread_id, long exc_id, long loc);
1786 void AppDomainCreate (int req_id, long thread_id, long id);
1788 void AppDomainUnload (int req_id, long thread_id, long id);