Пример #1
0
        public TraceCodeAddress GetManagedMethodOnStack(SampledProfileTraceData se)
        {
            TraceCodeAddress ca = TraceLogExtensions.IntructionPointerCodeAddress(se);

            if (ManagedModulePaths.Contains(ca.ModuleFilePath))
            {
                return(ca);
            }

            // We don't have a managed method, so walk to the managed method by skipping calls
            // inside clr or clrjit
            TraceCallStack cs = TraceLogExtensions.CallStack(se);

            while (cs != null)
            {
                ca = cs.CodeAddress;
                if (ca == null)
                {
                    return(null);
                }

                if (ManagedModulePaths.Contains(ca.ModuleFilePath))
                {
                    return(ca);
                }

                // This is to ensure we calculate time spent in the JIT helpers, for example.
                cs = ca.ModuleName.IndexOf("clr", StringComparison.OrdinalIgnoreCase) >= 0 ||
                     ca.ModuleName.IndexOf("clrjit", StringComparison.OrdinalIgnoreCase) >= 0
                    ? cs.Caller
                    : null;
            }
            return(null);
        }
Пример #2
0
        public static string[] StackFramesForProfileEvent(SampledProfileTraceData profileEvent)
        {
            List <string> frames    = new List <string>();
            var           callStack = profileEvent.CallStack();

            while (callStack != null)
            {
                var method = callStack.CodeAddress.Method;
                var module = callStack.CodeAddress.ModuleFile;

                if (!ShouldIgnoreFrame(method, module))
                {
                    if (method != null)
                    {
                        frames.Add(String.Format("{0}!{1}", module.Name, method.FullMethodName));
                    }
                    else if (module != null)
                    {
                        frames.Add(String.Format("{0}!0x{1:x}", module.Name, callStack.CodeAddress.Address));
                    }
                    else
                    {
                        frames.Add(String.Format("?!0x{0:x}", callStack.CodeAddress.Address));
                    }
                }

                callStack = callStack.Caller;
            }
            frames.Reverse();
            return(frames.ToArray());
        }
Пример #3
0
 public ThreadWorkSpan(SampledProfileTraceData sample)
 {
     ProcessName = sample.ProcessName;
     ProcessId = sample.ProcessID;
     ThreadId = sample.ThreadID;
     ProcessorNumber = sample.ProcessorNumber;
     AbsoluteTimestampMsc = sample.TimeStampRelativeMSec;
     DurationMsc = 1;
     Priority = 0;
 }
Пример #4
0
 public ThreadWorkSpan(SampledProfileTraceData sample)
 {
     ProcessName          = sample.ProcessName;
     ProcessId            = sample.ProcessID;
     ThreadId             = sample.ThreadID;
     ProcessorNumber      = sample.ProcessorNumber;
     AbsoluteTimestampMsc = sample.TimeStampRelativeMSec;
     DurationMsc          = 1;
     Priority             = 0;
 }
        // callbacks for pariticular ETW events
        private void OnCpuSample(SampledProfileTraceData data)
        {
            TraceThread thread = data.Thread();

            Debug.Assert(thread != null);
            if (null == thread)
            {
                return;
            }

            // Log the CPU sample.
            ComputingResourceThreadState threadState = m_ThreadState[(int)thread.ThreadIndex];

            threadState.LogCPUSample(this, thread, data);
        }
Пример #6
0
        //public Func Grouper;

        private void OnCpuSample(SampledProfileTraceData sample)
        {
            RolloverTimeSliceAsNeeded(sample.TimeStampRelativeMSec);

            var cpuSampled = new TraceModel.CpuSampled
            {
                Count = sample.Count,
                CpuCoreCount = _cpuCoreCount,
                IsDpc = sample.ExecutingDPC,
                IsIsr = sample.ExecutingISR,
                ProcessId = sample.ProcessID,
                ProcessName = sample.ProcessName,
                ThreadId = sample.ThreadID
            };

            _rawMeasurementsForCurrentTimeSlice.Add(cpuSampled);
        }
Пример #7
0
        private string GetSampledMethodName(JitCapCollector collector, SampledProfileTraceData data)
        {
            TraceCodeAddress ca = collector.GetManagedMethodOnStack(data);

            if (ca == null)
            {
                return(null);
            }

            if (String.IsNullOrEmpty(ca.ModuleName))
            {
                return(null);
            }

            // Lookup symbols, if not already looked up.
            if (!SymbolsLookedUp.Contains(ca.ModuleName))
            {
                try
                {
                    collector.EtlDataFile.SetFilterProcess(data.ProcessID);
                    collector.EtlDataFile.LookupSymbolsForModule(ca.ModuleName);
                }
                catch (Exception)
                {
                    return(null);
                }
                SymbolsLookedUp.Add(ca.ModuleName);
            }

            if (ca.Method == null)
            {
                SymbolsMissing.Add(ca.ModuleName);
                return(null);
            }
            return(ca.ModuleName + "!" + ca.Method.FullMethodName);
        }