/// <summary> /// Returns variable information for the method, including generic signatures for the variables. The variable table includes arguments and /// locals declared within the method. For instance methods, the "this" reference is included in the table. Also, synthetic variables may be /// present. Generic signatures are described in the signature attribute section in the Java Virtual Machine Specification, 3rd Edition. /// Since JDWP version 1.5. /// </summary> public Task <List <VariableInfo> > VariableTableWithGenericAsync(ReferenceTypeId typeId, MethodId methodId) { var conn = ConnectionOrError; var t = conn.SendAsync(JdwpPacket.CreateCommand(conn, Nr, 5, typeId.Size + methodId.Size, x => { var data = x.Data; typeId.WriteTo(data); methodId.WriteTo(data); })); return(t.ContinueWith(x => { x.ForwardException(); var result = x.Result; result.ThrowOnError(); var data = result.Data; var argCnt = data.GetInt(); var count = data.GetInt(); var list = new List <VariableInfo>(count); for (var i = 0; i < count; i++) { var codeIndex = data.GetLong(); var name = data.GetString(); var signature = data.GetString(); var genericSignature = data.GetString(); var length = data.GetInt(); var slot = data.GetInt(); list.Add(new VariableInfo(codeIndex, name, signature, genericSignature, length, slot)); } return list; })); }
/// <summary> /// Returns the value of one or more static fields of the reference type. Each field must be member of the reference type or /// one of its superclasses, superinterfaces, or implemented interfaces. Access control is not enforced; for example, the values /// of private fields can be obtained. /// </summary> public Task <List <Value> > GetValuesAsync(ReferenceTypeId typeId, FieldId[] fields) { var conn = ConnectionOrError; var sizeInfo = conn.GetIdSizeInfo(); var t = conn.SendAsync(JdwpPacket.CreateCommand(conn, Nr, 6, typeId.Size + 4 + (sizeInfo.FieldIdSize * fields.Length), x => { var data = x.Data; typeId.WriteTo(data); data.SetInt(fields.Length); foreach (var fieldId in fields) { fieldId.WriteTo(data); } })); return(t.ContinueWith(x => { x.ForwardException(); var result = x.Result; result.ThrowOnError(); var data = result.Data; var count = data.GetInt(); var list = new List <Value>(count); for (var i = 0; i < count; i++) { var value = new Value(data); list.Add(value); } return list; })); }
/// <summary> /// Write this location into the given packet writer. /// </summary> public void WriteTo(JdwpPacket.DataReaderWriter writer) { writer.SetByte((byte)GetType(Class)); Class.WriteTo(writer); Method.WriteTo(writer); writer.SetULong(Index); }
/// <summary> /// Write the modifier to the writer of a packet. /// In this method the kind byte is written override to write additional data. /// </summary> internal override void WriteTo(JdwpPacket.DataReaderWriter writer) { base.WriteTo(writer); exceptionClassId.WriteTo(writer); writer.SetBoolean(caught); writer.SetBoolean(uncaught); }
/// <summary> /// Returns information for each method in a reference type. Inherited methods are not included. The list of methods will include constructors /// (identified with the name "<init>"), the initialization method (identified with the name "<clinit>") if present, and any synthetic methods /// created by the compiler. Methods are returned in the order they occur in the class file. /// </summary> public Task <List <MethodInfo> > MethodsAsync(ReferenceTypeId id) { var conn = ConnectionOrError; var sizeInfo = conn.GetIdSizeInfo(); var t = conn.SendAsync(JdwpPacket.CreateCommand(conn, Nr, 15, sizeInfo.ReferenceTypeIdSize, x => id.WriteTo(x.Data))); return(t.ContinueWith(x => { x.ForwardException(); var result = x.Result; result.ThrowOnError(); var data = result.Data; var count = data.GetInt(); var list = new List <MethodInfo>(count); for (var i = 0; i < count; i++) { var methodId = new MethodId(data); var name = data.GetString(); var signature = data.GetString(); var genericSignature = data.GetString(); var accessFlags = data.GetInt(); list.Add(new MethodInfo(methodId, name, signature, genericSignature, accessFlags)); } return list; })); }
/// <summary> /// Returns the JNI signature of a reference type. JNI signature formats are described in the Java Native Inteface Specification /// For primitive classes the returned signature is the signature of the corresponding primitive type; for example, "I" is returned /// as the signature of the class represented by java.lang.Integer.TYPE. /// </summary> public Task <string> SignatureAsync(ReferenceTypeId id) { var conn = ConnectionOrError; var sizeInfo = conn.GetIdSizeInfo(); var t = conn.SendAsync(JdwpPacket.CreateCommand(conn, Nr, 1, sizeInfo.ReferenceTypeIdSize, x => id.WriteTo(x.Data))); return(t.ContinueWith(x => { x.ForwardException(); var result = x.Result; result.ThrowOnError(); return result.Data.GetString(); })); }
/// <summary> /// Returns the immediate superclass of a class. /// </summary> public Task <ClassId> SuperclassAsync(ReferenceTypeId id) { var conn = ConnectionOrError; var t = conn.SendAsync(JdwpPacket.CreateCommand(conn, Nr, 1, id.Size, x => id.WriteTo(x.Data))); return(t.ContinueWith(x => { x.ForwardException(); var result = x.Result; result.ThrowOnError(); return new ClassId(result.Data); })); }
/// <summary> /// Write the modifier to the writer of a packet. /// In this method the kind byte is written override to write additional data. /// </summary> internal override void WriteTo(JdwpPacket.DataReaderWriter writer) { base.WriteTo(writer); classId.WriteTo(writer); fieldId.WriteTo(writer); }