Пример #1
0
 public AccurateEngine(DbgEngineView aDebugEngineView, IArmStackInterface aStackInterface, ITracer aTracer)
 {
     iTracer          = aTracer;
     iDebugEngineView = aDebugEngineView;
     iStackInterface  = aStackInterface;
     iCodeHelper      = new ArmCodeHelper(aDebugEngineView, aTracer);
 }
Пример #2
0
        internal void Resolve(DbgEngineView aDebugEngineView)
        {
            base.Trace("[CICodeSeg] Resolve() - START - this: {0}", this);
            ResetState();

            // Check whether we have a symbol already loaded for the code segment's base address
            uint baseAddress = this.Base;
            //
            SymbolCollection col    = null;
            Symbol           symbol = aDebugEngineView.Symbols.Lookup(baseAddress, out col);

            base.Trace("[CICodeSeg] Resolve() - symbol: {0}, symbolCollection: {1}", symbol, col);
            //
            if (symbol != null)
            {
                // This must be valid if we found a symbol
                System.Diagnostics.Debug.Assert(col != null);
            }
            else
            {
                // Symbol engine is not aware of the code segment's base address, but we can check by name
                // as well...
                col = aDebugEngineView.Symbols[iCodeSegDef];
            }

            // Update state
            IsResolved = (col != null);
            AssociatedSymbolCollection = col;

            base.Trace("[CICodeSeg] Resolve() - END - this: {0}, resolved: {1}, iCodeSegDef.FileName: {2}", this, this.IsResolved, iCodeSegDef.FileName);
        }
Пример #3
0
        private void TestUDACode()
        {
            Clear();
            iDebugEngine.Add(@"C:\Tool Demo Files\2. Crash Data\File62\Ivalo_RM-505\Wk12\DebugMetaData\RM-505_52.50.2009.12_rnd.rofs1.symbol");
            iDebugEngine.Prime(SymbianUtils.TSynchronicity.ESynchronous);

            CodeSegDefinition csOnC = new CodeSegDefinition(@"C:\sys\bin\btaccesshost.exe", 0x80ef3ae8, 0x80efa988);

            using (DbgEngineView view = iDebugEngine.CreateView("TestView"))
            {
                DbgViewSymbols   symView = view.Symbols;
                SymbolCollection col     = null;

                // This won't activate
                col = symView.ActivateAndGetCollection(csOnC);
                System.Diagnostics.Debug.Assert(col == null);
            }

            // Now merge in the zip file containing lots of maps...
            iDebugEngine.Add(@"C:\Tool Demo Files\2. Crash Data\File62\Ivalo_RM-505\Wk12\DebugMetaData\mapfiles.zip");
            iDebugEngine.Prime(SymbianUtils.TSynchronicity.ESynchronous);

            using (DbgEngineView view = iDebugEngine.CreateView("TestView"))
            {
                DbgViewSymbols   symView = view.Symbols;
                SymbolCollection col     = null;

                // This should activate now
                col = symView.ActivateAndGetCollection(csOnC);
                System.Diagnostics.Debug.Assert(col != null);
            }
        }
Пример #4
0
        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);
                }
            }
        }
Пример #5
0
        private void TestRofsDllAtDifferentBaseAddresses()
        {
            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);

            using (DbgEngineView view1 = iDebugEngine.CreateView("TestView"))
            {
                SymbolCollection colPageScalerAt70000000 = view1.Symbols.ActivateAndGetCollection(new CodeSegDefinition(@"Z:\sys\bin\PageScaler.dll", 0x70000000, 0x7A000000));
                System.Diagnostics.Debug.Assert(colPageScalerAt70000000 != null);
                SymbolCollection col1 = view1.Symbols.CollectionByAddress(0x70000000);
                System.Diagnostics.Debug.Assert(col1 != null);

                // Make a second view
                using (DbgEngineView view2 = iDebugEngine.CreateView("TestView"))
                {
                    SymbolCollection colPageScalerAt75000000 = view2.Symbols.ActivateAndGetCollection(new CodeSegDefinition(@"Z:\sys\bin\PageScaler.dll", 0x75000000, 0x7A000000));
                    System.Diagnostics.Debug.Assert(colPageScalerAt75000000 != null);
                    SymbolCollection col2 = view2.Symbols.CollectionByAddress(0x75000000);
                    System.Diagnostics.Debug.Assert(col2 != null);

                    // Check invalid requests
                    Symbol symTemp = null;

                    symTemp = view1.Symbols[0x80240000];
                    System.Diagnostics.Debug.Assert(symTemp == null);
                    symTemp = view1.Symbols[0x74240000];
                    System.Diagnostics.Debug.Assert(symTemp == null);
                    symTemp = view1.Symbols[0x78240000];
                    System.Diagnostics.Debug.Assert(symTemp == null);

                    symTemp = view2.Symbols[0x80240000];
                    System.Diagnostics.Debug.Assert(symTemp == null);
                    symTemp = view2.Symbols[0x74240000];
                    System.Diagnostics.Debug.Assert(symTemp == null);
                    symTemp = view2.Symbols[0x78240000];
                    System.Diagnostics.Debug.Assert(symTemp == null);

                    // Check offsets are maintained
                    int count = col1.Count;
                    for (int i = 0; i < count; i++)
                    {
                        Symbol sym1 = col1[i];
                        Symbol sym2 = col2[i];
                        //
                        System.Diagnostics.Debug.Assert(sym1.Name == sym2.Name);
                        System.Diagnostics.Debug.Assert(sym1.Object == sym2.Object);
                        System.Diagnostics.Debug.Assert(sym1.Type == sym2.Type);
                        //
                        uint delta = sym2.Address - sym1.Address;
                        System.Diagnostics.Debug.Assert(delta == (0x75000000 - 0x70000000));
                    }
                }
            }
        }
