bool SkipModule(string module, SymbolInclusionSettings settings)
        {
            if (settings == null)
            {
                return(false);
            }

            return(!settings.IsModuleIncluded(module));
        }
 /// <summary>
 /// Load missing binaries and symbols. Skips modules that already have their symbols loaded
 /// or that are excluded via Include / Exclude options on symbols settings page.
 /// </summary>
 public Task <int> LoadModuleFilesAsync(
     SymbolInclusionSettings symbolsSettings,bool useSymbolStores,ICancelable task,
     IModuleFileLoadMetricsRecorder moduleFileLoadRecorder)
 {
     return(_moduleFileLoader.LoadModuleFilesAsync(
                Enumerable.Range(0,NumLoadedModules)
                .Select(_target.GetModuleAtIndex)
                .Where(m => m != null)
                .ToList(),
                symbolsSettings,useSymbolStores,task,moduleFileLoadRecorder));
 }
        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);
        }