예제 #1
0
 protected void ParseCommonAlloc(MemOpAllocation aOperation, ref string aLine, MemAnalysisParserPrefixesBase aPrefixes)
 {
     if (aLine.IndexOf(aPrefixes.AllocSize) >= 0)
     {
         PrefixParser.SkipPrefix(aPrefixes.AllocSize, ref aLine);
         aOperation.AllocationSize = PrefixParser.ReadUint(ref aLine);
     }
 }
예제 #2
0
        protected void ParseCommonKernel(MemOpBase aOperation, ref string aLine, MemAnalysisParserPrefixesBase aPrefixes)
        {
            string line = aLine;

            //
            if (line.IndexOf(aPrefixes.CellAddress) >= 0)
            {
                PrefixParser.SkipPrefix(aPrefixes.CellAddress, ref line);
                aOperation.CellAddress = PrefixParser.ReadUint(ref line);
            }
            if (line.IndexOf(aPrefixes.HeapSize) >= 0)
            {
                PrefixParser.SkipPrefix(aPrefixes.HeapSize, ref line);
                aOperation.HeapSize = PrefixParser.ReadUint(ref line);
            }
            if (line.IndexOf(aPrefixes.ChunkSize) >= 0)
            {
                PrefixParser.SkipPrefix(aPrefixes.ChunkSize, ref line);
                aOperation.ChunkSize = PrefixParser.ReadUint(ref line);
            }
            if (line.IndexOf(aPrefixes.LinkRegister) >= 0)
            {
                PrefixParser.SkipPrefix(aPrefixes.LinkRegister, ref line);
                aOperation.LinkRegisterAddress = PrefixParser.ReadUint(ref line);
            }
            if (line.IndexOf(aPrefixes.CellSize) >= 0)
            {
                PrefixParser.SkipPrefix(aPrefixes.CellSize, ref line);
                aOperation.CellSize = PrefixParser.ReadUint(ref line);
            }
            if (line.IndexOf(aPrefixes.AllocNumber) >= 0)
            {
                PrefixParser.SkipPrefix(aPrefixes.AllocNumber, ref line);
                try
                {
                    aOperation.AllocationNumber = PrefixParser.ReadUint(ref line);
                }
                catch (Exception)
                {
                }
            }
            if (line.IndexOf(aPrefixes.VTable) >= 0)
            {
                PrefixParser.SkipPrefix(aPrefixes.VTable, ref line);
                aOperation.VTable = PrefixParser.ReadUint(ref line);
            }
        }
예제 #3
0
 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);
        }