Пример #6
0
        private void RunObyMapViewTest()
        {
            CodeSegDefinitionCollection codeSegs = new CodeSegDefinitionCollection();

            //
            codeSegs.Add(new CodeSegDefinition(@"Z:\sys\bin\WidgetLauncher.exe", 0x7A120000, 0x7A170000));

            using (DbgEngineView view = iDebugEngine.CreateView("TestView", codeSegs))
            {
            }
        }
Пример #7
0
        private void TestMapGCCE()
        {
            Clear();
            iDebugEngine.Add(@"C:\Tool Demo Files\2. Crash Data\File55\GCCE\alarmserver.exe.map");
            iDebugEngine.Prime(SymbianUtils.TSynchronicity.ESynchronous);

            using (DbgEngineView view = iDebugEngine.CreateView("TestView"))
            {
                DbgViewSymbols   symView = view.Symbols;
                SymbolCollection col     = null;

                // Should be possible to activate
                col = symView.ActivateAndGetCollection(new CodeSegDefinition(@"Z:\sys\bin\alarmserver.exe", 0x70000000, 0x7FFFFFFF));
                System.Diagnostics.Debug.Assert(col != null);
                System.Diagnostics.Debug.WriteLine(col.ToString("full", null));

                // Check invalid address
                col = view.Symbols.CollectionByAddress(0x7000bcc8);
                System.Diagnostics.Debug.Assert(col == null);

                // Verify that the symbols were really read.
                col = view.Symbols.CollectionByAddress(0x7000bcc7);
                System.Diagnostics.Debug.Assert(col != null);
                col = view.Symbols.CollectionByAddress(0x70000000);
                System.Diagnostics.Debug.Assert(col != null);
                col = view.Symbols.CollectionByAddress(0x70000001);
                System.Diagnostics.Debug.Assert(col != null);
                col = view.Symbols.CollectionByAddress(0x70002001);
                System.Diagnostics.Debug.Assert(col != null);

                // Check for overlaps
                CheckNoOverlaps(col);

                // Perform some lookup tests
                string text = string.Empty;

                text = view.Symbols.PlainText[0x70000000];
                System.Diagnostics.Debug.Assert(text == "_xxxx_call_user_invariant");
                text = view.Symbols.PlainText[0x70000001];
                System.Diagnostics.Debug.Assert(text == "_xxxx_call_user_invariant");
                text = view.Symbols.PlainText[0x70000007];
                System.Diagnostics.Debug.Assert(text == "_xxxx_call_user_invariant");
                text = view.Symbols.PlainText[0x70000008];
                System.Diagnostics.Debug.Assert(text == "_xxxx_call_user_handle_exception");
                text = view.Symbols.PlainText[0x7000000f];
                System.Diagnostics.Debug.Assert(text == "_xxxx_call_user_handle_exception");
                text = view.Symbols.PlainText[0x70000070];
                System.Diagnostics.Debug.Assert(text == "CASSrvServer::CASSrvServer()");
                text = view.Symbols.PlainText[0x7000bcc7];
                System.Diagnostics.Debug.Assert(text == "typeinfo name for CASAltRequestQuietPeriodEnd");
            }
        }
