private void DoTestCodeSegmentResolution() { CodeSegDefinitionCollection codeSegs = new CodeSegDefinitionCollection(); using (StringReader reader = new StringReader(KTestBigDsoDataCodeSegList)) { string line = reader.ReadLine(); while (line != null) { CodeSegDefinition def = CodeSegDefinitionParser.ParseDefinition(line); if (def != null) { codeSegs.Add(def); } line = reader.ReadLine(); } } codeSegs.SortByAddress(); using (DbgEngineView view = iDebugEngine.CreateView("TestView", codeSegs)) { foreach (CodeSegDefinition def in codeSegs) { SymbolCollection col = null; Symbol sym = view.Symbols.Lookup(def.Base, out col); System.Diagnostics.Debug.Assert(sym != null); } } }
private void TryToParseCodeSegment(ParserLine aLine) { string line = aLine.GetCurrentLine(); CodeSegDefinition codeSegDef = CodeSegDefinitionParser.ParseDefinition(line); if (codeSegDef != null) { iEngine.CodeSegments.Add(codeSegDef); } }
private void TestBigDsoData() { Clear(); iDebugEngine.Add(@"C:\Tool Demo Files\4. Heap Sample Data\11. Browser heap\Rom_images_widgetui_rheap\ivalo\CoreImage\RM505_widgetui_rheap_rnd_rofs1.symbol"); iDebugEngine.Prime(SymbianUtils.TSynchronicity.ESynchronous); CodeSegDefinitionCollection codeSegs = new CodeSegDefinitionCollection(); using (StringReader reader = new StringReader(KTestBigDsoDataCodeSegList)) { string line = reader.ReadLine(); while (line != null) { CodeSegDefinition def = CodeSegDefinitionParser.ParseDefinition(line); if (def != null) { codeSegs.Add(def); } line = reader.ReadLine(); } } using (DbgEngineView view = iDebugEngine.CreateView("TestView", codeSegs)) { // MemMan.dll contains a dodgy symbol: // // 000031b4 0000 Image$$ER_RO$$Limit anon$$obj.o(linker$$defined$$symbols) // 003f8024 0004 __dso_handle ucppfini.o(.data) SymbolCollection colMemManDll = view.Symbols.CollectionByAddress(0x79E18000); System.Diagnostics.Debug.Assert(colMemManDll != null); // Verify it doesn't include the big dso object Symbol bigDsoData = FindByName("__dso_handle", colMemManDll); System.Diagnostics.Debug.Assert(bigDsoData == null); // Widget engine would otherwise overlap with memman.dll SymbolCollection colWidgetEngineDll = view.Symbols.CollectionByAddress(0x7A0C0000); System.Diagnostics.Debug.Assert(colMemManDll != null); // Check no overlaps CheckNoOverlaps(colMemManDll, colWidgetEngineDll); } }
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); }
private void DoTestHeapCellSymbolLookup() { CodeSegDefinitionCollection codeSegs = new CodeSegDefinitionCollection(); using (StringReader reader = new StringReader(KTestBigDsoDataCodeSegList)) { string line = reader.ReadLine(); while (line != null) { CodeSegDefinition def = CodeSegDefinitionParser.ParseDefinition(line); if (def != null) { codeSegs.Add(def); } line = reader.ReadLine(); } } codeSegs.SortByAddress(); using (DbgEngineView view = iDebugEngine.CreateView("TestView", codeSegs)) { foreach (TSymLookupEntry entry in TSymLookupEntry.KHeapSymbols) { SymbolCollection col = null; Symbol sym = view.Symbols.Lookup(entry.iAddress, out col); // if (sym != null) { string name = sym.Name; System.Diagnostics.Debug.Assert(entry.iSymbol == name); } else { System.Diagnostics.Debug.Assert(entry.iSymbol == string.Empty); } // if (col != null) { string name = entry.iCollection.ToUpper(); bool match = col.FileName.Contains(name); System.Diagnostics.Debug.Assert(match); } else { System.Diagnostics.Debug.Assert(entry.iCollection == string.Empty); } // CodeSegDefinition def = codeSegs[entry.iAddress]; if (def != null) { if (entry.iSymbol == string.Empty) { // The original SymbolLib didn't find a symbolic match. It's okay // if we did (or didn't) find a match using SymbianSymbolLib. } else if (entry.iSymbol != string.Empty) { // SymbolLib found a match, SymbianSymbolLib must do too. System.Diagnostics.Debug.Assert(sym != null); } if (col == null) { // We didn't find a symbol collection for the specified address // even though it falls within code segment range. Print a warning // as this may be caused by dodgy symbol file content. System.Diagnostics.Debug.WriteLine(string.Format(@"WARNING: couldn't find symbol for: 0x{0:x8}, offset: 0x{1:x8}, even though code seg match was found: {2}", entry.iAddress, entry.iAddress - def.Base, def)); } } } } }
internal MapFileEngineCollection(ITracer aTracer) : base(aTracer) { iCodeSegResolver = new CodeSegResolver(aTracer); iCodeSegParser = new CodeSegDefinitionParser(iCodeSegResolver); }