Exemplo n.º 1
0
 public ClassInfo(ReferenceTypeId typeId, string signature, string genericSignature, Jdwp.ClassStatus status)
 {
     TypeId = typeId;
     Signature = signature;
     GenericSignature = genericSignature;
     Status = status;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DalvikLocationBreakpoint(Jdwp.EventKind eventKind, DocumentPosition documentPosition, TypeEntry typeEntry, MethodEntry methodEntry)
     : base(eventKind)
 {
     this.documentPosition = documentPosition;
     this.typeEntry = typeEntry;
     this.methodEntry = methodEntry;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DalvikLocationBreakpoint(Jdwp.EventKind eventKind, SourceCodePosition sourcePosition, TypeEntry typeEntry, MethodEntry methodEntry)
     : base(eventKind)
 {
     this.typeEntry = typeEntry;
     this.methodEntry = methodEntry;
     SourceCodePosition = sourcePosition;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Read an untagged value.
 /// </summary>
 private static object ReadUntaggedValue(JdwpPacket.DataReaderWriter readerWriter, Jdwp.Tag tag)
 {
     switch (tag)
     {
         case Jdwp.Tag.Array:
         case Jdwp.Tag.Object:
         case Jdwp.Tag.String:
         case Jdwp.Tag.Thread:
         case Jdwp.Tag.ThreadGroup:
         case Jdwp.Tag.ClassLoader:
         case Jdwp.Tag.ClassObject:
             return new ObjectId(readerWriter);
         case Jdwp.Tag.Byte:
             return readerWriter.GetByte();
         case Jdwp.Tag.Char:
             return (char)readerWriter.GetInt16();
         case Jdwp.Tag.Float:
             return readerWriter.GetFloat();
         case Jdwp.Tag.Double:
             return readerWriter.GetDouble();
         case Jdwp.Tag.Int:
             return readerWriter.GetInt();
         case Jdwp.Tag.Long:
             return readerWriter.GetLong();
         case Jdwp.Tag.Short:
             return readerWriter.GetInt16();
         case Jdwp.Tag.Void:
             return null;
         case Jdwp.Tag.Boolean:
             return readerWriter.GetBoolean();
         default:
             throw new ArgumentException("Unknown tag " + (int)tag);
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Clear an event request. See JDWP.EventKind for a complete list of events that can be cleared. Only the event request matching the 
 /// specified event kind and requestID is cleared. If there isn't a matching event request the command is a no-op and does not result 
 /// in an error. Automatically generated events do not have a corresponding event request and may not be cleared using this command.
 /// </summary>
 public Task ClearAsync(Jdwp.EventKind eventKind, int requestId)
 {
     var conn = ConnectionOrError;
     var t = conn.SendAsync(JdwpPacket.CreateCommand(conn, Nr, 2, 5, x => {
         var data = x.Data;
         data.SetByte((byte)eventKind);
         data.SetInt(requestId);
     }));
     return t.ContinueWith(x => {
         x.ForwardException();
         var result = x.Result;
         result.ThrowOnError();
     });
 }
Exemplo n.º 6
0
 /// <summary>
 /// Set an event request. When the event described by this request occurs, an event is sent from the target VM. 
 /// If an event occurs that has not been requested then it is not sent from the target VM. The two exceptions to this are the 
 /// VM Start Event and the VM Death Event which are automatically generated events - see Composite Command for further details.
 /// </summary>
 /// <returns>Task that returns a requestId</returns>
 public Task<int> SetAsync(Jdwp.EventKind eventKind, Jdwp.SuspendPolicy suspendPolicy, params EventModifier[] modifiers)
 {
     var conn = ConnectionOrError;
     var sizeInfo = conn.GetIdSizeInfo();
     var size = 6 + modifiers.Sum(x => x.DataSize);
     var t = conn.SendAsync(JdwpPacket.CreateCommand(conn, Nr, 1, size, x => {
         var data = x.Data;
         data.SetByte((byte) eventKind);
         data.SetByte((byte)suspendPolicy);
         data.SetInt(modifiers.Length);
         foreach (var modifier in modifiers)
         {
             modifier.WriteTo(data);
         }
     }));
     return t.ContinueWith(x => {
         x.ForwardException();
         var result = x.Result;
         result.ThrowOnError();
         return result.Data.GetInt();
     });
 }
Exemplo n.º 7
0
 /// <summary>
 /// Read an untagged value.
 /// </summary>
 private static void WriteValue(JdwpPacket.DataReaderWriter data, Jdwp.Tag tag, object obj)
 {
     switch (tag)
     {
         //case Jdwp.Tag.Array:
         //case Jdwp.Tag.Object:
         //case Jdwp.Tag.String:
         //case Jdwp.Tag.Thread:
         //case Jdwp.Tag.ThreadGroup:
         //case Jdwp.Tag.ClassLoader:
         //case Jdwp.Tag.ClassObject:
         //    return new ObjectId(readerWriter);
         case Jdwp.Tag.Byte:
             data.SetByte((byte)obj);
             break;
         case Jdwp.Tag.Short:
         case Jdwp.Tag.Char:
             data.SetInt16((int) obj);
             break;
         //case Jdwp.Tag.Float:
         //    readerWriter.GetFloat(); //?
         //    break;
         //case Jdwp.Tag.Double:
         //    return readerWriter.SetDouble(); //?
         case Jdwp.Tag.Int:
             data.SetInt((int)obj);
             break;
         case Jdwp.Tag.Long:
             data.SetLong((long) obj);
             break;
         case Jdwp.Tag.Boolean:
             data.SetBoolean((bool)obj);
             break;
         default:
             throw new ArgumentException("unsupported tag " + tag);
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DebugLocationBreakpoint(Jdwp.EventKind eventKind, SourceCodePosition sourcePosition, TypeEntry typeEntry, MethodEntry methodEntry, BreakpointBookmark bookmark)
     : base(eventKind, sourcePosition, typeEntry, methodEntry)
 {
     this.bookmark = bookmark;
     InvalidateBookmark();
 }
Exemplo n.º 9
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DebugLocationBreakpoint(Jdwp.EventKind eventKind, SourceCodePosition sourcePosition, TypeEntry typeEntry, MethodEntry methodEntry, DebugBoundBreakpoint<DebugLocationBreakpoint> boundBreakpoint)
     : base(eventKind, sourcePosition, typeEntry, methodEntry)
 {
     this.boundBreakpoint = boundBreakpoint;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Default ctor
 /// </summary>
 protected DalvikBreakpoint(Jdwp.EventKind eventKind)
 {
     this.eventKind = eventKind;
 }
Exemplo n.º 11
0
        protected object ParsePrimitive(string value, Jdwp.Tag tag, int defaultRadix)
        {
            string parseVal = value;
            if (value.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
            {
                parseVal = value.Substring(2);
                defaultRadix = 16;
            }

            switch (tag)
            {
                case Jdwp.Tag.Byte:
                {
                    byte val;
                    if (byte.TryParse(parseVal, defaultRadix == 16 ? NumberStyles.HexNumber : NumberStyles.Any, CultureInfo.CurrentCulture, out val))
                        return val;
                    return sbyte.Parse(parseVal, defaultRadix == 16 ? NumberStyles.HexNumber : NumberStyles.Any, CultureInfo.CurrentCulture);
                }
                case Jdwp.Tag.Short:
                {
                    short val;
                    if (short .TryParse(parseVal, defaultRadix == 16 ? NumberStyles.HexNumber : NumberStyles.Any, CultureInfo.CurrentCulture, out val))
                        return val;
                    return (short)ushort.Parse(parseVal, defaultRadix == 16 ? NumberStyles.HexNumber : NumberStyles.Any, CultureInfo.CurrentCulture);
                }
                case Jdwp.Tag.Int:
                {
                    int val;
                    if (int.TryParse(parseVal, defaultRadix == 16 ? NumberStyles.HexNumber : NumberStyles.Any, CultureInfo.CurrentCulture, out val))
                        return val;
                    return (int)uint.Parse(parseVal, defaultRadix == 16 ? NumberStyles.HexNumber : NumberStyles.Any, CultureInfo.CurrentCulture);
                }
                case Jdwp.Tag.Long:
                {
                    long val;
                    if (long.TryParse(parseVal, defaultRadix == 16 ? NumberStyles.HexNumber : NumberStyles.Any, CultureInfo.CurrentCulture, out val))
                        return val;
                    return (long)ulong.Parse(parseVal, defaultRadix == 16 ? NumberStyles.HexNumber : NumberStyles.Any, CultureInfo.CurrentCulture);
                }
                case Jdwp.Tag.Char:
                {
                    if (value.Length == 1)
                        return value[0];
                    goto case Jdwp.Tag.Short;
                }
                case Jdwp.Tag.Double:
                {
                    return Convert.ToDouble(value);
                }
                case Jdwp.Tag.Float:
                {
                    return Convert.ToSingle(value);
                }
                case Jdwp.Tag.Boolean:
                {
                    return Convert.ToBoolean(value);
                }
                default:
                    throw new NotImplementedException("cannot parse to " + tag);
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// Sets the status of the class.
 /// </summary>
 internal void SetStatusIfNull(Jdwp.ClassStatus value)
 {
     if (!status.HasValue)
         status = value;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Update the info of a given class.
 /// </summary>
 private void ProcessClassData(ReferenceTypeId typeId, string signature, Jdwp.ClassStatus status)
 {
     lock (dataLock)
     {
         DalvikReferenceType refType;
         if (!classes.TryGetValue(typeId, out refType))
         {
             // Not found, create new one
             refType = CreateReferenceType(typeId);
             classes[typeId] = refType;
             classesBySignature[signature] = refType;
         }
         refType.SetSignatureIfNull(signature);
         refType.SetStatusIfNull(status);
     }
 }
Exemplo n.º 14
0
 public StepRequest(DalvikThread thread, Jdwp.StepDepth stepDepth, StepMode stepMode = StepMode.Line)
 {
     Thread = thread;
     StepDepth = stepDepth;
     StepMode = stepMode;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public EventStepModifier(ThreadId threadId, Jdwp.StepSize stepSize, Jdwp.StepDepth stepDepth)
     : base(10)
 {
     this.threadId = threadId;
     this.stepSize = stepSize;
     this.stepDepth = stepDepth;
 }
Exemplo n.º 16
0
 public ThreadStatusInfo(Jdwp.ThreadStatus threadStatus, Jdwp.SuspendStatus suspendStatus)
 {
     ThreadStatus = threadStatus;
     SuspendStatus = suspendStatus;
 }
Exemplo n.º 17
0
 public SlotRequest(int slot, Jdwp.Tag tag)
 {
     Slot = slot;
     Tag = tag;
 }
Exemplo n.º 18
0
        /// <summary>
        /// Get all local registers for this frame.
        /// </summary>
        /// <returns></returns>
        public Task<List<DalvikStackFrameValue>> GetRegistersAsync(bool parametersOnly = false, Jdwp.Tag type = Jdwp.Tag.Int, params int[] indizes)
        {
            if (parametersOnly && parameters != null)
                return parameters.AsTask();
            if (!parametersOnly && registers != null && indizes.Length == 0) 
                return registers.AsTask();

            return Task.Factory.StartNew(() =>
            {
                var ret = new List<DalvikStackFrameValue>();

                var loc = GetDocumentLocationAsync().Await(DalvikProcess.VmTimeout);

                List<Register> regDefs;
                
                MethodDisassembly methodDiss = thread.Manager.Process.DisassemblyProvider.GetFromLocation(loc);

                if(indizes.Length == 0)
                {
                    if (methodDiss == null)
                        return ret;

                    var body = methodDiss.Method.Body;
                    regDefs = (parametersOnly ? body.Registers.Where(r=>body.IsComing(r))
                                              : body.Registers)
                              .Where(p => indizes.Length == 0 || indizes.Contains(p.Index))
                              .OrderBy(p=>p.Index)
                              .ToList();
                }
                else
                {
                    regDefs = indizes.Select(i => new Register(i)).ToList();
                }

                var requests = regDefs.Select(reg => new SlotRequest(reg.Index, type)).ToList();
   
                var regValues = Debugger.StackFrame.GetValuesAsync(thread.Id, Id, requests.ToArray())
                                                   .Await(DalvikProcess.VmTimeout);

                var process = thread.Manager.Process;
                for (int i = 0; i < regDefs.Count && i < regValues.Count; ++i)
                {
                    var reg = regDefs[i];
                    if (methodDiss != null)
                    {
                        var body = methodDiss.Method.Body;
                        bool isParam = body.IsComing(reg);

                        string regName = MethodDisassembly.FormatRegister(reg, body);
                        var valInfo = new VariableInfo(0, regName, null, null, body.Instructions.Count, reg.Index);

                        DalvikStackFrameValue val = new DalvikStackFrameValue(regValues[i], valInfo, isParam, process);
                        ret.Add(val);
                    }
                    else
                    {
                        string regName = "r" + reg.Index;
                        var valInfo = new VariableInfo(0, regName, null, null, int.MaxValue, reg.Index);

                        var val = new DalvikStackFrameValue(regValues[i], valInfo, false, process);
                        ret.Add(val);
                    }
                }

                if (indizes.Length > 0)
                    return ret;

                if(parametersOnly)
                    parameters = parameters ?? ret;
                else
                    registers = registers ?? ret;
                return ret;
            });
        }
Exemplo n.º 19
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DebugLocationBreakpoint(Jdwp.EventKind eventKind, DocumentPosition documentPosition, TypeEntry typeEntry, MethodEntry methodEntry, DebugBoundBreakpoint<DebugLocationBreakpoint> boundBreakpoint)
     : base(eventKind, documentPosition, typeEntry, methodEntry)
 {
     this.boundBreakpoint = boundBreakpoint;
 }
Exemplo n.º 20
0
 /// <summary>
 /// Read an untagged value.
 /// </summary>
 public Value(JdwpPacket.DataReaderWriter readerWriter, Jdwp.Tag tag)
 {
     Tag = tag;
     ValueObject = ReadUntaggedValue(readerWriter, tag);
 }
Exemplo n.º 21
0
 public StepRequest(DalvikThread thread, Jdwp.StepDepth stepDepth)
 {
     Thread = thread;
     StepDepth = stepDepth;
 }
Exemplo n.º 22
0
 public SlotValue(int slot, Jdwp.Tag tag, object value)
 {
     Slot = slot;
     Value = value;
     Tag = tag;
 }