Beispiel #1
0
        //public List<CTFERecord> readTrace(string metafile)
        public List <CTFThread> ReadTrace(string metafile)
        {
            List <CTFThread> threads = new List <CTFThread>();
            TokParser        p       = null;

            try
            {
                p = new TokParser(metafile);
                ParseFile(p);

                // Try to find all stream files
                int n = metafile.LastIndexOf(Path.DirectorySeparatorChar);
                if (n >= 0)
                {
                    CTFStreamReader cr = GetStreamReader();

                    string dir      = Path.GetDirectoryName(metafile);
                    var    files    = Directory.GetFiles(dir);
                    var    ctffiles = Array.FindAll(files, s => s.Contains("channel0_"));

                    foreach (string cfile in ctffiles)
                    {
                        cr.Open(cfile);
                        for (CTFERecord cer; (cer = cr.GetEvent()) != null;)
                        {
                            CTFThread thread = CTFThread.FirstOrCreateCTFThreadById(Convert.ToUInt64(cer.Vpid),
                                                                                    Convert.ToUInt64(cer.Vtid), threads);
                            thread.Records.Add(cer);
                            if (cr.IsEvDiscarded == true)
                            {
                                thread.LostRecords.Add(cr.EvDiscarded);
                                cr.IsEvDiscarded = false;
                            }
                        }

                        cr.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.Print("Error {0}\n", ex.Message);
            }
            finally
            {
                p?.Close();
            }

            return(threads);
        }
Beispiel #2
0
        public static CTFThread FirstOrCreateCTFThreadById(ulong pid, ulong tid, List <CTFThread> threads)
        {
            CTFThread result = null;

            foreach (CTFThread thread in threads)
            {
                if (thread.Pid == pid && thread.Tid == tid)
                {
                    result = thread;
                    break;
                }
            }

            if (result == null)
            {
                result = new CTFThread {
                    Pid = pid, Tid = tid
                };
                threads.Add(result);
            }

            return(result);
        }