Esempio n. 1
0
        public override void EndDataCooking(CancellationToken cancellationToken)
        {
            IThreadTracker pidTracker = this.dataRetrieval.QueryOutput <IThreadTracker>(
                new DataOutputPath(LTTngThreadDataCooker.DataCookerPath, "ThreadTracker"));

            this.moduleEvents.ForEach(x => x.SetThreadInformation(pidTracker.QueryInfo(x.Tid, x.Time)));
        }
        public override void EndDataCooking(CancellationToken cancellationToken)
        {
            IThreadTracker pidTracker = this.dataRetrieval.QueryOutput <IThreadTracker>(
                new DataOutputPath(LTTngThreadDataCooker.DataCookerPath, "ThreadTracker"));

            Dictionary <int, List <SyscallEvent> > syscallsPerThread = new Dictionary <int, List <SyscallEvent> >();
            Dictionary <int, int> threadClosingEventsToSkip          = new Dictionary <int, int>();

            foreach (var syscallType in syscallEvents)
            {
                threadClosingEventsToSkip.Clear();
                new List <List <SyscallEvent> >(syscallsPerThread.Values).ForEach(l => l.Clear());
                int       t = 1;
                Timestamp nextDroppedEventTimestamp = Timestamp.MaxValue;
                if (discardedEventsTimestamps.Count > 0)
                {
                    nextDroppedEventTimestamp = discardedEventsTimestamps[0];
                }

                var receivedEntries = syscallType.Value;
                for (int i = 0; i < receivedEntries.Count; ++i)
                {
                    if (receivedEntries[i].Timestamp >= nextDroppedEventTimestamp)
                    {
                        new List <List <SyscallEvent> >(syscallsPerThread.Values).ForEach(l => l.Clear());
                        threadClosingEventsToSkip.Clear();
                        if (t < discardedEventsTimestamps.Count)
                        {
                            nextDroppedEventTimestamp = discardedEventsTimestamps[t++];
                        }
                        else
                        {
                            nextDroppedEventTimestamp = Timestamp.MaxValue;
                        }
                    }
                    if (!syscallsPerThread.TryGetValue(receivedEntries[i].Tid, out List <SyscallEvent> ongoingSyscalls))
                    {
                        ongoingSyscalls = new List <SyscallEvent>();
                        syscallsPerThread[receivedEntries[i].Tid] = ongoingSyscalls;
                    }
                    if (threadClosingEventsToSkip.TryGetValue(receivedEntries[i].Tid, out int amountOfEventsToSkip) && amountOfEventsToSkip > 0)
                    {
                        if (receivedEntries[i].IsEntry)
                        {
                            this.syscallEntries.Add(new Syscall(receivedEntries[i], null, pidTracker.QueryInfo(receivedEntries[i].Tid, receivedEntries[i].Timestamp)));
                            threadClosingEventsToSkip[receivedEntries[i].Tid] = amountOfEventsToSkip + 1;
                        }
                        else
                        {
                            threadClosingEventsToSkip[receivedEntries[i].Tid] = amountOfEventsToSkip - 1;
                        }
                    }
                    else if (receivedEntries[i].IsEntry)
                    {
                        if (receivedEntries[i].Name.StartsWith("exit"))
                        {
                            this.syscallEntries.Add(new Syscall(receivedEntries[i], null, pidTracker.QueryInfo(receivedEntries[i].Tid, receivedEntries[i].Timestamp)));
                        }
                        else
                        {
                            ongoingSyscalls.Add(receivedEntries[i]);
                        }
                    }
                    else if (ongoingSyscalls.Count == 1)
                    {
                        this.syscallEntries.Add(new Syscall(ongoingSyscalls[0], receivedEntries[i], pidTracker.QueryInfo(receivedEntries[i].Tid, receivedEntries[i].Timestamp)));
                        ongoingSyscalls.Clear();
                    }
                    else if (ongoingSyscalls.Count > 1)
                    {
                        threadClosingEventsToSkip[receivedEntries[i].Tid] = ongoingSyscalls.Count - 1;
                        ongoingSyscalls.ForEach(syscall => this.syscallEntries.Add(new Syscall(syscall, null, pidTracker.QueryInfo(syscall.Tid, syscall.Timestamp))));
                        ongoingSyscalls.Clear();
                    }
                }
                receivedEntries.Clear();
            }
            syscallEvents.Clear();
            discardedEventsTimestamps.Clear();
            this.syscallEntries.Sort(delegate(ISyscall a, ISyscall b)
            {
                return(a.StartTime.ToNanoseconds.CompareTo(b.StartTime.ToNanoseconds));
            });
        }