コード例 #1
0
 /// <summary>
 /// append a new symbol path element to the begining of the symbol path represented by 'this'.
 /// </summary>
 public void Add(SymPathElement elem)
 {
     if (elem != null && !_elements.Contains(elem))
     {
         _elements.Add(elem);
     }
 }
コード例 #2
0
 /// <summary>
 /// insert a new symbol path element to the begining of the symbol path represented by 'this'.
 /// </summary>
 public void Insert(SymPathElement elem)
 {
     if (elem != null)
     {
         var existing = _elements.IndexOf(elem);
         if (existing >= 0)
         {
             _elements.RemoveAt(existing);
         }
         _elements.Insert(0, elem);
     }
 }
コード例 #3
0
        /// <summary>
        /// Implements object interface
        /// </summary>
        public override bool Equals(object obj)
        {
            SymPathElement asSymPathElem = obj as SymPathElement;

            if (asSymPathElem == null)
            {
                return(false);
            }

            return
                (Target == asSymPathElem.Target &&
                 Cache == asSymPathElem.Cache &&
                 IsSymServer == asSymPathElem.IsSymServer);
        }
コード例 #4
0
        private async Task <string> SearchSymbolServerForFile(string fileSimpleName, string fileIndexPath, Func <string, bool> match)
        {
            var tasks = new List <Task <string> >();

            foreach (var element in SymPathElement.GetElements(SymbolPath))
            {
                if (element.IsSymServer)
                {
                    tasks.Add(TryGetFileFromServerAsync(element.Target, fileIndexPath, element.Cache ?? SymbolCache));
                }
                else
                {
                    string fullDestPath = Path.Combine(element.Cache ?? SymbolCache, fileIndexPath);
                    string sourcePath   = Path.Combine(element.Target, fileSimpleName);
                    tasks.Add(CheckAndCopyRemoteFile(sourcePath, fullDestPath, match));
                }
            }

            string result = await tasks.GetFirstNonNullResult();

            return(result);
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        /// <summary>
        /// Attempts to locate a binary via the symbol server.  This function will then copy the file
        /// locally to the symbol cache and return the location of the local file on disk.
        /// </summary>
        /// <param name="fileName">The filename that the binary is indexed under.</param>
        /// <param name="buildTimeStamp">The build timestamp the binary is indexed under.</param>
        /// <param name="imageSize">The image size the binary is indexed under.</param>
        /// <param name="checkProperties">Whether or not to validate the properties of the binary after download.</param>
        /// <returns>A full path on disk (local) of where the binary was copied to, null if it was not found.</returns>
        public override string FindBinary(string fileName, int buildTimeStamp, int imageSize, bool checkProperties = true)
        {
            string fullPath = fileName;

            fileName = Path.GetFileName(fullPath).ToLower();

            // First see if we already have the result cached.
            FileEntry entry  = new FileEntry(fileName, buildTimeStamp, imageSize);
            string    result = GetFileEntry(entry);

            if (result != null)
            {
                return(result);
            }

            HashSet <FileEntry> missingFiles = _missingFiles;

            if (IsMissing(missingFiles, entry))
            {
                return(null);
            }

            // Test to see if the file is on disk.
            if (ValidateBinary(fullPath, buildTimeStamp, imageSize, checkProperties))
            {
                SetFileEntry(missingFiles, entry, fullPath);
                return(fullPath);
            }

            // Finally, check the symbol paths.
            string exeIndexPath = null;

            foreach (SymPathElement element in SymPathElement.GetElements(SymbolPath))
            {
                if (element.IsSymServer)
                {
                    if (exeIndexPath == null)
                    {
                        exeIndexPath = GetIndexPath(fileName, buildTimeStamp, imageSize);
                    }

                    string target = TryGetFileFromServer(element.Target, exeIndexPath, element.Cache ?? SymbolCache);
                    if (target == null)
                    {
                        Trace($"Server '{element.Target}' did not have file '{Path.GetFileName(fileName)}' with timestamp={buildTimeStamp:x} and filesize={imageSize:x}.");
                    }
                    else if (ValidateBinary(target, buildTimeStamp, imageSize, checkProperties))
                    {
                        Trace($"Found '{fileName}' on server '{element.Target}'.  Copied to '{target}'.");
                        SetFileEntry(missingFiles, entry, target);
                        return(target);
                    }
                }
                else
                {
                    string filePath = Path.Combine(element.Target, fileName);
                    if (ValidateBinary(filePath, buildTimeStamp, imageSize, checkProperties))
                    {
                        Trace($"Found '{fileName}' at '{filePath}'.");
                        SetFileEntry(missingFiles, entry, filePath);
                        return(filePath);
                    }
                }
            }

            SetFileEntry(missingFiles, entry, null);
            return(null);
        }
コード例 #7
0
 /// <summary>
 /// insert a new symbol path element to the begining of the symbol path represented by 'this'.
 /// </summary>
 public void Insert(SymPathElement elem)
 {
     if (elem != null)
     {
         var existing = m_elements.IndexOf(elem);
         if (existing >= 0)
             m_elements.RemoveAt(existing);
         m_elements.Insert(0, elem);
     }
 }
コード例 #8
0
 /// <summary>
 /// append a new symbol path element to the begining of the symbol path represented by 'this'.
 /// </summary>
 public void Add(SymPathElement elem)
 {
     if (elem != null && !m_elements.Contains(elem))
         m_elements.Add(elem);
 }