/// <summary>
            /// Gets the current call stack of the thread with given id.
            /// </summary>
            public Task<List<Tuple<FrameId, Location>>> FramesAsync(ThreadId id, int length = -1)
            {
                var conn = ConnectionOrError;
                var sizeInfo = conn.GetIdSizeInfo();
                var t = conn.SendAsync(JdwpPacket.CreateCommand(conn, Nr, 6, sizeInfo.ObjectIdSize + 8,
                    x => {
                        id.WriteTo(x.Data);
                        x.Data.SetInt(0); // start frame
                        x.Data.SetInt(length); // length -1 == all
                    }));
                return t.ContinueWith(x => {
                    x.ForwardException();
                    var result = x.Result;
                    result.ThrowOnError();

                    var count = result.Data.GetInt();
                    var list = new List<Tuple<FrameId, Location>>(count);
                    for (var i = 0; i < count; i++)
                    {
                        var frame = new FrameId(result.Data, sizeInfo);
                        var location = new Location(result.Data);
                        list.Add(Tuple.Create(frame, location));
                    }
                    return list;
                });
            }
Example #2
0
        protected override void Execute(NativeActivityContext context)
        {
            var script  = Script.Get(context);
            var frameid = FrameId.Get(context);
            var browser = Browser.Get(context);
            var timeout = TimeSpan.FromSeconds(3);

            script = Interfaces.Selector.Selector.ReplaceVariables(script, context.DataContext);
            if (browser != "chrome" && browser != "ff" && browser != "edge")
            {
                browser = "chrome";
            }
            if (!script.Contains(Environment.NewLine) && !script.Contains(";") && !script.Contains("return"))
            {
                script = "return " + script;
            }
            var result = NMHook.ExecuteScript(browser, frameid, -1, script, timeout);

            if (result == null)
            {
                result = "[]";
            }
            var results = JsonConvert.DeserializeObject <object[]>(result.ToString());

            Result.Set(context, results[0]);
            Results.Set(context, results);
        }
Example #3
0
        public void WriteTo(Stream stream)
        {
            SubmeshId.WriteTo(stream);
            BinaryWriter writer = new BinaryWriter(stream);

            writer.Write(AlwaysZero16);
            writer.Write(SelectorList.Count);
            writer.Write(children.Count);
            Name.WriteTo(stream);
            writer.Write(NumIndices);
            writer.Write(MeshIndices);
            writer.Write(UnknownIndices);
            foreach (odfMorphProfile profile in children)
            {
                profile.WriteTo(stream);
            }
            foreach (odfMorphSelector sel in SelectorList)
            {
                sel.WriteTo(stream);
            }
            writer.Write(ClipType);
            if (ClipType != 0)
            {
                writer.Write(MorphClipList.Count);
                foreach (odfMorphClip clip in MorphClipList)
                {
                    clip.WriteTo(stream);
                }
            }
            writer.Write(MinusOne);
            FrameId.WriteTo(stream);
        }
Example #4
0
 virtual protected void PostUpdate(FrameId frameId, CommandBuffer cb, uint rendertargetSlice)
 {
     if (!IsNativeDepth())
     {
         cb.ReleaseTemporaryRT(m_TempDepthId);
     }
 }
Example #5
0
            protected bool Alloc(FrameId frameId, Key key, uint width, uint height, out uint cachedEntryIdx, VectorArray <ShadowPayload> payload)
            {
                CachedEntry ce = new CachedEntry();

                ce.key                 = key;
                ce.current.frameId     = frameId;
                ce.current.contentHash = -1;
                ce.current.slice       = 0;
                ce.current.viewport    = new Rect(0, 0, width, height);

                uint idx;

                if (m_EntryCache.FindFirst(out idx, ref key, (ref Key k, ref CachedEntry entry) => { return(k.id == entry.key.id && k.faceIdx == entry.key.faceIdx); }))
                {
                    if (m_EntryCache[idx].current.viewport.width == width && m_EntryCache[idx].current.viewport.height == height)
                    {
                        ce.previous       = m_EntryCache[idx].current;
                        m_EntryCache[idx] = ce;
                        cachedEntryIdx    = m_ActiveEntriesCount;
                        m_EntryCache.SwapUnchecked(m_ActiveEntriesCount++, idx);
                        return(true);
                    }
                    else
                    {
                        m_EntryCache.SwapUnchecked(idx, m_EntryCache.Count() - 1);
                        m_EntryCache.Purge(1, Free);
                    }
                }

                idx = m_EntryCache.Count();
                m_EntryCache.Add(ce);
                cachedEntryIdx = m_ActiveEntriesCount;
                m_EntryCache.SwapUnchecked(m_ActiveEntriesCount++, idx);
                return(true);
            }
        public override int GetHashCode()
        {
            int hash = 1;

            if (FrameId != 0L)
            {
                hash ^= FrameId.GetHashCode();
            }
            if (PayloadType != 0)
            {
                hash ^= PayloadType.GetHashCode();
            }
            if (EngineName.Length != 0)
            {
                hash ^= EngineName.GetHashCode();
            }
            if (Payload.Length != 0)
            {
                hash ^= Payload.GetHashCode();
            }
            if (engineFields_ != null)
            {
                hash ^= EngineFields.GetHashCode();
            }
            return(hash);
        }
