protected void ParseCommonRealloc(MemOpReallocation aOperation, ref string aLine, MemAnalysisParserPrefixesBase aPrefixes) { if (aLine.IndexOf(aPrefixes.ReallocMode) >= 0) { PrefixParser.SkipPrefix(aPrefixes.ReallocMode, ref aLine); aOperation.ReallocationMode = (byte)PrefixParser.ReadLong(ref aLine); } if (aLine.IndexOf(aPrefixes.OriginalCellAddress) >= 0) { PrefixParser.SkipPrefix(aPrefixes.OriginalCellAddress, ref aLine); aOperation.OriginalAddress = PrefixParser.ReadUint(ref aLine); } if (aLine.IndexOf(aPrefixes.OriginalCellSize) >= 0) { PrefixParser.SkipPrefix(aPrefixes.OriginalCellSize, ref aLine); aOperation.OriginalAllocationSize = PrefixParser.ReadUint(ref aLine); } if (aLine.IndexOf(aPrefixes.OriginalCellAllocNumber) >= 0) { PrefixParser.SkipPrefix(aPrefixes.OriginalCellAllocNumber, ref aLine); aOperation.OriginalAllocationNumber = PrefixParser.ReadUint(ref aLine); } }
private bool CheckForKnownElement(string aLine) { bool handled = false; string origLine = aLine; // if (CheckForKnownElement(ref aLine, iPrefixes.HeapBaseAddress)) { DataSource.MetaData.Heap.HeapBaseAddress = PrefixParser.ReadUint(ref aLine); handled = true; } else if (CheckForKnownElement(ref aLine, iPrefixes.HeapChunkSize)) { DataSource.MetaData.Heap.ChunkSize = PrefixParser.ReadUint(ref aLine); handled = true; } else if (CheckForKnownElement(ref aLine, iPrefixes.SizeOfRHeap)) { DataSource.MetaData.Heap.SizeOfRHeap = PrefixParser.ReadUint(ref aLine); handled = true; } else if (CheckForKnownElement(ref aLine, iPrefixes.HeapCellMinimumSize)) { DataSource.MetaData.Heap.MinCellSize = PrefixParser.ReadUint(ref aLine); handled = true; } else if (CheckForKnownElement(ref aLine, iPrefixes.FreeCellAddress)) { DataSource.MetaData.Heap.InfoFree.FreeCellAddress = PrefixParser.ReadUint(ref aLine); handled = true; } else if (CheckForKnownElement(ref aLine, iPrefixes.FreeCellLength)) { DataSource.MetaData.Heap.InfoFree.FreeCellLength = PrefixParser.ReadUint(ref aLine); handled = true; } else if (CheckForKnownElement(ref aLine, iPrefixes.DebugAllocator)) { DataSource.MetaData.Heap.DebugAllocator = PrefixParser.ReadBool(ref aLine); handled = true; } else if (CheckForKnownElement(ref aLine, iPrefixes.MiscRHeapRand)) { long val = PrefixParser.ReadLong(ref aLine); uint rand = (uint)val; DataSource.MetaData.Heap.Rand = rand; handled = true; } else if (CheckForKnownElement(ref aLine, iPrefixes.FreeStatistics)) { iState = TState.EStateStatisticsFree; handled = true; } else if (CheckForKnownElement(ref aLine, iPrefixes.AllocStatistics)) { iState = TState.EStateStatisticsAlloc; handled = true; } else if (CheckForKnownElement(ref aLine, iPrefixes.FreeCellCount)) { if (iState == TState.EStateNone || iState == TState.EStateStatisticsFree) { DataSource.MetaData.Heap.InfoFree.FreeCellCount = PrefixParser.ReadInt(ref aLine); handled = true; } else if (iState == TState.EStateStatisticsAlloc) { // Must also handle alloc cells inside the free block, because in the new file format // both alloc and free cell statistics contain the same prefix. DataSource.MetaData.Heap.InfoAlloc.AllocCellCount = PrefixParser.ReadInt(ref aLine); handled = true; } } else if (CheckForKnownElement(ref aLine, iPrefixes.CommonStatisticsSizeOfCells)) { if (iState == TState.EStateStatisticsFree) { DataSource.MetaData.Heap.InfoFree.FreeCellTotalSpace = PrefixParser.ReadUint(ref aLine); handled = true; } else if (iState == TState.EStateStatisticsAlloc) { DataSource.MetaData.Heap.InfoAlloc.AllocCellTotalSpace = PrefixParser.ReadUint(ref aLine); handled = true; } } else if (CheckForKnownElement(ref aLine, iPrefixes.AllocCellCount)) { if (iState == TState.EStateNone || iState == TState.EStateStatisticsAlloc) { DataSource.MetaData.Heap.InfoAlloc.AllocCellCount = PrefixParser.ReadInt(ref aLine); handled = true; } } else if (CheckForKnownElement(ref aLine, iPrefixes.FreeCellList)) { iState = TState.EStateFreeCellList; } else { // Check for free cell list match if (iState == TState.EStateFreeCellList) { Match freeCellListMatch = KFreeCellRegEx.Match(aLine); if (freeCellListMatch.Success) { int index = int.Parse(freeCellListMatch.Groups["Index"].Value); uint address = uint.Parse(freeCellListMatch.Groups["Address"].Value, System.Globalization.NumberStyles.AllowHexSpecifier); int length = int.Parse(freeCellListMatch.Groups["Length"].Value); int type = int.Parse(freeCellListMatch.Groups["Type"].Value); // The index should be between 1 and FreeCellCount int max = DataSource.MetaData.Heap.InfoFree.FreeCellCount; // However, if we didn't read the free cell count then don't panic... if (max > 0) { if (index >= 1 && index <= max) { DataSource.MetaData.Heap.InfoFree.AddFreeCell(address, length, type); } else { DataSource.AddError(DataSource.TErrorTypes.EErrorTypeInvalidFreeCellIndexInFreeList); } } else { // No free cell to validate against, just hope it's okay! DataSource.MetaData.Heap.InfoFree.AddFreeCell(address, length, type); } } } // Is it a code segment? if (!handled) { CodeSegDefinition def = CodeSegDefinitionParser.ParseDefinition(aLine); if (def != null) { DataSource.MetaData.CodeSegments.Add(def); } } } // return(handled); }