Пример #8
0
        private void TestMapRVCT()
        {
            Clear();
            iDebugEngine.Add(@"C:\Tool Demo Files\2. Crash Data\File55\RVCT\alarmserver.exe.map");
            iDebugEngine.Prime(SymbianUtils.TSynchronicity.ESynchronous);

            using (DbgEngineView view = iDebugEngine.CreateView("TestView"))
            {
                DbgViewSymbols   symView = view.Symbols;
                SymbolCollection col     = null;

                // Should be possible to activate
                col = symView.ActivateAndGetCollection(new CodeSegDefinition(@"Z:\sys\bin\alarmserver.exe", 0x70000000, 0x7FFFFFFF));
                System.Diagnostics.Debug.Assert(col != null);
                System.Diagnostics.Debug.WriteLine(col.ToString("full", null));

                // Check invalid address
                col = view.Symbols.CollectionByAddress(0x700090a5);
                System.Diagnostics.Debug.Assert(col == null);

                // Verify that the symbols were really read.
                col = view.Symbols.CollectionByAddress(0x700090a4);
                System.Diagnostics.Debug.Assert(col != null);
                col = view.Symbols.CollectionByAddress(0x70000000);
                System.Diagnostics.Debug.Assert(col != null);
                col = view.Symbols.CollectionByAddress(0x70000001);
                System.Diagnostics.Debug.Assert(col != null);
                col = view.Symbols.CollectionByAddress(0x70002001);
                System.Diagnostics.Debug.Assert(col != null);

                // Check for overlaps
                CheckNoOverlaps(col);

                // Perform some lookup tests
                string text = string.Empty;

                text = view.Symbols.PlainText[0x70000000];
                System.Diagnostics.Debug.Assert(text == "_E32Startup");
                text = view.Symbols.PlainText[0x70000001];
                System.Diagnostics.Debug.Assert(text == "_E32Startup");
                text = view.Symbols.PlainText[0x7000006f];
                System.Diagnostics.Debug.Assert(text == "_E32Startup");
                text = view.Symbols.PlainText[0x70000070];
                System.Diagnostics.Debug.Assert(text == "__cpp_initialize__aeabi_");
                text = view.Symbols.PlainText[0x700090a4];
                System.Diagnostics.Debug.Assert(text == ".ARM.exidx$$Limit");
            }
        }
Пример #9
0
        private void TestMulitThreadedLookup()
        {
            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);

            using (DbgEngineView view = iDebugEngine.CreateView("TestView"))
            {
                DbgViewSymbols symView = view.Symbols;

                SymbolCollection col = null;

                // Should be possible to activate a file within a zip
                SymbolCollection colPageScaler = symView.ActivateAndGetCollection(new CodeSegDefinition(@"Z:\sys\bin\PageScaler.dll", 0x70000000, 0x7A000000));
                System.Diagnostics.Debug.Assert(colPageScaler != null);

                // Verify that the symbols were really read.
                col = view.Symbols.CollectionByAddress(0x70000000);
                System.Diagnostics.Debug.Assert(col != null);
                System.Diagnostics.Debug.WriteLine(col.ToString("full", null));

                // Multithreaded symbol lookup times
                ThreadPool.QueueUserWorkItem(new WaitCallback(MultiThreadedLookup), new AsyncData(symView, iWaiter1, col, 10000));
                ThreadPool.QueueUserWorkItem(new WaitCallback(MultiThreadedLookup), new AsyncData(symView, iWaiter2, col, 5000));
                ThreadPool.QueueUserWorkItem(new WaitCallback(MultiThreadedLookup), new AsyncData(symView, iWaiter3, col, 8000));
                ThreadPool.QueueUserWorkItem(new WaitCallback(MultiThreadedLookup), new AsyncData(symView, iWaiter4, col, 20000));

                // Wait
                using ( iWaiter4 )
                {
                    iWaiter4.WaitOne();
                }
                using ( iWaiter3 )
                {
                    iWaiter3.WaitOne();
                }
                using ( iWaiter2 )
                {
                    iWaiter2.WaitOne();
                }
                using ( iWaiter1 )
                {
                    iWaiter1.WaitOne();
                }
            }
        }
Пример #10
0
        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);
            }
        }
Пример #11
0
        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));
                        }
                    }
                }
            }
        }