Example #7
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (header_ != null)
            {
                hash ^= Header.GetHashCode();
            }
            if (FrameId.Length != 0)
            {
                hash ^= FrameId.GetHashCode();
            }
            if (Format.Length != 0)
            {
                hash ^= Format.GetHashCode();
            }
            if (Data.Length != 0)
            {
                hash ^= Data.GetHashCode();
            }
            if (MeasurementTime != 0D)
            {
                hash ^= MeasurementTime.GetHashCode();
            }
            return(hash);
        }
Example #8
0
        protected override void Execute(NativeActivityContext context)
        {
            var script  = Script.Get(context);
            var frameid = FrameId.Get(context);
            var browser = Browser.Get(context);
            var timeout = TimeSpan.FromSeconds(3);

            script = Interfaces.Selector.Selector.ReplaceVariables(script, context.DataContext);
            if (browser != "chrome" && browser != "ff" && browser != "edge")
            {
                browser = "chrome";
            }
            var result = NMHook.ExecuteScript(browser, frameid, -1, script, timeout);

            if (result == null)
            {
                result = "[]";
            }
            var results = JsonConvert.DeserializeObject <object[]>(result.ToString());

            if (results != null && results.Length > 0)
            {
                Result.Set(context, results[0]);
            }
            else
            {
                Result.Set(context, null);
            }
            Results.Set(context, results);
        }
Example #9
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (FrameId != 0)
            {
                hash ^= FrameId.GetHashCode();
            }
            if (ShapeType != global::Physics.Telemetry.Serialised.ShapeTypePacket.Obb)
            {
                hash ^= ShapeType.GetHashCode();
            }
            if (obbShape_ != null)
            {
                hash ^= ObbShape.GetHashCode();
            }
            if (tetrahedronShape_ != null)
            {
                hash ^= TetrahedronShape.GetHashCode();
            }
            if (convexHullShape_ != null)
            {
                hash ^= ConvexHullShape.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #10
0
 /// <summary>
 /// Returns the value of one or more local variables in a given frame. Each variable must be visible at the frame's code index. 
 /// Even if local variable information is not available, values can be retrieved if the front-end is able to determine the correct 
 /// local variable index. (Typically, this index can be determined for method arguments from the method signature without access to 
 /// the local variable table information.)
 /// </summary>
 public Task<List<Value>> GetValuesAsync(ThreadId threadId, FrameId frameId, SlotRequest[] slots)
 {
     var conn = ConnectionOrError;
     DLog.Debug(DContext.DebuggerLibCommands, () => string.Format("StackFrame.GetValues {0}", string.Join(", ", slots.Select(x => x.ToString()))));
     var t = conn.SendAsync(JdwpPacket.CreateCommand(conn, Nr, 1, threadId.Size + frameId.Size + 4 + (slots.Length * 5), 
         x => {
             var data = x.Data;
             threadId.WriteTo(data);
             frameId.WriteTo(data);
             data.SetInt(slots.Length);
             foreach (var slot in slots)
             {
                 data.SetInt(slot.Slot);
                 data.SetByte((byte) slot.Tag);
             }
         }));
     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;
     });
 }
Example #11
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (header_ != null)
            {
                hash ^= Header.GetHashCode();
            }
            if (FrameId.Length != 0)
            {
                hash ^= FrameId.GetHashCode();
            }
            if (IsDense != false)
            {
                hash ^= IsDense.GetHashCode();
            }
            hash ^= point_.GetHashCode();
            if (MeasurementTime != 0D)
            {
                hash ^= MeasurementTime.GetHashCode();
            }
            if (Width != 0)
            {
                hash ^= Width.GetHashCode();
            }
            if (Height != 0)
            {
                hash ^= Height.GetHashCode();
            }
            return(hash);
        }
Example #12
0
 override public bool Reserve(FrameId frameId, ref ShadowData shadowData, ShadowRequest sr, uint width, uint height, ref VectorArray <ShadowData> entries, ref VectorArray <ShadowPayload> payload, VisibleLight[] lights)
 {
     for (uint i = 0, cnt = sr.facecount; i < cnt; ++i)
     {
         m_TmpWidths[i]  = width;
         m_TmpHeights[i] = height;
     }
     return(Reserve(frameId, ref shadowData, sr, m_TmpWidths, m_TmpHeights, ref entries, ref payload, lights));
 }
