Exemplo n.º 1
0
        protected void Read(DataResponse response)
        {
            int count = 0;

            BinaryReader reader = response.Reader;

            if (response.Version >= NetworkProtocol.NETWORK_PROTOCOL_VERSION_24)
            {
                count   = reader.ReadInt32();
                Modules = new List <Module>(count);
                for (uint i = 0; i < count; ++i)
                {
                    Module module = new Module();
                    module.Path    = Utils.ReadBinaryString(reader);
                    module.Address = reader.ReadUInt64();
                    module.Size    = reader.ReadUInt64();
                    Modules.Add(module);
                }
                Modules.Sort();
            }

            count        = reader.ReadInt32();
            Descriptions = new Dictionary <UInt64, SamplingDescription>(count);
            for (uint i = 0; i < count; ++i)
            {
                SamplingDescription desc = SamplingDescription.Create(reader, response.Version);
                desc.Module = GetModule(desc.Address);
                Descriptions[desc.Address] = desc;
            }
        }
Exemplo n.º 2
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.º 3
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.º 4
0
        protected void Read(BinaryReader reader)
        {
            Descriptions = new Dictionary <UInt64, SamplingDescription>();

            uint count = reader.ReadUInt32();

            for (uint i = 0; i < count; ++i)
            {
                SamplingDescription desc = SamplingDescription.Create(reader);
                Descriptions[desc.Address] = desc;
            }
        }
Exemplo n.º 5
0
        public static SamplingDescription Create(BinaryReader reader, uint version)
        {
            SamplingDescription description = new SamplingDescription();

            description.Address = reader.ReadUInt64();
            if (version <= NetworkProtocol.NETWORK_PROTOCOL_VERSION_23)
            {
                Utils.ReadBinaryString(reader);
            }
            description.FullName = Utils.ReadBinaryWideString(reader);
            description.Path     = new FileLine(Utils.ReadBinaryWideString(reader), reader.ReadInt32());

            return(description);
        }
Exemplo n.º 6
0
        public static SamplingDescription Create(BinaryReader reader)
        {
            SamplingDescription description = new SamplingDescription();

            description.Address  = reader.ReadUInt64();
            description.Module   = Utils.ReadBinaryString(reader);
            description.FullName = Utils.ReadBinaryString(reader);

            String file = Utils.ReadBinaryString(reader);

            description.Path = new FileLine(file, reader.ReadInt32());

            return(description);
        }
Exemplo n.º 7
0
        public static SamplingDescription Create(BinaryReader reader)
        {
            SamplingDescription description = new SamplingDescription();

            description.Address  = reader.ReadUInt64();
            description.Module   = System.Text.Encoding.Unicode.GetString(reader.ReadBytes(reader.ReadInt32()));
            description.FullName = System.Text.Encoding.Unicode.GetString(reader.ReadBytes(reader.ReadInt32()));

            String file = System.Text.Encoding.Unicode.GetString(reader.ReadBytes(reader.ReadInt32()));

            description.Path = new FileLine(file, reader.ReadInt32());

            return(description);
        }
Exemplo n.º 8
0
        public static SamplingDescriptionBoard Create(BinaryReader reader)
        {
            SamplingDescriptionBoard board = new SamplingDescriptionBoard();

            board.Descriptions = new Dictionary <UInt64, SamplingDescription>();

            uint count = reader.ReadUInt32();

            for (uint i = 0; i < count; ++i)
            {
                SamplingDescription desc = SamplingDescription.Create(reader);
                board.Descriptions[desc.Address] = desc;
            }

            return(board);
        }
Exemplo n.º 9
0
 public override SamplingDescription GetDescription(ulong address)
 {
     return(SamplingDescription.Create(address));
 }
Exemplo n.º 10
0
        public override SamplingDescription GetDescription(ulong address)
        {
            SamplingDescription result = null;

            return(Descriptions.TryGetValue(address, out result) ? result : SamplingDescription.UnresolvedDescription);
        }
Exemplo n.º 11
0
 public SamplingSharedKey(SamplingDescription desc)
 {
     Description = desc;
 }