Пример #12
0
        private void TestZipMapFiles()
        {
            // So we can spot it in the profiler...
            //Thread.Sleep( 2000 );
            Clear();
            iDebugEngine.Add(@"C:\Tool Demo Files\8. For SymbianSymbolLib Test Code\S60_3_2_200846_RnD_merlin_emulator_hw.rom.symbol");
            iDebugEngine.Add(@"C:\Tool Demo Files\2. Crash Data\File44\Platform_wk49\Symbols\mapfiles.zip");
            iDebugEngine.Prime(SymbianUtils.TSynchronicity.ESynchronous);

            using (DbgEngineView view = iDebugEngine.CreateView("TestView"))
            {
                DbgViewSymbols symView = view.Symbols;

                // Should be possible to activate a file within a zip
                SymbolCollection activatedCol = symView.ActivateAndGetCollection(new CodeSegDefinition(@"Z:\sys\bin\AcCmOnItOr.dll", 0x70000000, 0x7A000000));
                System.Diagnostics.Debug.Assert(activatedCol != null);

                // Verify that the symbols were really read.
                SymbolCollection col = view.Symbols.CollectionByAddress(0x70000000);
                System.Diagnostics.Debug.Assert(col != null);
                System.Diagnostics.Debug.WriteLine(col.ToString("full", null));

                // Verify that the collections are the same
                System.Diagnostics.Debug.Assert(activatedCol.Count == col.Count);
                System.Diagnostics.Debug.Assert(activatedCol.FileName == col.FileName);
                System.Diagnostics.Debug.Assert(activatedCol == col);

                // Cannot activate the same dll twice
                bool activated = symView.Activate(new CodeSegDefinition(@"Z:\sys\bin\AcCmOnItOr.dll", 0x80000000, 0x8A000000));
                System.Diagnostics.Debug.Assert(activated == false);

                // Cannot activate an overlapping area.
                activated = symView.Activate(new CodeSegDefinition(@"Z:\sys\bin\AIFW.dll", 0x70000000, 0x70040000));
                System.Diagnostics.Debug.Assert(activated == false);

                // Cannot deactivate a non-activated dll
                bool deactivated = symView.Deactivate(new CodeSegDefinition(@"Z:\sys\bin\AIUTILS.DLL"));
                System.Diagnostics.Debug.Assert(deactivated == false);

                // Cannot deactivate a missing dll
                deactivated = symView.Deactivate(new CodeSegDefinition(@"Z:\sys\bin\THIS_DOES_NOT_EXIST.EXE"));
                System.Diagnostics.Debug.Assert(deactivated == false);

                // Look up first symbol
                Symbol sym  = null;
                Symbol sym2 = null;
                sym = symView.Lookup(0x70000000, out col);
                System.Diagnostics.Debug.Assert(sym != null && col == activatedCol && sym.Name == "_E32Dll");
                sym = symView.Lookup(0x70000027, out col);
                System.Diagnostics.Debug.Assert(sym != null && col == activatedCol && sym.Name == "_E32Dll");

                // For the following sequence, ensure that we discard the CAccMonitor::~CAccMonitor__sub_object()
                // line and keep the CAccMonitor::~CAccMonitor() line instead. Ensure that the size of the
                // CAccMonitor::~CAccMonitor() entry has been calculated using the data from the sub_object entry which
                // we threw away.
                //
                //     CAccMonitor::~CAccMonitor__deallocating() 0x00009195   Thumb Code    16  accmonitor.in(i._ZN11CAccMonitorD0Ev)
                //     CAccMonitor::~CAccMonitor()              0x000091a5   Thumb Code     0  accmonitor.in(i._ZN11CAccMonitorD2Ev)
                //     CAccMonitor::~CAccMonitor__sub_object()  0x000091a5   Thumb Code     8  accmonitor.in(i._ZN11CAccMonitorD2Ev)
                //     CAccMonitorInfo::Reset()                 0x000091ad   Thumb Code    28  accmonitor.in(i._ZN15CAccMonitorInfo5ResetEv)
                //
                sym = FindByName("CAccMonitor::~CAccMonitor__sub_object()", col);
                System.Diagnostics.Debug.Assert(sym == null);
                sym = FindByName("CAccMonitor::~CAccMonitor()", col);
                System.Diagnostics.Debug.Assert(sym != null && sym.Size == 8);

                // For the following sequence, ensure that we discard the sub object and keep the destructor.
                //
                //      RArray<unsigned long>::RArray()          0x00009289   Thumb Code    10  accmonitor.in(t._ZN6RArrayImEC1Ev)
                //      RArray<unsigned long>::RArray__sub_object() 0x00009289   Thumb Code     0  accmonitor.in(t._ZN6RArrayImEC1Ev)
                sym = FindByName("RArray<unsigned long>::RArray__sub_object()", col);
                System.Diagnostics.Debug.Assert(sym == null);
                sym = FindByName("RArray<unsigned long>::RArray()", col);
                System.Diagnostics.Debug.Assert(sym != null && sym.Size == 10);

                // For the following sequence, ensure that the end of the first entry doesn't overlap with the start of the second.
                //
                //      typeinfo name for CAccMonitorCapMapper   0x000094a8   Data          23  accmonitor.in(.constdata__ZTS20CAccMonitorCapMapper)
                //      typeinfo name for CAccMonitorContainer   0x000094bf   Data          23  accmonitor.in(.constdata__ZTS20CAccMonitorContainer)
                //
                sym = FindByName("typeinfo name for CAccMonitorCapMapper", col);
                System.Diagnostics.Debug.Assert(sym != null);
                sym2 = FindByName("typeinfo name for CAccMonitorContainer", col);
                System.Diagnostics.Debug.Assert(sym2 != null);
                System.Diagnostics.Debug.Assert(sym.AddressRange.Max + 1 == sym2.Address);

                // Check no overlap
                CheckNoOverlaps(col);

                // Second symbol
                sym = symView.Lookup(0x70000028, out col);
                System.Diagnostics.Debug.Assert(sym != null && col == activatedCol && sym.Name == "__cpp_initialize__aeabi_");

                // Deactivate an activated dll
                deactivated = symView.Deactivate(new CodeSegDefinition(@"Z:\sys\bin\ACCMONITOR.DLL"));
                System.Diagnostics.Debug.Assert(deactivated == true);

                // symbol shouldn't be available anymore
                sym = symView.Lookup(0x70000000, out col);
                System.Diagnostics.Debug.Assert(sym == null && col == null);
            }
        }
