Exemple #1
0
        public PlaceholderModuleProperties GetPlaceholderProperties(SbModule placeholderModule,
                                                                    RemoteTarget lldbTarget)
        {
            SbSection placeholderSection = placeholderModule.FindSection(".module_image");

            if (placeholderSection == null)
            {
                // Could be either an RPC error or a usage error. Hmm...
                throw new ArgumentException(
                          "Placeholder properties can only be copied from placeholder modules.");
            }

            // The load address of the placeholder section represents the base load address of the
            // module as a whole in the original process.
            ulong placeholderBaseLoadAddress = placeholderSection.GetLoadAddress(lldbTarget);

            if (placeholderBaseLoadAddress == DebuggerConstants.INVALID_ADDRESS)
            {
                Trace.WriteLine("Failed to get load address from the placeholder section.");
                return(null);
            }

            // |slide| is how much we need to offset the module's load address by
            long slide = (long)placeholderBaseLoadAddress;

            SbFileSpec fileSpec = placeholderModule.GetPlatformFileSpec();

            if (fileSpec == null)
            {
                Trace.WriteLine("Failed to get file spec from placeholder module.");
                return(null);
            }
            return(new PlaceholderModuleProperties(slide, fileSpec));
        }
        public void SetUp()
        {
            mockTask = Substitute.For <ICancelable>();

            mockPlatformFileSpec = Substitute.For <SbFileSpec>();
            mockPlatformFileSpec.GetDirectory().Returns(PLATFORM_DIRECTORY);
            mockPlatformFileSpec.GetFilename().Returns(BINARY_FILENAME);

            fakeModuleFileLoadRecorder = new FakeModuleFileLoadRecorder();

            mockSymbolLoader = Substitute.For <ISymbolLoader>();
            mockSymbolLoader
            .LoadSymbolsAsync(Arg.Any <SbModule>(), Arg.Any <TextWriter>(), Arg.Any <bool>())
            .Returns(Task.FromResult(false));
            mockBinaryLoader = Substitute.For <IBinaryLoader>();
            var anyModule = Arg.Any <SbModule>();

            mockBinaryLoader
            .LoadBinaryAsync(anyModule, Arg.Any <TextWriter>())
            .Returns((anyModule, false));

            mockModuleSearchLogHolder = new ModuleSearchLogHolder();
            moduleFileLoader          = new ModuleFileLoader(mockSymbolLoader, mockBinaryLoader,
                                                             mockModuleSearchLogHolder);
        }
        public void SetSearchLog(SbModule lldbModule, string log)
        {
            SbFileSpec platformFileSpec = lldbModule.GetPlatformFileSpec();

            if (platformFileSpec != null)
            {
                string key = FileUtil.PathCombineLinux(platformFileSpec.GetDirectory(),
                                                       platformFileSpec.GetFilename());
                _logsByPlatformFileSpec[key] = log;
            }
        }
        public override Task <SetPlatformFileSpecResponse> SetPlatformFileSpec(
            SetPlatformFileSpecRequest request, ServerCallContext context)
        {
            var        module   = moduleStore.GetObject(request.Module.Id);
            SbFileSpec fileSpec = fileSpecFactory.Create(request.FileSpec.Directory,
                                                         request.FileSpec.Filename);

            return(Task.FromResult(
                       new SetPlatformFileSpecResponse {
                Result = module.SetPlatformFileSpec(fileSpec)
            }));
        }
Exemple #5
0
        public void SetUp()
        {
            logSpy = new LogSpy();
            logSpy.Attach();

            var noError = new SbErrorStub(true, null);

            mockTarget = Substitute.For <RemoteTarget>();
            mockTarget.SetModuleLoadAddress(Arg.Any <SbModule>(), Arg.Any <long>()).Returns(noError);
            mockModule = Substitute.For <SbModule>();
            mockModule.HasCompileUnits().Returns(false);
            mockModule.FindSection(Arg.Any <string>()).Returns((SbSection)null);
            mockPlatformFileSpec = Substitute.For <SbFileSpec>();
            moduleUtil           = new LldbModuleUtil();
        }
        public string GetSearchLog(SbModule lldbModule)
        {
            SbFileSpec platformFileSpec = lldbModule.GetPlatformFileSpec();

            if (platformFileSpec == null)
            {
                return("");
            }

            string key = FileUtil.PathCombineLinux(platformFileSpec.GetDirectory(),
                                                   platformFileSpec.GetFilename());

            if (_logsByPlatformFileSpec.TryGetValue(key, out string log))
            {
                return(log);
            }

            return("");
        }
        public void SetUp()
        {
            searchLog = new StringWriter();

            mockBinaryFileUtil = Substitute.For <IBinaryFileUtil>();

            mockSuccessCommandReturnObject = Substitute.For <SbCommandReturnObject>();
            mockSuccessCommandReturnObject.GetOutput().Returns(LLDB_OUTPUT);
            mockSuccessCommandReturnObject.GetDescription().Returns("Success: " + LLDB_OUTPUT);
            mockSuccessCommandReturnObject.Succeeded().Returns(true);

            mockCommandInterpreter = Substitute.For <SbCommandInterpreter>();
            SetHandleCommandReturnValue(mockCommandInterpreter, COMMAND_WITH_MODULE_PATH,
                                        ReturnStatus.SuccessFinishResult,
                                        mockSuccessCommandReturnObject);

            mockPlatformFileSpec = Substitute.For <SbFileSpec>();
            mockPlatformFileSpec.GetDirectory().Returns(PLATFORM_DIRECTORY);
            mockPlatformFileSpec.GetFilename().Returns(BINARY_FILENAME);

            mockSymbolFileSpec = Substitute.For <SbFileSpec>();
            mockSymbolFileSpec.GetDirectory().Returns("");
            mockSymbolFileSpec.GetFilename().Returns(SYMBOL_FILE_NAME);

            mockBinaryFileSpec = Substitute.For <SbFileSpec>();
            mockBinaryFileSpec.GetDirectory().Returns(BINARY_DIRECTORY);
            mockBinaryFileSpec.GetFilename().Returns(BINARY_FILENAME);

            mockModuleFileFinder = Substitute.For <IModuleFileFinder>();
            SetFindFileReturnValue(PATH_IN_STORE);
            mockModuleUtil = Substitute.For <ILldbModuleUtil>();
            mockModuleUtil.HasSymbolsLoaded(Arg.Any <SbModule>()).Returns(false);

            symbolLoader = new SymbolLoader(mockModuleUtil, mockBinaryFileUtil,
                                            mockModuleFileFinder, mockCommandInterpreter);

            symbolFileInStore = Substitute.For <IFileReference>();
            symbolFileInStore.IsFilesystemLocation.Returns(true);
            symbolFileInStore.Location.Returns(PATH_IN_STORE);

            logSpy = new LogSpy();
            logSpy.Attach();
        }
 public bool SetPlatformFileSpec(SbFileSpec fileSpec)
 {
     return(SetPlatformFileSpec(fileSpec.GetDirectory(), fileSpec.GetFilename()));
 }
Exemple #9
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);
        }
Exemple #10
0
 public PlaceholderModuleProperties(long slide, SbFileSpec platformFileSpec)
 {
     this.Slide            = slide;
     this.PlatformFileSpec = platformFileSpec;
 }