Example #13
0
            public override void ProcessShadowRequests(FrameId frameId, CullResults cullResults, Camera camera, VisibleLight[] lights, ref uint shadowRequestsCount, int[] shadowRequests, out int[] shadowDataIndices)
            {
                shadowDataIndices = null;

                // TODO:
                // Cached the cullResults here so we don't need to pass them around.
                // Allocate needs to pass them to the shadowmaps, as the ShadowUtil functions calculating view/proj matrices need them to call into C++ land.
                // Ideally we can get rid of that at some point, then we wouldn't need to cache them here, anymore.
                foreach (var sm in m_Shadowmaps)
                {
                    sm.Assign(cullResults);
                }

                if (shadowRequestsCount == 0 || lights == null || shadowRequests == null)
                {
                    shadowRequestsCount = 0;
                    return;
                }

                // first sort the shadow casters according to some priority
                PrioritizeShadowCasters(camera, lights, shadowRequestsCount, shadowRequests);

                // next prune them based on some logic
                VectorArray <int> requestedShadows = new VectorArray <int>(shadowRequests, 0, shadowRequestsCount, false);

                m_TmpRequests.Reset(shadowRequestsCount);
                uint totalGranted;

                PruneShadowCasters(camera, lights, ref requestedShadows, ref m_TmpRequests, out totalGranted);

                // if there are no shadow casters at this point -> bail
                if (totalGranted == 0)
                {
                    shadowRequestsCount = 0;
                    return;
                }

                // TODO: Now would be a good time to kick off the culling jobs for the granted requests - but there's no way to control that at the moment.

                // finally go over the lights deemed shadow casters and try to fit them into the shadow map
                // shadowmap allocation must succeed at this point.
                m_ShadowCtxt.ClearData();
                ShadowDataVector    shadowVector  = m_ShadowCtxt.shadowDatas;
                ShadowPayloadVector payloadVector = m_ShadowCtxt.payloads;

                m_ShadowIndices.Reset(m_TmpRequests.Count());
                AllocateShadows(frameId, lights, totalGranted, ref m_TmpRequests, ref m_ShadowIndices, ref shadowVector, ref payloadVector);
                Debug.Assert(m_TmpRequests.Count() == m_ShadowIndices.Count());
                m_ShadowCtxt.shadowDatas = shadowVector;
                m_ShadowCtxt.payloads    = payloadVector;

                // and set the output parameters
                uint offset;

                shadowDataIndices = m_ShadowIndices.AsArray(out offset, out shadowRequestsCount);
            }
Example #14
0
 public override void RenderShadows(FrameId frameId, ScriptableRenderContext renderContext, CullResults cullResults, VisibleLight[] lights)
 {
     using (new Utilities.ProfilingSample("Render Shadows Exp", renderContext))
     {
         foreach (var sm in m_Shadowmaps)
         {
             sm.Update(frameId, renderContext, cullResults, lights);
         }
     }
 }
Example #15
0
 virtual protected void PreUpdate(FrameId frameId, CommandBuffer cb, uint rendertargetSlice)
 {
     cb.SetRenderTarget(m_ShadowmapId, 0, (CubemapFace)0, (int)rendertargetSlice);
     if (!IsNativeDepth())
     {
         cb.GetTemporaryRT(m_TempDepthId, (int)m_Width, (int)m_Height, (int)m_ShadowmapBits, FilterMode.Bilinear, RenderTextureFormat.Shadowmap, RenderTextureReadWrite.Default);
         cb.SetRenderTarget(new RenderTargetIdentifier(m_TempDepthId));
     }
     cb.ClearRenderTarget(true, !IsNativeDepth(), m_ClearColor);
 }
Example #16
0
        public void WriteTo(Stream stream)
        {
            FrameId.WriteTo(stream);
            BinaryWriter writer = new BinaryWriter(stream);

            writer.Write(NumberIndices);
            writer.Write(AlwaysZero24perIndex);
            writer.Write(VertexIndexArray);
            writer.Write(WeightArray);
            writer.Write(Matrix);
        }
Example #17
0
 private void ParseFrameBody()
 {
     if (FrameId.ToUpper()[0] == 'T')
     {
         ParseEncoding();
         ParseTextInfoData();
         IsTextInfoFrame = true;
     }
     else
     {
         byteOffset += (int)Size;
     }
 }
Example #18
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (FrameId.Length != 0)
            {
                hash ^= FrameId.GetHashCode();
            }
            if (stamp_ != null)
            {
                hash ^= Stamp.GetHashCode();
            }
            return(hash);
        }
Example #19
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (FrameId != 0)
            {
                hash ^= FrameId.GetHashCode();
            }
            hash ^= rigidBodies_.GetHashCode();
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #20
0
        protected override void Execute(NativeActivityContext context)
        {
            var script  = Script.Get(context);
            var frameid = FrameId.Get(context);
            var browser = Browser.Get(context);
            var timeout = TimeSpan.FromSeconds(3);

            script = Interfaces.Selector.Selector.ReplaceVariables(script, context.DataContext);
            if (browser != "chrome" && browser != "ff" && browser != "edge")
            {
                browser = "chrome";
            }
            var result = NMHook.ExecuteScript(browser, frameid, -1, script, timeout);

            Result.Set(context, result);
        }
