private void SetPdbEntry(HashSet <PdbEntry> missing, PdbEntry entry, string value) { if (value == null) { missing.Add(entry); } else { _pdbCache[entry] = value; } }
private string GetPdbEntry(PdbEntry entry) { lock (s_pdbs) { if (s_pdbs.TryGetValue(entry, out Task <string> task)) { return(task.Result); } } return(null); }
private string GetPdbEntry(PdbEntry entry) { string result; if (!_pdbCache.TryGetValue(entry, out result)) { return(null); } Debug.Assert(result != null); if (File.Exists(result)) { return(result); } _pdbCache.Remove(entry); return(null); }
private void SetPdbEntry(HashSet <PdbEntry> missing, PdbEntry entry, string value) { if (value != null) { lock (s_pdbs) { if (!s_pdbs.ContainsKey(entry)) { Task <string> task = new Task <string>(() => value); s_pdbs[entry] = task; task.Start(); } } } else { lock (missing) missing.Add(entry); } }
/// <summary> /// Attempts to locate a pdb based on its name, guid, and revision number. /// </summary> /// <param name="pdbName">The name the pdb is indexed under.</param> /// <param name="pdbIndexGuid">The guid the pdb is indexed under.</param> /// <param name="pdbIndexAge">The age of the pdb.</param> /// <returns>A full path on disk (local) of where the pdb was copied to.</returns> public async override Task <string> FindPdbAsync(string pdbName, Guid pdbIndexGuid, int pdbIndexAge) { if (string.IsNullOrWhiteSpace(pdbName)) { throw new ArgumentNullException(nameof(pdbName)); } // Ensure we don't attempt to download the same pdb multiple times. string pdbSimpleName = Path.GetFileName(pdbName); PdbEntry pdbEntry = new PdbEntry(pdbSimpleName, pdbIndexGuid, pdbIndexAge); var missingPdbs = _missingPdbs; Task <string> task = null; lock (s_pdbs) { if (IsMissing(missingPdbs, pdbEntry)) { return(null); } if (!s_pdbs.TryGetValue(pdbEntry, out task)) { task = s_pdbs[pdbEntry] = DownloadPdbWorker(pdbName, pdbSimpleName, pdbIndexGuid, pdbIndexAge); } } // If we failed to find the file, we need to clear out the empty task, since the user could // change symbol paths and we need s_files to only contain positive results. string result = await task; if (result == null) { ClearFailedTask(s_pdbs, task, missingPdbs, pdbEntry); } return(result); }
/// <summary> /// Default implementation of finding a pdb. /// </summary> /// <param name="pdbName">The name the pdb is indexed under.</param> /// <param name="pdbIndexGuid">The guid the pdb is indexed under.</param> /// <param name="pdbIndexAge">The age of the pdb.</param> /// <returns>A full path on disk (local) of where the pdb was copied to.</returns> public override string FindPdb(string pdbName, Guid pdbIndexGuid, int pdbIndexAge) { if (string.IsNullOrEmpty(pdbName)) { return(null); } string pdbSimpleName = Path.GetFileName(pdbName); if (pdbName != pdbSimpleName) { if (ValidatePdb(pdbName, pdbIndexGuid, pdbIndexAge)) { return(pdbName); } } // Check to see if it's already cached. PdbEntry entry = new PdbEntry(pdbSimpleName, pdbIndexGuid, pdbIndexAge); string result = GetPdbEntry(entry); if (result != null) { return(result); } HashSet <PdbEntry> missingPdbs = _missingPdbs; if (IsMissing(missingPdbs, entry)) { return(null); } string pdbIndexPath = GetIndexPath(pdbSimpleName, pdbIndexGuid, pdbIndexAge); foreach (SymPathElement element in SymPathElement.GetElements(SymbolPath)) { if (element.IsSymServer) { string targetPath = TryGetFileFromServer(element.Target, pdbIndexPath, element.Cache ?? SymbolCache); if (targetPath != null) { Trace("Found pdb {0} from server '{1}' on path '{2}'. Copied to '{3}'.", pdbSimpleName, element.Target, pdbIndexPath, targetPath); SetPdbEntry(missingPdbs, entry, targetPath); return(targetPath); } Trace("No matching pdb found on server '{0}' on path '{1}'.", element.Target, pdbIndexPath); } else { string fullPath = Path.Combine(element.Target, pdbSimpleName); if (ValidatePdb(fullPath, pdbIndexGuid, pdbIndexAge)) { Trace($"Found pdb '{pdbSimpleName}' at '{fullPath}'."); SetPdbEntry(missingPdbs, entry, fullPath); return(fullPath); } Trace($"Mismatched pdb found at '{fullPath}'."); } } SetPdbEntry(missingPdbs, entry, null); return(null); }
public string FindPdb(string pdbName, Guid pdbIndexGuid, int pdbIndexAge) { if (string.IsNullOrEmpty(pdbName)) { return(null); } string pdbSimpleName = Path.GetFileName(pdbName); if (pdbName != pdbSimpleName) { if (PdbMatches(pdbName, pdbIndexGuid, pdbIndexAge)) { return(pdbName); } } PdbEntry entry = new PdbEntry(pdbSimpleName, pdbIndexGuid, pdbIndexAge); string result = null; if (_pdbCache.TryGetValue(entry, out result)) { return(result); } string pdbIndexPath = null; foreach (SymPathElement element in SymbolElements) { if (element.IsSymServer) { if (pdbIndexPath == null) { pdbIndexPath = GetIndexPath(pdbSimpleName, pdbIndexGuid, pdbIndexAge); } string targetPath = TryGetFileFromServer(element.Target, pdbIndexPath, element.Cache ?? SymbolCache); if (targetPath != null) { WriteLine("Found pdb {0} from server '{1}' on path '{2}'. Copied to '{3}'.", pdbSimpleName, element.Target, pdbIndexPath, targetPath); _pdbCache[entry] = targetPath; return(targetPath); } else { WriteLine("No matching pdb found on server '{0}' on path '{1}'.", element.Target, pdbIndexPath); } } else { string fullPath = Path.Combine(element.Target, pdbSimpleName); if (PdbMatches(fullPath, pdbIndexGuid, pdbIndexAge)) { _pdbCache[entry] = fullPath; return(fullPath); } } } return(null); }