internal void StopScan(StreamscanrequestStartArgs_V1TraceData data)
        {
            // Get the requesting user process based on the PID logged inside the engine.
            TraceProcess process      = _traceLog.Processes.GetProcess(data.PID, data.TimeStampRelativeMSec);
            ProcessIndex processIndex = process.ProcessIndex;

            if (processIndex == ProcessIndex.Invalid)
            {
                return;
            }

            // Get the file scan operation.
            Dictionary <ThreadIndex, FileScanOperation> processContainer = GetOrCreateProcessContainer(processIndex);
            FileScanOperation operation = processContainer.Values.Where(s => s.File.Equals(data.Path, System.StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

            if (operation != null)
            {
                operation.StopTimeRelativeMSec = data.TimeStampRelativeMSec;

                // Create the stack.
                StackSourceFrameIndex fileNodeIndex   = _stackSource.Interner.FrameIntern($"File ({operation.File})");
                StackSourceFrameIndex reasonNodeIndex = _stackSource.Interner.FrameIntern($"Reason ({(operation.Reason != null ? operation.Reason : "Unknown")})");
                StackSourceFrameIndex resultNodeIndex = _stackSource.Interner.FrameIntern($"Scan Result ({operation.Result})");
                _sample.StackIndex       = _stackSource.Interner.CallStackIntern(resultNodeIndex, operation.RequestorStack);
                _sample.StackIndex       = _stackSource.Interner.CallStackIntern(reasonNodeIndex, _sample.StackIndex);
                _sample.StackIndex       = _stackSource.Interner.CallStackIntern(fileNodeIndex, _sample.StackIndex);
                _sample.Metric           = (float)(operation.StopTimeRelativeMSec - operation.StartTimeRelativeMSec);
                _sample.TimeRelativeMSec = operation.StartTimeRelativeMSec;
                _stackSource.AddSample(_sample);
            }
        }
        internal void CreateFileScanOperation(AMFilter_FileScanArgsTraceData data)
        {
            // If we can't get the process or thread index, bail.
            ProcessIndex processIndex = data.Process().ProcessIndex;

            if (processIndex == ProcessIndex.Invalid)
            {
                return;
            }

            ThreadIndex threadIndex = data.Thread().ThreadIndex;

            if (threadIndex == ThreadIndex.Invalid)
            {
                return;
            }

            // Get the process container.
            Dictionary <ThreadIndex, FileScanOperation> processContainer = GetOrCreateProcessContainer(processIndex);

            // Create a new file scan operation.
            // This happens when the scan is requested inside the user process.
            FileScanOperation scan = new FileScanOperation()
            {
                File           = data.FileName,
                Reason         = data.Reason,
                RequestorStack = _stackSource.GetCallStack(data.CallStackIndex(), data)
            };

            processContainer[threadIndex] = scan;
        }
示例#3
0
 public StackSourceCacheKey(ProcessIndex processIndex, int stackType, double start, double end, string drillIntoKey)
 {
     this.processIndex = processIndex;
     this.stackType    = stackType;
     this.start        = start;
     this.end          = end;
     this.drillIntoKey = drillIntoKey;
 }
示例#4
0
 private void Initialize(int processID, ProcessIndex processIndex, TraceEventDispatcher source)
 {
     ProcessID             = processID;
     ParentID              = -1;
     ProcessIndex          = processIndex;
     endTimeQPC            = long.MaxValue;
     CommandLine           = "";
     ImageFileName         = "";
     Source                = source;
     Is64Bit               = false;
     LoadedModules         = null;
     Log                   = null;
     Parent                = null;
     Threads               = null;
     EventsInProcess       = null;
     EventsDuringProcess   = null;
     StartTime             = EndTime = default(DateTime);
     StartTimeRelativeMsec = EndTimeRelativeMsec = -1;
 }
        internal void StartScan(StreamscanrequestStartArgs_V1TraceData data)
        {
            // Get the requesting user process based on the PID logged inside the engine.
            TraceProcess process      = _traceLog.Processes.GetProcess(data.PID, data.TimeStampRelativeMSec);
            ProcessIndex processIndex = process.ProcessIndex;

            if (processIndex == ProcessIndex.Invalid)
            {
                return;
            }

            // Get the file scan operation.
            Dictionary <ThreadIndex, FileScanOperation> processContainer = GetOrCreateProcessContainer(processIndex);
            FileScanOperation operation = processContainer.Values.Where(s => s.File.Equals(data.Path, System.StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

            if (operation != null)
            {
                operation.StartTimeRelativeMSec = data.TimeStampRelativeMSec;
                _engineThreadToScanMap[(int)data.Thread().ThreadIndex] = operation;
            }
        }
示例#6
0
        /// <summary>
        /// Each process that occurs in the log is given a unique index (which unlike the PID is unique), that
        /// ranges from 0 to Count - 1.   Return the TraceProcess for the given index.
        /// </summary>
        public TraceProcess this[ProcessIndex processIndex]
        {
            get
            {
                if (processIndex == ProcessIndex.Invalid)
                {
                    return(null);
                }
                return(processes[(int)processIndex]);
            }
            internal set
            {
                if (processIndex != ProcessIndex.Invalid)
                {
                    processes[(int)processIndex] = value;

                    int index;
                    FindProcessAndIndex(value.ProcessID, value.startTimeQPC, out index);
                    processesByPID[index] = value;
                }
            }
        }
        // GET: ProcessModels
        public ActionResult Index()
        {
            ProcessIndex index = new ProcessIndex();

            index.Macro = (from pr in db.ProcessModels
                           where pr.Level == 0
                           join mn in db.Managers on pr.ManagerID equals mn.ManagerID
                           into new_pr
                           from tbl in new_pr.DefaultIfEmpty()
                           select new ProcessList
            {
                ProcessID = pr.ProcessID,
                Name = pr.Name,
                CreationTime = pr.CreationTime,
                Manager = tbl.Name
            }).ToList();
            index.Process = (from pr in db.ProcessModels where pr.Level == 1
                             join mn in db.Managers on pr.ManagerID equals mn.ManagerID
                             into new_pr from tbl in new_pr.DefaultIfEmpty()
                             select new ProcessList {
                ProcessID = pr.ProcessID, Name = pr.Name,
                CreationTime = pr.CreationTime, Manager = tbl.Name
            }).ToList();
            index.Subprocess = (from pr in db.ProcessModels
                                where pr.Level > 1
                                join mn in db.Managers on pr.ManagerID equals mn.ManagerID
                                into new_pr
                                from tbl in new_pr.DefaultIfEmpty()
                                select new ProcessList
            {
                ProcessID = pr.ProcessID,
                Name = pr.Name,
                CreationTime = pr.CreationTime,
                Manager = tbl.Name
            }).ToList();
            return(View(index));
        }
        public StackSource GetStackSource(ProcessIndex processIndex, int stackType, double start, double end)
        {
            var sessionEndMsec = this.traceLog.SessionEndTimeRelativeMSec;
            var events         = this.traceLog.Events.FilterByTime(start, Math.Abs(end) < 0.006 ? sessionEndMsec : (end > sessionEndMsec ? sessionEndMsec : end));

            TraceProcess process = null;

            if (processIndex != ProcessIndex.Invalid)
            {
                process = this.TraceProcesses[processIndex];
            }

            if (this.EventStats.TryGetValue(stackType, out var value))
            {
                if (value.IsClassic)
                {
                    if (value.TaskGuid == new Guid("{ce1dbfb4-137e-4da6-87b0-3f59aa102cbc}"))
                    {
                        return(events.CPUStacks(process));
                    }

                    return(events.SingleEventTypeStack(process, @event => @event.TaskGuid == value.TaskGuid && @event.Opcode == value.Opcode));
                }

                if (!value.IsClassic)
                {
                    if (value.ProviderGuid == new Guid("{e13c0d23-ccbc-4e12-931b-d9cc2eee27e4}") && value.EventID == (TraceEventID)80)
                    {
                        return(events.Exceptions(process));
                    }

                    return(events.SingleEventTypeStack(process, @event => @event.ProviderGuid == value.ProviderGuid && @event.ID == value.EventID));
                }
            }

            return(events.AnyStacks(process));
        }
示例#9
0
        public GenericStackSource GetStackSource(ProcessIndex processIndex, int stackType)
        {
            TraceProcess process = null;

            if (processIndex != ProcessIndex.Invalid)
            {
                process = this.TraceProcesses[processIndex];
            }

            if (this.EventStats.TryGetValue(stackType, out var value))
            {
                if (value.IsClassic && value.TaskGuid == new Guid("{ce1dbfb4-137e-4da6-87b0-3f59aa102cbc}"))
                {
                    return(new SourceAwareStackSource(this.traceLog.CPUStacks(process)));
                }

                if (!value.IsClassic && value.ProviderGuid == new Guid("{e13c0d23-ccbc-4e12-931b-d9cc2eee27e4}") && value.EventID == (TraceEventID)80)
                {
                    return(new SourceAwareStackSource(this.traceLog.Exceptions(process)));
                }
            }

            return(new SourceAwareStackSource(this.traceLog.AnyStacks(process)));
        }
示例#10
0
 internal TraceProcess(int processID, TraceLog log, ProcessIndex processIndex, TraceEventDispatcher source)
 {
     Initialize(processID, processIndex, source);
 }
示例#11
0
 internal TraceProcess(int processID, ProcessIndex processIndex)
 {
     Initialize(processID, processIndex, null /* TraceEventDispatcher */);
 }
        private Dictionary <ThreadIndex, FileScanOperation> GetOrCreateProcessContainer(ProcessIndex processIndex)
        {
            Dictionary <ThreadIndex, FileScanOperation> processContainer;

            if (!_inProcessScanOperations.TryGetValue(processIndex, out processContainer))
            {
                processContainer = new Dictionary <ThreadIndex, FileScanOperation>();
                _inProcessScanOperations[processIndex] = processContainer;
            }

            return(processContainer);
        }