bool TryPreloadModule(RemoteTarget lldbTarget, TextWriter searchLog, DumpModule module) { string moduleOriginPath = Path.GetDirectoryName(module.Path); string moduleName = Path.GetFileName(module.Path); string modulePath = _taskContext.Factory.Run(() => { return(_moduleFileFinder.FindFileAsync(moduleName, module.Id, false, searchLog)); }); if (!string.IsNullOrWhiteSpace(modulePath)) { var sbModule = lldbTarget.AddModule(modulePath, "", module.Id.ToUUIDString()); Trace.WriteLine($"Full dump load: found module {moduleName} with id {module.Id} " + $"by path {modulePath}. Module preloaded: {sbModule != null}"); if (sbModule?.SetPlatformFileSpec(moduleOriginPath, moduleName) == true) { Trace.WriteLine($"Full dump load: module {moduleName} path set to " + $"{moduleOriginPath}."); _moduleSearchLogHolder.SetSearchLog(sbModule, searchLog.ToString()); return(true); } } return(false); }
public async Task <int> LoadModuleFilesAsync( IList <SbModule> modules, SymbolInclusionSettings symbolSettings, bool useSymbolStores, ICancelable task, IModuleFileLoadMetricsRecorder moduleFileLoadRecorder) { if (modules == null) { throw new ArgumentNullException(nameof(modules)); } if (task == null) { throw new ArgumentNullException(nameof(task)); } if (moduleFileLoadRecorder == null) { throw new ArgumentNullException(nameof(moduleFileLoadRecorder)); } // Add some metrics to the event proto before attempting to load symbols, so that they // are still recorded if the task is aborted or cancelled. moduleFileLoadRecorder.RecordBeforeLoad(modules); int result = VSConstants.S_OK; for (int i = 0; i < modules.Count; ++i) { SbModule module = modules[i]; TextWriter searchLog = new StringWriter(); string name = module.GetPlatformFileSpec()?.GetFilename() ?? "<unknown>"; try { task.ThrowIfCancellationRequested(); if (SkipModule(name, symbolSettings)) { await searchLog.WriteLineAsync( SymbolInclusionSettings.ModuleExcludedMessage); continue; } task.Progress.Report($"Loading binary for {name} ({i}/{modules.Count})"); (SbModule newModule, bool ok) = await _binaryLoader.LoadBinaryAsync(module, searchLog); if (!ok) { result = VSConstants.E_FAIL; continue; } module = newModule; task.ThrowIfCancellationRequested(); task.Progress.Report($"Loading symbols for {name} ({i}/{modules.Count})"); var loaded = await _symbolLoader.LoadSymbolsAsync(module, searchLog, useSymbolStores); if (!loaded) { result = VSConstants.E_FAIL; continue; } } finally { _moduleSearchLogHolder.SetSearchLog(module, searchLog.ToString()); modules[i] = module; } } moduleFileLoadRecorder.RecordAfterLoad(modules); return(result); }