Example #21
0
            protected override void AllocateShadows(FrameId frameId, VisibleLight[] lights, uint totalGranted, ref ShadowRequestVector grantedRequests, ref ShadowIndicesVector shadowIndices, ref ShadowDataVector shadowDatas, ref ShadowPayloadVector shadowmapPayload)
            {
                ShadowData sd = new ShadowData();

                shadowDatas.Reserve(totalGranted);
                shadowIndices.Reserve(grantedRequests.Count());
                for (uint i = 0, cnt = grantedRequests.Count(); i < cnt; ++i)
                {
                    VisibleLight        vl  = lights[grantedRequests[i].index];
                    Light               l   = vl.light;
                    AdditionalLightData ald = l.GetComponent <AdditionalLightData>();

                    // set light specific values that are not related to the shadowmap
                    GPUShadowType shadowtype;
                    ShadowUtils.MapLightType(ald.archetype, vl.lightType, out sd.lightType, out shadowtype);
                    sd.bias    = l.shadowBias;
                    sd.quality = 0;

                    shadowIndices.AddUnchecked((int)shadowDatas.Count());

                    int smidx = 0;
                    while (smidx < k_MaxShadowmapPerType)
                    {
                        if (m_ShadowmapsPerType[(int)shadowtype, smidx].Reserve(frameId, ref sd, grantedRequests[i], (uint)ald.shadowResolution, (uint)ald.shadowResolution, ref shadowDatas, ref shadowmapPayload, lights))
                        {
                            break;
                        }
                        smidx++;
                    }
                    if (smidx == k_MaxShadowmapPerType)
                    {
                        throw new ArgumentException("The requested shadows do not fit into any shadowmap.");
                    }
                }

                // final step for shadowmaps that only gather data during the previous loop and do the actual allocation once they have all the data.
                foreach (var sm in m_Shadowmaps)
                {
                    if (!sm.ReserveFinalize(frameId, ref shadowDatas, ref shadowmapPayload))
                    {
                        throw new ArgumentException("Shadow allocation failed in the ReserveFinalize step.");
                    }
                }
            }
        public override int GetHashCode()
        {
            int hash = 1;

            if (FrameId != 0L)
            {
                hash ^= FrameId.GetHashCode();
            }
            if (Status != 0)
            {
                hash ^= Status.GetHashCode();
            }
            hash ^= results_.GetHashCode();
            if (engineFields_ != null)
            {
                hash ^= EngineFields.GetHashCode();
            }
            return(hash);
        }
Example #23
0
        public jvmtiError GetStackTrace(JniEnvironment nativeEnvironment, ThreadId threadId, int startDepth, int maxFrameCount, out FrameLocationData[] frames)
        {
            frames = null;

            using (var thread = VirtualMachine.GetLocalReferenceForThread(nativeEnvironment, threadId))
            {
                if (!thread.IsAlive)
                {
                    return(jvmtiError.InvalidThread);
                }

                jvmtiFrameInfo[] frameBuffer = new jvmtiFrameInfo[maxFrameCount];
                int        frameCount;
                jvmtiError error = RawInterface.GetStackTrace(this, thread.Value, startDepth, maxFrameCount, frameBuffer, out frameCount);
                if (error != jvmtiError.None)
                {
                    return(error);
                }

                var frameData = new FrameLocationData[frameCount];
                for (int i = 0; i < frameCount; i++)
                {
                    TaggedReferenceTypeId declaringClass;
                    MethodId method = new MethodId(frameBuffer[i]._method.Handle);
                    ulong    index  = (ulong)frameBuffer[i]._location.Value;
                    error = GetMethodDeclaringClass(nativeEnvironment, method, out declaringClass);
                    if (error != jvmtiError.None)
                    {
                        return(error);
                    }

                    FrameId  frameId  = new FrameId(startDepth + i);
                    Location location = new Location(declaringClass, method, index);
                    frameData[i] = new FrameLocationData(frameId, location);
                }

                frames = frameData;
                return(jvmtiError.None);
            }
        }
