private Extractor.Extractor ExtractorByThread(string aName) { Predicate <Extractor.Extractor> findByNamePredicate = delegate(Extractor.Extractor aExtractor) { string entryName = aExtractor.Interpreter.DataSource.ThreadName; return(entryName == aName); }; Extractor.Extractor ret = iActiveExtractors.Find(findByNamePredicate); return(ret); }
private void AddExtractor(Extractor.Extractor aExtractor) { // Check whether we already have an extractor for this thread. string threadName = aExtractor.Interpreter.DataSource.ThreadName; // If an entry with the same thread name already exists, then we // remove it, and replace it with a new entry Extractor.Extractor existingEntry = ExtractorByThread(threadName); if (existingEntry != null) { iActiveExtractors.Remove(existingEntry); } // Save new extractor for the thread iActiveExtractors.Add(aExtractor); }
internal void HandleFilteredLine(string aLine, long aLineNumber) { // The four types of data we allow. // // 1) Text data from a trace file // [15:21:32.719] xti2:MCU_ASCII_PRINTF; channel:0xE0; msg:HeapData - EComServer::!ecomserver - HEAP INFO FOR THREAD 'EComServer::!ecomserver' // // 2) Text data from a MemSpy heap dump file // HEAP INFO FOR THREAD 'ecomserver::!ecomserver' // // 3) Binary data from a trace file: // [14:39:24.344] xti2:MCU_ASCII_PRINTF; channel:0xE0; msg:[BinHeap:00000131]<BinHeapData:00000131:00000130:000000000001346e> // [14:39:24.344] xti2:MCU_ASCII_PRINTF; channel:0xE0; msg:[BinHeap:00000131]00000000: be d0 be d0 ba da ba da 00 00 00 d0 01 00 00 00 ................ // [14:39:24.344] xti2:MCU_ASCII_PRINTF; channel:0xE0; msg:[BinHeap:00000131]00000010: 6e 34 01 00 82 00 00 00 83 00 00 00 01 00 00 00 n4.............. // // 4) Binary data from a MemSpy heap dump file // <BinHeapData:00000114:00000113:0000000000001234> // 000ae8cc: 00 00 00 00 00 00 00 00 9d 2a 17 00 24 00 00 00 // First, try running the line past any existing extractors bool handled = false; foreach (Extractor.Extractor ext in iActiveExtractors) { if (ext.ExtractFrom(aLine, false)) { handled = true; break; } } // if (!handled) { // Try to create a new extractor that can handle this type of line Extractor.Extractor extractor = iExtractorFactory.FindSuitableExtractor(aLine); if (extractor != null) { InterpreterBase interpreter = iInterpreterFactory.FindSuitableInterpreter(extractor); if (interpreter != null) { // Link up extractor and interpreter with a new data source string dataSourceFileName = GetSourceFileName(); DataSource dataSource = new DataSource(dataSourceFileName, aLineNumber); interpreter.DataSource = dataSource; extractor.Interpreter = interpreter; // We should also initialise the interpreter now that we've // prepared the data source interpreter.PrepareToStart(extractor); // We must fire the extractor extractor.ExtractFrom(aLine, true); // Save the extractor so that we can ask it to handle future lines AddExtractor(extractor); // Save the data source iDataSources.Add(dataSource); } } } }