Exemplo n.º 1
0
        public static CallstackPack Create(DataResponse response, ISamplingBoard board, SysCallBoard sysCallBoard)
        {
            CallstackPack result = new CallstackPack()
            {
                Response = response, CallstackMap = new Dictionary <ulong, List <Callstack> >()
            };

            ulong totalCount = response.Reader.ReadUInt32();

            for (ulong i = 0; i < totalCount;)
            {
                UInt64 threadID  = response.Reader.ReadUInt64();
                UInt64 timestamp = response.Reader.ReadUInt64();

                UInt64 count = response.Reader.ReadUInt64();

                Callstack callstack = new Callstack()
                {
                    Start = (long)timestamp, Reason = CallStackReason.AutoSample
                };

                if (sysCallBoard != null)
                {
                    Tuple <bool, UInt64> sysCallDesc = sysCallBoard.GetSystemCallParams(timestamp);

                    if (sysCallDesc.Item1)
                    {
                        if (sysCallDesc.Item2 < (int)CallStackReason.MaxReasonsCount)
                        {
                            callstack.Reason = (CallStackReason)sysCallDesc.Item2;
                        }
                        else
                        {
                            callstack.Reason = CallStackReason.SysCall;
                        }
                    }
                }

                for (ulong addressIndex = 0; addressIndex < count; ++addressIndex)
                {
                    UInt64 address           = response.Reader.ReadUInt64();
                    SamplingDescription desc = board.GetDescription(address);
                    callstack.Add(desc);
                }

                List <Callstack> callstacks;
                if (!result.CallstackMap.TryGetValue(threadID, out callstacks))
                {
                    callstacks = new List <Callstack>();
                    result.CallstackMap.Add(threadID, callstacks);
                }

                callstack.Reverse();
                callstacks.Add(callstack);

                i += (3 + count);
            }

            return(result);
        }
Exemplo n.º 2
0
        void AppendMerge(Callstack callstack, int index, SamplingNode root)
        {
            if (callstack.Count == index)
            {
                return;
            }

            SamplingDescription desc     = callstack[index];
            SamplingNode        rootNode = root == null ? this : root;

            foreach (SamplingNode node in Children)
            {
                if (IsSimilar(node.Description, desc))
                {
                    node.shadowNodes.Add(new SamplingNode(rootNode, desc, 1)
                    {
                        Parent = this, ChildrenDuration = index == callstack.Count - 1 ? 0 : 1
                    });
                    ++node.Passed;
                    node.AppendMerge(callstack, index + 1, rootNode);
                    return;
                }
            }

            SamplingNode child = new SamplingNode(rootNode, desc, 1);

            child.shadowNodes.Add(new SamplingNode(rootNode, desc, 1)
            {
                Parent = child, ChildrenDuration = index == callstack.Count - 1 ? 0 : 1
            });
            AddChild(child);
            child.AppendMerge(callstack, index + 1, rootNode);
        }
Exemplo n.º 3
0
        void AppendMerge(Callstack callstack, int index, SamplingNode root)
        {
            if (callstack.Count == index)
            {
                return;
            }

            SamplingDescription desc     = callstack[index];
            SamplingNode        rootNode = root == null ? this : root;

            foreach (SamplingNode node in Children)
            {
                if (IsSimilar(node.Description, desc))
                {
                    ++node.Passed;
                    node.AppendMerge(callstack, index + 1, rootNode);
                    return;
                }
            }

            SamplingNode child = new SamplingNode(rootNode, desc, desc.Address, 1);

            AddChild(child);
            child.AppendMerge(callstack, index + 1, rootNode);
        }
Exemplo n.º 4
0
        public static CallstackPack Create(DataResponse response, ISamplingBoard board, SysCallBoard sysCallBoard)
        {
            CallstackPack result = new CallstackPack()
            {
                Response = response, CallstackMap = new Dictionary <ulong, List <Callstack> >()
            };

            ulong totalCount = response.Reader.ReadUInt32();

            for (ulong i = 0; i < totalCount;)
            {
                UInt64 threadID  = response.Reader.ReadUInt64();
                UInt64 timestamp = response.Reader.ReadUInt64();
                UInt64 count     = response.Reader.ReadUInt64();

                Callstack callstack = new Callstack()
                {
                    Start = (long)timestamp, Reason = CallStackReason.AutoSample
                };

                if (sysCallBoard != null)
                {
                    if (sysCallBoard.HasSysCall(threadID, callstack.Start))
                    {
                        callstack.Reason = CallStackReason.SysCall;
                    }
                }

                for (ulong addressIndex = 0; addressIndex < count; ++addressIndex)
                {
                    UInt64 address           = response.Reader.ReadUInt64();
                    SamplingDescription desc = board.GetDescription(address);
                    if (!desc.IsIgnore)
                    {
                        callstack.Add(desc);
                    }
                }

                List <Callstack> callstacks;
                if (!result.CallstackMap.TryGetValue(threadID, out callstacks))
                {
                    callstacks = new List <Callstack>();
                    result.CallstackMap.Add(threadID, callstacks);
                }

                //callstack.Reverse();
                callstacks.Add(callstack);

                i += (3 + count);
            }

            foreach (List <Callstack> cs in result.CallstackMap.Values)
            {
                cs.Sort();
            }

            return(result);
        }
Exemplo n.º 5
0
 public int CompareTo(Callstack other)
 {
     return(Start.CompareTo(other.Start));
 }