INVALID_FRAMEID = 30,
NOT_IMPLEMENTED = 100,
NOT_SUSPENDED = 101,
- INVALID_ARGUMENT = 102
+ INVALID_ARGUMENT = 102,
+ ERR_UNLOADED = 103,
+ ERR_NO_INVOCATION = 104
}
public class ErrorHandlerEventArgs : EventArgs {
/*
* Th version of the wire-protocol implemented by the library. The library
- * and the debuggee can communicate if they implement the same major version,
- * and the debuggee's minor version is <= the library's minor version.
+ * and the debuggee can communicate if they implement the same major version.
+ * If they implement a different minor version, they can communicate, but some
+ * features might not be available. This allows older clients to communicate
+ * with newer runtimes, and vice versa.
*/
public const int MAJOR_VERSION = 2;
public const int MINOR_VERSION = 1;
RESUME = 4,
EXIT = 5,
DISPOSE = 6,
- INVOKE_METHOD = 7
+ INVOKE_METHOD = 7,
+ SET_PROTOCOL_VERSION = 8,
+ ABORT_INVOKE = 9
}
enum CmdEvent {
GET_FRAME_INFO = 1,
GET_NAME = 2,
GET_STATE = 3,
- GET_INFO = 4
+ GET_INFO = 4,
+ /* FIXME: Merge into GET_INFO when the major protocol version is increased */
+ GET_ID = 5
}
enum CmdEventRequest {
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;
}
public EndPoint EndPoint {
}
/* Send a request and call cb when a result is received */
- void Send (CommandSet command_set, int command, PacketWriter packet, Action<PacketReader> cb) {
+ int Send (CommandSet command_set, int command, PacketWriter packet, Action<PacketReader> cb) {
int id = IdGenerator;
lock (reply_packets_monitor) {
WritePacket (EncodePacket (id, (int)command_set, command, null, 0));
else
WritePacket (EncodePacket (id, (int)command_set, command, packet.Data, packet.Offset));
+
+ return id;
}
PacketReader SendReceive (CommandSet command_set, int command, PacketWriter packet) {
return info;
}
+ public void VM_SetProtocolVersion (int major, int minor) {
+ SendReceive (CommandSet.VM, (int)CmdVM.SET_PROTOCOL_VERSION, new PacketWriter ().WriteInt (major).WriteInt (minor));
+ }
+
public long[] VM_GetThreads () {
var res = SendReceive (CommandSet.VM, (int)CmdVM.ALL_THREADS, null);
int len = res.ReadInt ();
public delegate void InvokeMethodCallback (ValueImpl v, ValueImpl exc, ErrorCode error, object state);
- public void VM_BeginInvokeMethod (long thread, long method, ValueImpl this_arg, ValueImpl[] arguments, InvokeFlags flags, InvokeMethodCallback callback, object state) {
- 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) {
+ public int VM_BeginInvokeMethod (long thread, long method, ValueImpl this_arg, ValueImpl[] arguments, InvokeFlags flags, InvokeMethodCallback callback, object state) {
+ 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) {
ValueImpl v, exc;
if (r.ErrorCode != 0) {
});
}
+ public void VM_AbortInvoke (long thread, int id)
+ {
+ SendReceive (CommandSet.VM, (int)CmdVM.ABORT_INVOKE, new PacketWriter ().WriteId (thread).WriteInt (id));
+ }
+
/*
* DOMAIN
*/
return res;
}
+ public long Thread_GetId (long id) {
+ return SendReceive (CommandSet.THREAD, (int)CmdThread.GET_ID, new PacketWriter ().WriteId (id)).ReadLong ();
+ }
+
/*
* MODULE
*/