예제 #1
0
            /// <summary>
            /// Returns reference types for all classes currently loaded by the target VM.
            /// </summary>
            public Task <List <ClassInfo> > AllClassesWithGenericAsync()
            {
                var conn     = ConnectionOrError;
                var sizeInfo = conn.GetIdSizeInfo();
                var t        = conn.SendAsync(JdwpPacket.CreateCommand(conn, Nr, 20, 0));

                return(t.ContinueWith(x => {
                    x.ForwardException();
                    var result = x.Result;
                    result.ThrowOnError();
                    var data = result.Data;
                    var count = data.GetInt();
                    var list = new List <ClassInfo>();
                    while (count > 0)
                    {
                        count--;
                        var typeId = ReferenceTypeId.Read(data);
                        var signature = data.GetString();
                        var genericSignature = data.GetString();
                        var status = data.GetInt();
                        list.Add(new ClassInfo(typeId, signature, genericSignature, (Jdwp.ClassStatus)status));
                    }
                    return list;
                }));
            }
예제 #2
0
            /// <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;
                }));
            }
예제 #3
0
            /// <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;
                }));
            }
예제 #4
0
            /// <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 "&lt;init&gt;"), the initialization method (identified with the name "&lt;clinit&gt;") 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;
                }));
            }
예제 #5
0
 /// <summary>
 /// Default ctor
 /// </summary>
 /// <param name="exceptionClassId">Exception to report. Null (0) means report exceptions of all types. A non-null type restricts the reported exception events to exceptions of the given type or any of its subtypes.</param>
 /// <param name="caught">Report caught exceptions </param>
 /// <param name="uncaught">Report uncaught exceptions. Note that it is not always possible to determine whether an exception is caught or uncaught at the time it is thrown. See the exception event catch location under composite events for more information.</param>
 public ExceptionOnlyModifier(ReferenceTypeId exceptionClassId, bool caught, bool uncaught)
     : base(8)
 {
     if (exceptionClassId == null)
     {
         throw new ArgumentNullException("exceptionClassId");
     }
     this.exceptionClassId = exceptionClassId;
     this.caught           = caught;
     this.uncaught         = uncaught;
 }
예제 #6
0
            /// <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);
                }));
            }
예제 #7
0
            /// <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 runtime type of the object. The runtime type will be a class or an array.
            /// </summary>
            public Task <ReferenceTypeId> ReferenceTypeAsync(ObjectId objectId)
            {
                var conn = ConnectionOrError;
                var t    = conn.SendAsync(JdwpPacket.CreateCommand(conn, Nr, 1, objectId.Size,
                                                                   x => {
                    var data = x.Data;
                    objectId.WriteTo(data);
                }));

                return(t.ContinueWith(x => {
                    x.ForwardException();
                    var result = x.Result;
                    result.ThrowOnError();
                    return ReferenceTypeId.Read(result.Data);
                }));
            }
예제 #9
0
 /// <summary>
 /// Gets the type for the given reference id.
 /// </summary>
 private static Jdwp.TypeTag GetType(ReferenceTypeId classId)
 {
     if (classId is ClassId)
     {
         return(Jdwp.TypeTag.Class);
     }
     if (classId is InterfaceId)
     {
         return(Jdwp.TypeTag.Interface);
     }
     if (classId is ArrayTypeId)
     {
         return(Jdwp.TypeTag.Array);
     }
     throw new ArgumentException("Unknown classid " + classId);
 }
예제 #10
0
            /// <summary>
            /// Returns reference types that match the given signature.
            /// </summary>
            public Task <List <ClassInfo> > ClassBySignatureAsync(string signature)
            {
                var conn     = ConnectionOrError;
                var sizeInfo = conn.GetIdSizeInfo();
                var t        = conn.SendAsync(JdwpPacket.CreateCommand(conn, Nr, 2, JdwpPacket.DataReaderWriter.GetStringSize(signature), x => x.Data.SetString(signature)));

                return(t.ContinueWith(x => {
                    x.ForwardException();
                    var result = x.Result;
                    result.ThrowOnError();
                    var data = result.Data;
                    var count = data.GetInt();
                    var list = new List <ClassInfo>();
                    while (count > 0)
                    {
                        count--;
                        var typeId = ReferenceTypeId.Read(data);
                        var status = data.GetInt();
                        list.Add(new ClassInfo(typeId, signature, signature, (Jdwp.ClassStatus)status));
                    }
                    return list;
                }));
            }
예제 #11
0
 /// <summary>
 /// Read an value.
 /// </summary>
 public Location(JdwpPacket.DataReaderWriter readerWriter)
 {
     Class  = ReferenceTypeId.Read(readerWriter);
     Method = new MethodId(readerWriter);
     Index  = readerWriter.GetULong();
 }
예제 #12
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public Location(ReferenceTypeId classId, MethodId methodId, ulong index)
 {
     Class  = classId;
     Method = methodId;
     Index  = index;
 }
예제 #13
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public FieldOnlyModifier(ReferenceTypeId classId, FieldId fieldId)
     : base(9)
 {
     this.classId = classId;
     this.fieldId = fieldId;
 }
예제 #14
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public ClassOnlyModifier(ReferenceTypeId classId)
     : base(4)
 {
     this.classId = classId;
 }