public ClassInfo(ReferenceTypeId typeId, string signature, string genericSignature, Jdwp.ClassStatus status) { TypeId = typeId; Signature = signature; GenericSignature = genericSignature; Status = status; }
/// <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; }
/// <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; }
/// <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); } }
/// <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(); }); }
/// <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(); }); }
/// <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); } }
/// <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(); }
/// <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; }
/// <summary> /// Default ctor /// </summary> protected DalvikBreakpoint(Jdwp.EventKind eventKind) { this.eventKind = eventKind; }
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); } }
/// <summary> /// Sets the status of the class. /// </summary> internal void SetStatusIfNull(Jdwp.ClassStatus value) { if (!status.HasValue) status = value; }
/// <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); } }
public StepRequest(DalvikThread thread, Jdwp.StepDepth stepDepth, StepMode stepMode = StepMode.Line) { Thread = thread; StepDepth = stepDepth; StepMode = stepMode; }
/// <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; }
public ThreadStatusInfo(Jdwp.ThreadStatus threadStatus, Jdwp.SuspendStatus suspendStatus) { ThreadStatus = threadStatus; SuspendStatus = suspendStatus; }
public SlotRequest(int slot, Jdwp.Tag tag) { Slot = slot; Tag = tag; }
/// <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; }); }
/// <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; }
/// <summary> /// Read an untagged value. /// </summary> public Value(JdwpPacket.DataReaderWriter readerWriter, Jdwp.Tag tag) { Tag = tag; ValueObject = ReadUntaggedValue(readerWriter, tag); }
public StepRequest(DalvikThread thread, Jdwp.StepDepth stepDepth) { Thread = thread; StepDepth = stepDepth; }
public SlotValue(int slot, Jdwp.Tag tag, object value) { Slot = slot; Value = value; Tag = tag; }