コード例 #1
0
ファイル: SysCall.cs プロジェクト: yresk/optick
        public static SysCallBoard Create(DataResponse response, FrameGroup group)
        {
            SysCallBoard result = new SysCallBoard()
            {
                Response = response, SysCallMap = new Dictionary <UInt64, List <SysCallEntry> >()
            };

            ulong totalCount = response.Reader.ReadUInt32();

            for (ulong i = 0; i < totalCount; ++i)
            {
                SysCallEntry entry = new SysCallEntry(response.Reader, group.Board);

                List <SysCallEntry> entries = null;
                if (!result.SysCallMap.TryGetValue(entry.ThreadID, out entries))
                {
                    entries = new List <SysCallEntry>();
                    result.SysCallMap.Add(entry.ThreadID, entries);
                }

                if (entry.IsValid)
                {
                    entries.Add(entry);
                }
            }

            return(result);
        }
コード例 #2
0
ファイル: Callstack.cs プロジェクト: qjxkid/brofiler
        public static SysCallBoard Create(DataResponse response, FrameGroup group)
        {
            SysCallBoard result = new SysCallBoard()
            {
                Response = response, systemCalls = new Dictionary <UInt64, UInt64>()
            };

            ulong totalCount = response.Reader.ReadUInt32();

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

                UInt64 res = 0;
                if (!result.systemCalls.TryGetValue(timestamp, out res))
                {
                    result.systemCalls.Add(timestamp, callId);
                }
            }

            return(result);
        }
コード例 #3
0
ファイル: Callstack.cs プロジェクト: qjxkid/brofiler
        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);
        }
コード例 #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);
        }