Example #24
0
            /// <summary>
            /// Returns the value of one or more local variables in a given frame. Each variable must be visible at the frame's code index. 
            /// Even if local variable information is not available, values can be retrieved if the front-end is able to determine the correct 
            /// local variable index. (Typically, this index can be determined for method arguments from the method signature without access to 
            /// the local variable table information.)
            /// </summary>
            public Task<List<Value>> GetValuesAsync(ThreadId threadId, FrameId frameId, SlotRequest[] slots)
            {
                var conn = ConnectionOrError;
                DLog.Debug(DContext.DebuggerLibCommands, () => string.Format("StackFrame.GetValues {0}", string.Join(", ", slots.Select(x => x.ToString()))));
                var t = conn.SendAsync(JdwpPacket.CreateCommand(conn, Nr, 1, threadId.Size + frameId.Size + 4 + (slots.Length * 5),
                    x => {
                        var data = x.Data;
                        threadId.WriteTo(data);
                        frameId.WriteTo(data);
                        data.SetInt(slots.Length);
                        foreach (var slot in slots)
                        {
                            if (slot.Slot == 1000)
                            {
                                // I have seen this crash the VM on a CyanogenMod Android 4.4.4
                                // Samsung GT-I9195. Might be a bug in CyanogenMod.
                                // https://android.googlesource.com/platform/art/+/ffcd9d25199a944625bd3c9a766349c23dcbdb66/runtime/debugger.cc
                                DLog.Debug(DContext.DebuggerLibEvent, "accessing variable with Slot=1000");
                            }

                            data.SetInt(slot.Slot);
                            data.SetByte((byte) slot.Tag);
                        }
                    }));
                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;
                });
            }
        public override int GetHashCode()
        {
            int hash = 1;

            if (FrameId.Length != 0)
            {
                hash ^= FrameId.GetHashCode();
            }
            if (ChildFrameId.Length != 0)
            {
                hash ^= ChildFrameId.GetHashCode();
            }
            if (FilePath.Length != 0)
            {
                hash ^= FilePath.GetHashCode();
            }
            if (Enable != false)
            {
                hash ^= Enable.GetHashCode();
            }
            return(hash);
        }
Example #26
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (FrameId != 0)
            {
                hash ^= FrameId.GetHashCode();
            }
            if (MessageType != global::Physics.Telemetry.Serialised.MessageHeaderMessage.Types.MessageType.RigidBodyUpdate)
            {
                hash ^= MessageType.GetHashCode();
            }
            if (DataSize != 0)
            {
                hash ^= DataSize.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #27
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (FrameId != 0)
            {
                hash ^= FrameId.GetHashCode();
            }
            if (ConsumedFrameTime != 0F)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(ConsumedFrameTime);
            }
            if (FrameProcessingTime != 0F)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(FrameProcessingTime);
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #28
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (header_ != null)
            {
                hash ^= Header.GetHashCode();
            }
            if (FrameId.Length != 0)
            {
                hash ^= FrameId.GetHashCode();
            }
            if (MeasurementTime != 0D)
            {
                hash ^= MeasurementTime.GetHashCode();
            }
            if (Height != 0)
            {
                hash ^= Height.GetHashCode();
            }
            if (Width != 0)
            {
                hash ^= Width.GetHashCode();
            }
            if (Encoding.Length != 0)
            {
                hash ^= Encoding.GetHashCode();
            }
            if (Step != 0)
            {
                hash ^= Step.GetHashCode();
            }
            if (Data.Length != 0)
            {
                hash ^= Data.GetHashCode();
            }
            return(hash);
        }
Example #29
0
            override public bool ReserveFinalize(FrameId frameId, ref VectorArray <ShadowData> entries, ref VectorArray <ShadowPayload> payload)
            {
                if (Layout())
                {
                    // patch up the shadow data contents with the result of the layouting step
                    for (uint i = 0; i < m_ActiveEntriesCount; ++i)
                    {
                        CachedEntry ce = m_EntryCache[i];

                        ShadowData sd = entries[ce.key.shadowDataIdx];
                        // update the shadow data with the actual result of the layouting step
                        sd.scaleOffset = new Vector4(ce.current.viewport.width * m_WidthRcp, ce.current.viewport.height * m_HeightRcp, ce.current.viewport.x * m_WidthRcp, ce.current.viewport.y * m_HeightRcp);
                        sd.PackShadowmapId(m_TexSlot, m_SampSlot, ce.current.slice);
                        // write back the correct results
                        entries[ce.key.shadowDataIdx] = sd;
                    }
                    m_EntryCache.Purge(m_EntryCache.Count() - m_ActiveEntriesCount, (CachedEntry entry) => { Free(entry); });
                    return(true);
                }
                m_ActiveEntriesCount = 0;
                m_EntryCache.Reset((CachedEntry entry) => { Free(entry); });
                return(false);
            }
        public Error SetValues(ThreadId thread, FrameId frame, int[] slots, Value[] values)
        {
            int frameIndex = (int)frame.Handle;
            FrameLocationData[] frames = new FrameLocationData[1];
            Error errorCode = GetRawThreadFrames(out frames, thread, frameIndex, 1);
            if (errorCode != Error.None)
                return errorCode;

            frame = frames[0].FrameId;

            throw new NotImplementedException();
        }
