示例#1
0
        public void GetInfo()
        {
            ulong  testCodeLoadAddress   = 456;
            ulong  testCodeSize          = 789;
            string testSymbolFile        = "symbol file";
            string testSymbolDirectory   = "c:\\symbol\\dir";
            string testPlatformFile      = "platform file";
            string testPlatformDirectory = "/platform/dir";

            var mockPlatformFileSpec = Substitute.For <SbFileSpec>();

            mockPlatformFileSpec.GetFilename().Returns(testPlatformFile);
            mockPlatformFileSpec.GetDirectory().Returns(testPlatformDirectory);

            var mockSymbolFileSpec = Substitute.For <SbFileSpec>();

            mockSymbolFileSpec.GetFilename().Returns(testSymbolFile);
            mockSymbolFileSpec.GetDirectory().Returns(testSymbolDirectory);

            _mockModule.GetPlatformFileSpec().Returns(mockPlatformFileSpec);
            _mockModule.GetSymbolFileSpec().Returns(mockSymbolFileSpec);
            _mockModule.GetCodeLoadAddress().Returns(testCodeLoadAddress);
            _mockModule.GetCodeSize().Returns(testCodeSize);
            _mockModule.Is64Bit().Returns(true);
            _mockModuleUtil.HasSymbolsLoaded(_mockModule).Returns(true);

            var flags = enum_MODULE_INFO_FIELDS.MIF_NAME | enum_MODULE_INFO_FIELDS.MIF_URL |
                        enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION |
                        enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS |
                        enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS |
                        enum_MODULE_INFO_FIELDS.MIF_SIZE | enum_MODULE_INFO_FIELDS.MIF_LOADORDER |
                        enum_MODULE_INFO_FIELDS.MIF_FLAGS;
            var moduleInfo = new MODULE_INFO[1];

            Assert.Multiple(() =>
            {
                Assert.That(_debugModule.GetInfo(flags, moduleInfo), Is.EqualTo(VSConstants.S_OK));
                Assert.That(moduleInfo[0].dwValidFields, Is.EqualTo(flags));
                Assert.That(moduleInfo[0].m_bstrName, Is.EqualTo(testPlatformFile));
                Assert.That(moduleInfo[0].m_bstrUrl,
                            Is.EqualTo(testPlatformDirectory + "/" + testPlatformFile));
                Assert.That(moduleInfo[0].m_bstrUrlSymbolLocation,
                            Is.EqualTo(testSymbolDirectory + "\\" + testSymbolFile));
                Assert.That(moduleInfo[0].m_addrLoadAddress, Is.EqualTo(testCodeLoadAddress));
                Assert.That(moduleInfo[0].m_dwSize, Is.EqualTo(testCodeSize));
                Assert.That(moduleInfo[0].m_dwLoadOrder, Is.EqualTo(_testLoadOrder));
                Assert.That(moduleInfo[0].m_dwModuleFlags,
                            Is.EqualTo(enum_MODULE_FLAGS.MODULE_FLAG_64BIT |
                                       enum_MODULE_FLAGS.MODULE_FLAG_SYMBOLS));
            });
        }
示例#2
0
        public int GetInfo(enum_MODULE_INFO_FIELDS fields, MODULE_INFO[] moduleInfo)
        {
            var        info             = new MODULE_INFO();
            SbFileSpec platformFileSpec = _lldbModule.GetPlatformFileSpec();

            if ((enum_MODULE_INFO_FIELDS.MIF_NAME & fields) != 0)
            {
                if (platformFileSpec != null)
                {
                    info.m_bstrName     = platformFileSpec.GetFilename();
                    info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_NAME;
                }
            }

            // "URL" fills in the "Path" column in the Modules window.
            if ((enum_MODULE_INFO_FIELDS.MIF_URL & fields) != 0)
            {
                // The module paths are for remote files (on Linux).
                if (platformFileSpec != null)
                {
                    info.m_bstrUrl = FileUtil.PathCombineLinux(
                        platformFileSpec.GetDirectory(), platformFileSpec.GetFilename());
                }

                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URL;
            }

            // "URLSYMBOLLOCATION" fills in the Symbol File Location column.
            if ((enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION & fields) != 0)
            {
                if (_moduleUtil.HasSymbolsLoaded(_lldbModule))
                {
                    // The symbol paths are for local files (on Windows).
                    SbFileSpec symbolFileSpec = _lldbModule.GetSymbolFileSpec();
                    if (symbolFileSpec != null)
                    {
                        info.m_bstrUrlSymbolLocation = Path.Combine(
                            symbolFileSpec.GetDirectory(), symbolFileSpec.GetFilename());
                        info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_URLSYMBOLLOCATION;
                    }
                }
            }

            if ((enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS & fields) != 0)
            {
                info.m_addrLoadAddress = _lldbModule.GetCodeLoadAddress();
                info.dwValidFields    |= enum_MODULE_INFO_FIELDS.MIF_LOADADDRESS;
            }

            if ((enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS & fields) != 0)
            {
                // TODO: Find the actual preferred load address rather than
                // pretending the module is loaded in the right place.
                // We may choose to ignore this, as samples do: extracting the preferred base
                // address from the library / executable seems nontrivial.
                // If m_addrLoadAddress is a different value, VS will show a warning on the icons
                // in the Modules window.
                info.m_addrPreferredLoadAddress = info.m_addrLoadAddress;
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_PREFFEREDADDRESS;
            }

            if ((enum_MODULE_INFO_FIELDS.MIF_SIZE & fields) != 0)
            {
                info.m_dwSize       = (uint)_lldbModule.GetCodeSize();
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_SIZE;
            }

            if ((enum_MODULE_INFO_FIELDS.MIF_LOADORDER & fields) != 0)
            {
                info.m_dwLoadOrder  = _loadOrder;
                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_LOADORDER;
            }

            if ((enum_MODULE_INFO_FIELDS.MIF_FLAGS & fields) != 0)
            {
                info.m_dwModuleFlags = 0;
                if (_moduleUtil.HasSymbolsLoaded(_lldbModule))
                {
                    info.m_dwModuleFlags |= enum_MODULE_FLAGS.MODULE_FLAG_SYMBOLS;
                }

                if (_lldbModule.Is64Bit())
                {
                    info.m_dwModuleFlags |= enum_MODULE_FLAGS.MODULE_FLAG_64BIT;
                }

                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_FLAGS;
            }

            if ((enum_MODULE_INFO_FIELDS.MIF_DEBUGMESSAGE & fields) != 0)
            {
                if (!_moduleUtil.HasSymbolsLoaded(_lldbModule))
                {
                    var inclusionSetting = _symbolSettingsProvider.GetInclusionSettings();
                    if (!inclusionSetting.IsModuleIncluded(ModuleName))
                    {
                        info.m_bstrDebugMessage = SymbolInclusionSettings.ModuleExcludedMessage;
                    }
                }

                info.dwValidFields |= enum_MODULE_INFO_FIELDS.MIF_DEBUGMESSAGE;
            }

            moduleInfo[0] = info;
            return(VSConstants.S_OK);
        }