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); }
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); }