Example #31
0
        public Error GetThisObject(ThreadId thread, FrameId frame, out TaggedObjectId thisObject)
        {
            thisObject = default(TaggedObjectId);

            JniEnvironment nativeEnvironment;
            JvmtiEnvironment environment;
            jvmtiError error = GetEnvironment(out environment, out nativeEnvironment);
            if (error != jvmtiError.None)
                return GetStandardError(error);

            using (LocalThreadReferenceHolder threadHandle = VirtualMachine.GetLocalReferenceForThread(nativeEnvironment, thread))
            {
                if (!threadHandle.IsAlive)
                    return Error.InvalidThread;

                int depth = (int)frame.Handle;

                jmethodID method;
                jlocation location;
                error = environment.GetFrameLocation(threadHandle.Value, depth, out method, out location);
                if (error != jvmtiError.None)
                    return GetStandardError(error);

                JvmAccessModifiers modifiers;
                error = environment.GetMethodModifiers(method, out modifiers);
                if (error != jvmtiError.None)
                    return GetStandardError(error);

                if ((modifiers & JvmAccessModifiers.Static) != 0)
                    return Error.None;

                error = environment.GetLocalObject(nativeEnvironment, threadHandle.Value, depth, 0, out thisObject);
                if (error != jvmtiError.None)
                    return GetStandardError(error);

                return Error.None;
            }
        }
Example #32
0
 // allocate the shadow requests in the shadow map, only is called if shadowsCount > 0 - may modify shadowRequests and shadowsCount
 protected abstract void AllocateShadows(FrameId frameId, VisibleLight[] lights, uint totalGranted, ref VectorArray <ShadowmapBase.ShadowRequest> grantedRequests, ref VectorArray <int> shadowIndices, ref VectorArray <ShadowData> shadowmapDatas, ref VectorArray <ShadowPayload> shadowmapPayload);
Example #33
0
 public abstract void RenderShadows(FrameId frameId, ScriptableRenderContext renderContext, CullResults cullResults, VisibleLight[] lights);
Example #34
0
 public abstract void ProcessShadowRequests(FrameId frameId, CullResults cullResults, Camera camera, VisibleLight[] lights, ref uint shadowRequestsCount, int[] shadowRequests, out int[] shadowDataIndices);
Example #35
0
 public Error PopFrames(ThreadId thread, FrameId frame)
 {
     throw new NotImplementedException();
 }
Example #36
0
 /// <summary>
 /// Create a stack frame for the given parameters.
 /// </summary>
 protected override DalvikStackFrame CreateStackFrame(FrameId frameId, Location location)
 {
     return new DebugStackFrame(frameId, location, this);
 }
Example #37
0
 /// <summary>
 // Sets the value of one or more local variables. Each variable must be visible at the current frame code index.
 // For primitive values, the value's type must match the variable's type exactly. For object values, there must
 // be a widening reference conversion from the value's type to the variable's type and the variable's type must
 // be loaded.
 // Even if local variable information is not available, values can be set, if the front-end is able to determine
 // the correct local variable index. (Typically, this index can be determined for method arguments from the
 // method signature without access to the local variable table information.)
 /// </summary>
 public Task SetValuesAsync(ThreadId threadId, FrameId frameId, params SlotValue[] slotValues)
 {
     var conn = ConnectionOrError;
     DLog.Debug(DContext.DebuggerLibCommands, () => string.Format("StackFrame.SetValues {0}", string.Join(", ", slotValues.Select(x => x.ToString()))));
     var t = conn.SendAsync(JdwpPacket.CreateCommand(conn, Nr, 2, 4000 /* we don't know how long the packet is going to be... */,
         x =>
         {
             var data = x.Data;
             threadId.WriteTo(data);
             frameId.WriteTo(data);
             data.SetInt(slotValues.Length);
             foreach (var value in slotValues)
             {
                 value.Write(data);
             }
             x.Length = data.Offset;
         }));
     return t.ContinueWith(x =>
     {
         x.ForwardException();
         var result = x.Result;
         result.ThrowOnError();
     });
 }
Example #38
0
 public Error SetValues(ThreadId thread, FrameId frame, int[] slots, Value[] values)
 {
     throw new NotImplementedException();
 }
        public Error GetThisObject(out TaggedObjectId thisObject, ThreadId thread, FrameId frame)
        {
            int frameIndex = (int)frame.Handle;
            FrameLocationData[] frames = new FrameLocationData[1];
            Error errorCode = GetRawThreadFrames(out frames, thread, frameIndex, 1);
            if (errorCode != Error.None)
            {
                thisObject = default(TaggedObjectId);
                return errorCode;
            }

            frame = frames[0].FrameId;

            byte[] packet = new byte[HeaderSize + ThreadIdSize + FrameIdSize];
            int id = GetMessageId();
            SerializeHeader(packet, id, StackFrameCommand.ThisObject);
            WriteObjectId(packet, HeaderSize, thread);
            WriteFrameId(packet, HeaderSize + ThreadIdSize, frame);

            byte[] response = SendPacket(id, packet);
            errorCode = ReadErrorCode(response);
            if (errorCode != Error.None)
            {
                thisObject = default(TaggedObjectId);
                return errorCode;
            }

            int offset = HeaderSize;
            thisObject = ReadTaggedObjectId(response, ref offset);
            return Error.None;
        }
        public Error PopFrames(ThreadId thread, FrameId frame)
        {
            int frameIndex = (int)frame.Handle;
            FrameLocationData[] frames = new FrameLocationData[1];
            Error errorCode = GetRawThreadFrames(out frames, thread, frameIndex, 1);
            if (errorCode != Error.None)
                return errorCode;

            frame = frames[0].FrameId;

            byte[] packet = new byte[HeaderSize + ThreadIdSize + FrameIdSize];
            int id = GetMessageId();
            SerializeHeader(packet, id, StackFrameCommand.PopFrames);
            WriteObjectId(packet, HeaderSize, thread);
            WriteFrameId(packet, HeaderSize + ThreadIdSize, frame);

            byte[] response = SendPacket(id, packet);
            return ReadErrorCode(response);
        }
        private void WriteFrameId(byte[] packet, int offset, FrameId frameId)
        {
            switch (FrameIdSize)
            {
            case 2:
                WriteInt16(packet, offset, (short)frameId.Handle);
                break;

            case 4:
                WriteInt32(packet, offset, (int)frameId.Handle);
                break;

            case 8:
                WriteInt64(packet, offset, frameId.Handle);
                break;

            default:
                throw new NotImplementedException();
            }
        }
