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 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())); }
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); }