Пример #13
0
        private void RunZipMapFileTest()
        {
            // So we can spot it in the profiler...
            //Thread.Sleep( 2000 );

            using (DbgEngineView view = iDebugEngine.CreateView("TestView"))
            {
                DbgViewSymbols symView = view.Symbols;

                // Should be possible to activate a file within a zip
                SymbolCollection activatedCol = symView.ActivateAndGetCollection(new CodeSegDefinition(@"Z:\sys\bin\AcCmOnItOr.dll", 0x70000000, 0x7A000000));
                System.Diagnostics.Debug.Assert(activatedCol != null);

                // Verify that the symbols were really read.
                SymbolCollection col = view.Symbols.CollectionByAddress(0x70000000);
                //System.Diagnostics.Debug.Assert( col.Count == 0xaa );
                System.Diagnostics.Debug.WriteLine(col.ToString("full", null));

                // Verify that the collections are the same
                System.Diagnostics.Debug.Assert(activatedCol.Count == col.Count);
                System.Diagnostics.Debug.Assert(activatedCol.FileName == col.FileName);
                System.Diagnostics.Debug.Assert(activatedCol == col);

                // Cannot activate the same dll twice
                bool activated = symView.Activate(new CodeSegDefinition(@"Z:\sys\bin\AcCmOnItOr.dll", 0x80000000, 0x8A000000));
                System.Diagnostics.Debug.Assert(activated == false);

                // Cannot activate an overlapping area.
                activated = symView.Activate(new CodeSegDefinition(@"Z:\sys\bin\AIFW.dll", 0x70000000, 0x70040000));
                System.Diagnostics.Debug.Assert(activated == false);

                // Cannot deactivate a non-activated dll
                bool deactivated = symView.Deactivate(new CodeSegDefinition(@"Z:\sys\bin\AIUTILS.DLL"));
                System.Diagnostics.Debug.Assert(deactivated == false);

                // Cannot deactivate a missing dll
                deactivated = symView.Deactivate(new CodeSegDefinition(@"Z:\sys\bin\THIS_DOES_NOT_EXIST.EXE"));
                System.Diagnostics.Debug.Assert(deactivated == false);

                // Look up first symbol
                Symbol sym  = null;
                Symbol sym2 = null;
                sym = symView.Lookup(0x70000000, out col);
                System.Diagnostics.Debug.Assert(sym != null && col == activatedCol && sym.Name == "_E32Dll");
                sym = symView.Lookup(0x70000027, out col);
                System.Diagnostics.Debug.Assert(sym != null && col == activatedCol && sym.Name == "_E32Dll");

                // For the following sequence, ensure that we discard the CAccMonitor::~CAccMonitor__sub_object()
                // line and keep the CAccMonitor::~CAccMonitor() line instead. Ensure that the size of the
                // CAccMonitor::~CAccMonitor() entry has been calculated using the data from the sub_object entry which
                // we threw away.
                //
                //     CAccMonitor::~CAccMonitor__deallocating() 0x00009195   Thumb Code    16  accmonitor.in(i._ZN11CAccMonitorD0Ev)
                //     CAccMonitor::~CAccMonitor()              0x000091a5   Thumb Code     0  accmonitor.in(i._ZN11CAccMonitorD2Ev)
                //     CAccMonitor::~CAccMonitor__sub_object()  0x000091a5   Thumb Code     8  accmonitor.in(i._ZN11CAccMonitorD2Ev)
                //     CAccMonitorInfo::Reset()                 0x000091ad   Thumb Code    28  accmonitor.in(i._ZN15CAccMonitorInfo5ResetEv)
                //
                sym = FindByName("CAccMonitor::~CAccMonitor__sub_object()", col);
                System.Diagnostics.Debug.Assert(sym == null);
                sym = FindByName("CAccMonitor::~CAccMonitor()", col);
                System.Diagnostics.Debug.Assert(sym != null && sym.Size == 8);

                // For the following sequence, ensure that we discard the sub object and keep the destructor.
                //
                //      RArray<unsigned long>::RArray()          0x00009289   Thumb Code    10  accmonitor.in(t._ZN6RArrayImEC1Ev)
                //      RArray<unsigned long>::RArray__sub_object() 0x00009289   Thumb Code     0  accmonitor.in(t._ZN6RArrayImEC1Ev)
                sym = FindByName("RArray<unsigned long>::RArray__sub_object()", col);
                System.Diagnostics.Debug.Assert(sym == null);
                sym = FindByName("RArray<unsigned long>::RArray()", col);
                System.Diagnostics.Debug.Assert(sym != null && sym.Size == 10);

                // For the following sequence, ensure that the end of the first entry doesn't overlap with the start of the second.
                //
                //      typeinfo name for CAccMonitorCapMapper   0x000094a8   Data          23  accmonitor.in(.constdata__ZTS20CAccMonitorCapMapper)
                //      typeinfo name for CAccMonitorContainer   0x000094bf   Data          23  accmonitor.in(.constdata__ZTS20CAccMonitorContainer)
                //
                sym = FindByName("typeinfo name for CAccMonitorCapMapper", col);
                System.Diagnostics.Debug.Assert(sym != null);
                sym2 = FindByName("typeinfo name for CAccMonitorContainer", col);
                System.Diagnostics.Debug.Assert(sym2 != null);
                System.Diagnostics.Debug.Assert(sym.AddressRange.Max + 1 == sym2.Address);

                // Check no overlap
                CheckNoOverlaps(col);

                // Second symbol
                sym = symView.Lookup(0x70000028, out col);
                System.Diagnostics.Debug.Assert(sym != null && col == activatedCol && sym.Name == "__cpp_initialize__aeabi_");

                // Multithreaded symbol lookup times
                ThreadPool.QueueUserWorkItem(new WaitCallback(MultiThreadedLookup), new AsyncData(symView, iWaiter1, col, 10000));
                ThreadPool.QueueUserWorkItem(new WaitCallback(MultiThreadedLookup), new AsyncData(symView, iWaiter2, col, 5000));
                ThreadPool.QueueUserWorkItem(new WaitCallback(MultiThreadedLookup), new AsyncData(symView, iWaiter3, col, 8000));
                ThreadPool.QueueUserWorkItem(new WaitCallback(MultiThreadedLookup), new AsyncData(symView, iWaiter4, col, 20000));

                // Wait
                using ( iWaiter4 )
                {
                    iWaiter4.WaitOne();
                }
                using ( iWaiter3 )
                {
                    iWaiter3.WaitOne();
                }
                using ( iWaiter2 )
                {
                    iWaiter2.WaitOne();
                }
                using ( iWaiter1 )
                {
                    iWaiter1.WaitOne();
                }

                // Deactivate an activated dll
                deactivated = symView.Deactivate(new CodeSegDefinition(@"Z:\sys\bin\ACCMONITOR.DLL"));
                System.Diagnostics.Debug.Assert(deactivated == true);

                // symbol shouldn't be available anymore
                sym = symView.Lookup(0x70000000, out col);
                System.Diagnostics.Debug.Assert(sym == null && col == null);
            }
        }