Example #42
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DalvikStackFrame(FrameId id, Location location, DalvikThread thread)
 {
     Id          = id;
     Location    = location;
     this.thread = thread;
 }
Example #43
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DalvikStackFrame(FrameId id, Location location, DalvikThread thread)
 {
     Id = id;
     Location = location;
     this.thread = thread;
 }
Example #44
0
        public Error GetValues(ThreadId thread, FrameId frame, int[] slots, out Value[] values)
        {
            values = null;

            JniEnvironment nativeEnvironment;
            JvmtiEnvironment environment;
            jvmtiError error = GetEnvironment(out environment, out nativeEnvironment);
            if (error != jvmtiError.None)
                return GetStandardError(error);

            using (LocalThreadReferenceHolder threadHandle = VirtualMachine.GetLocalReferenceForThread(nativeEnvironment, thread))
            {
                if (!threadHandle.IsAlive)
                    return Error.InvalidThread;

                int depth = (int)frame.Handle;

                jmethodID method;
                jlocation location;
                error = environment.GetFrameLocation(threadHandle.Value, depth, out method, out location);
                if (error != jvmtiError.None)
                    return GetStandardError(error);

                VariableData[] variables;
                error = environment.GetLocalVariableTable(method, out variables);
                if (error != jvmtiError.None)
                    return GetStandardError(error);

                Value[] valuesArray = new Value[slots.Length];
                for (int i = 0; i < valuesArray.Length; i++)
                {
                    string signature = variables.First(j => j.Slot == slots[i] && j.CodeIndex <= (ulong)location.Value && (ulong)location.Value < j.CodeIndex + j.Length).Signature;

                    int integerValue;
                    double doubleValue;
                    float floatValue;
                    long longValue;
                    TaggedObjectId objectValue;

                    switch (signature[0])
                    {
                    case 'Z':
                        error = environment.GetLocalInt(threadHandle.Value, depth, slots[i], out integerValue);
                        if (error != jvmtiError.None)
                            return GetStandardError(error);

                        valuesArray[i] = integerValue != 0;
                        break;

                    case 'B':
                        error = environment.GetLocalInt(threadHandle.Value, depth, slots[i], out integerValue);
                        if (error != jvmtiError.None)
                            return GetStandardError(error);

                        valuesArray[i] = (byte)integerValue;
                        break;

                    case 'C':
                        error = environment.GetLocalInt(threadHandle.Value, depth, slots[i], out integerValue);
                        if (error != jvmtiError.None)
                            return GetStandardError(error);

                        valuesArray[i] = (char)integerValue;
                        break;

                    case 'D':
                        error = environment.GetLocalDouble(threadHandle.Value, depth, slots[i], out doubleValue);
                        if (error != jvmtiError.None)
                            return GetStandardError(error);

                        valuesArray[i] = doubleValue;
                        break;

                    case 'F':
                        error = environment.GetLocalFloat(threadHandle.Value, depth, slots[i], out floatValue);
                        if (error != jvmtiError.None)
                            return GetStandardError(error);

                        valuesArray[i] = floatValue;
                        break;

                    case 'I':
                        error = environment.GetLocalInt(threadHandle.Value, depth, slots[i], out integerValue);
                        if (error != jvmtiError.None)
                            return GetStandardError(error);

                        valuesArray[i] = integerValue;
                        break;

                    case 'J':
                        error = environment.GetLocalLong(threadHandle.Value, depth, slots[i], out longValue);
                        if (error != jvmtiError.None)
                            return GetStandardError(error);

                        valuesArray[i] = longValue;
                        break;

                    case 'S':
                        error = environment.GetLocalInt(threadHandle.Value, depth, slots[i], out integerValue);
                        if (error != jvmtiError.None)
                            return GetStandardError(error);

                        valuesArray[i] = (short)integerValue;
                        break;

                    case 'V':
                        return Error.InvalidFieldid;

                    case '[':
                    case 'L':
                        error = environment.GetLocalObject(nativeEnvironment, threadHandle.Value, depth, slots[i], out objectValue);
                        if (error != jvmtiError.None)
                            return GetStandardError(error);

                        valuesArray[i] = objectValue;
                        break;

                    default:
                        throw new FormatException();
                    }
                }

                values = valuesArray;
                return Error.None;
            }
        }
        public Error GetValues(out Value[] values, ThreadId thread, FrameId frame, int[] slots)
        {
            int frameIndex = (int)frame.Handle;
            FrameLocationData[] frames = new FrameLocationData[1];
            Error errorCode = GetRawThreadFrames(out frames, thread, frameIndex, 1);
            if (errorCode != Error.None)
            {
                values = null;
                return errorCode;
            }

            frame = frames[0].FrameId;

            VariableData[] variableData;
            errorCode = GetMethodVariableTable(out variableData, frames[0].Location.Class, frames[0].Location.Method);
            if (errorCode != Error.None)
            {
                values = null;
                return errorCode;
            }

            Tag[] tags = new Tag[slots.Length];
            for (int i = 0; i < slots.Length; i++)
            {
                tags[i] = Tag.Object;
                foreach (VariableData variable in variableData)
                {
                    if (variable.Slot != slots[i])
                        continue;

                    if (variable.CodeIndex > frames[0].Location.Index)
                        continue;

                    if (variable.CodeIndex + variable.Length <= frames[0].Location.Index)
                        continue;

                    if (string.IsNullOrEmpty(variable.Signature))
                        continue;

                    tags[i] = (Tag)variable.Signature[0];
                    break;
                }
            }

            byte[] packet = new byte[HeaderSize + ThreadIdSize + FrameIdSize + sizeof(int) + (slots.Length * (sizeof(int) + sizeof(byte)))];
            int id = GetMessageId();
            SerializeHeader(packet, id, StackFrameCommand.GetValues);
            WriteObjectId(packet, HeaderSize, thread);
            WriteFrameId(packet, HeaderSize + ThreadIdSize, frame);
            WriteInt32(packet, HeaderSize + ThreadIdSize + FrameIdSize, slots.Length);

            int baseOffset = HeaderSize + ThreadIdSize + FrameIdSize + sizeof(int);
            for (int i = 0; i < slots.Length; i++)
            {
                int slotOffset = baseOffset + i * (sizeof(int) + sizeof(byte));
                WriteInt32(packet, slotOffset, slots[i]);
                packet[slotOffset + sizeof(int)] = (byte)tags[i];
            }

            byte[] response = SendPacket(id, packet);
            errorCode = ReadErrorCode(response);
            if (errorCode != Error.None)
            {
                values = null;
                return errorCode;
            }

            int offset = HeaderSize;
            int valueCount = ReadInt32(response, ref offset);
            values = new Value[valueCount];
            for (int i = 0; i < valueCount; i++)
            {
                values[i] = ReadValue(response, ref offset);
            }

            return Error.None;
        }
Example #46
0
 /// <summary>
 /// Create a stack frame for the given parameters.
 /// </summary>
 protected virtual DalvikStackFrame CreateStackFrame(FrameId frameId, Location location)
 {
     return new DalvikStackFrame(frameId, location, this);
 }
Example #47
0
        public jvmtiError GetStackTrace(JniEnvironment nativeEnvironment, ThreadId threadId, int startDepth, int maxFrameCount, out FrameLocationData[] frames)
        {
            frames = null;

            using (var thread = VirtualMachine.GetLocalReferenceForThread(nativeEnvironment, threadId))
            {
                if (!thread.IsAlive)
                    return jvmtiError.InvalidThread;

                jvmtiFrameInfo[] frameBuffer = new jvmtiFrameInfo[maxFrameCount];
                int frameCount;
                jvmtiError error = RawInterface.GetStackTrace(this, thread.Value, startDepth, maxFrameCount, frameBuffer, out frameCount);
                if (error != jvmtiError.None)
                    return error;

                var frameData = new FrameLocationData[frameCount];
                for (int i = 0; i < frameCount; i++)
                {
                    TaggedReferenceTypeId declaringClass;
                    MethodId method = new MethodId(frameBuffer[i]._method.Handle);
                    ulong index = (ulong)frameBuffer[i]._location.Value;
                    error = GetMethodDeclaringClass(nativeEnvironment, method, out declaringClass);
                    if (error != jvmtiError.None)
                        return error;

                    FrameId frameId = new FrameId(startDepth + i);
                    Location location = new Location(declaringClass, method, index);
                    frameData[i] = new FrameLocationData(frameId, location);
                }

                frames = frameData;
                return jvmtiError.None;
            }
        }
Example #48
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DebugStackFrame(FrameId frameId, Location location, DebugThread thread)
     : base(frameId, location, thread)
 {
 }
Example #49
0
 public FrameLocationData(FrameId frameId, Location location)
 {
     FrameId = frameId;
     Location = location;
 }