private SymbolStore BuildSymbolStore() { SymbolStore store = null; foreach (ServerInfo server in ((IEnumerable <ServerInfo>)SymbolServers).Reverse()) { if (server.InternalSymwebServer) { store = new SymwebHttpSymbolStore(Tracer, store, server.Uri, server.PersonalAccessToken); } else { store = new HttpSymbolStore(Tracer, store, server.Uri, server.PersonalAccessToken); } } // Add default symbol cache if one wasn't set by the command line if (CacheDirectories.Count == 0) { CacheDirectories.Add(GetDefaultSymbolCache()); } foreach (string cache in ((IEnumerable <string>)CacheDirectories).Reverse()) { store = new CacheSymbolStore(Tracer, store, cache); } return(store); }
private static bool GetServerSymbolStore(ref SymbolStore store, bool msdl, bool symweb, string symbolServerPath, string symbolCachePath) { bool internalServer = false; // Add symbol server URL if exists if (symbolServerPath == null) { if (msdl) { symbolServerPath = MsdlsymbolServer; } else if (symweb) { symbolServerPath = SymwebSymbolService; internalServer = true; } } else { // Use the internal symbol store for symweb internalServer = symbolServerPath.Contains("symweb"); // Make sure the server Uri ends with "/" symbolServerPath = symbolServerPath.TrimEnd('/') + '/'; } if (symbolServerPath != null) { if (!Uri.TryCreate(symbolServerPath, UriKind.Absolute, out Uri uri) || uri.IsFile) { return(false); } // Create symbol server store if (internalServer) { store = new SymwebHttpSymbolStore(s_tracer, store, uri); } else { store = new HttpSymbolStore(s_tracer, store, uri); } } if (symbolCachePath != null) { store = new CacheSymbolStore(s_tracer, store, symbolCachePath); // Don't add the default cache later s_symbolCacheAdded = true; } return(true); }
public async Task CacheSymbolStore() { using (Stream pdb = File.OpenRead("TestBinaries/HelloWorld.pdb")) { // Clean up any previous cache directories string cacheDirectory = "TestSymbolCache"; try { Directory.Delete(cacheDirectory, recursive: true); } catch (DirectoryNotFoundException) { } var inputFile = new SymbolStoreFile(pdb, "HelloWorld.pdb"); var generator = new PDBFileKeyGenerator(_tracer, inputFile); IEnumerable <SymbolStoreKey> keys = generator.GetKeys(KeyTypeFlags.IdentityKey); Assert.True(keys.Count() == 1); SymbolStoreKey key = keys.First(); var backingStore = new TestSymbolStore(_tracer, key, inputFile); var cacheSymbolStore = new CacheSymbolStore(_tracer, backingStore, cacheDirectory); // This should put HelloWorld.pdb into the cache SymbolStoreFile outputFile = await cacheSymbolStore.GetFile(key, CancellationToken.None); Assert.True(outputFile != null); // Should be the exact same instance given to TestSymbolStore Assert.True(inputFile == outputFile); // This should get it from the cache and not the backingStore backingStore.Dispose(); outputFile = await cacheSymbolStore.GetFile(key, CancellationToken.None); Assert.True(outputFile != null); // Should NOT be the exact same SymbolStoreFile instance given to TestSymbolStore Assert.True(inputFile != outputFile); // Now make sure the output file from the cache is the same as the pdb we opened above CompareStreams(pdb, outputFile.Stream); } }
private SymbolStore BuildSymbolStore() { SymbolStore store = null; foreach (ServerInfo server in ((IEnumerable <ServerInfo>)SymbolServers).Reverse()) { if (server.InternalSymwebServer) { store = new SymwebHttpSymbolStore(Tracer, store, server.Uri, server.PersonalAccessToken); } else { store = new HttpSymbolStore(Tracer, store, server.Uri, server.PersonalAccessToken); } } foreach (string cache in ((IEnumerable <string>)CacheDirectories).Reverse()) { store = new CacheSymbolStore(Tracer, store, cache); } return(store); }
private async Task DownloadFile(string path, bool ms, bool mi, string cache) { using (Stream stream = TestUtilities.OpenCompressedFile(path)) { SymbolStoreFile file = new SymbolStoreFile(stream, path); SymbolStores.SymbolStore store = null; if (ms) { Uri.TryCreate("http://msdl.microsoft.com/download/symbols/", UriKind.Absolute, out Uri uri); store = new HttpSymbolStore(_tracer, store, uri); } if (mi) { Uri.TryCreate("http://symweb.corp.microsoft.com/", UriKind.Absolute, out Uri uri); store = new SymwebHttpSymbolStore(_tracer, store, uri); } if (cache != null) { store = new CacheSymbolStore(_tracer, store, cache); } KeyTypeFlags flags = KeyTypeFlags.IdentityKey; var generator = new FileKeyGenerator(_tracer, file); IEnumerable <SymbolStoreKey> keys = generator.GetKeys(flags); foreach (SymbolStoreKey key in keys) { using (SymbolStoreFile symbolFile = await store.GetFile(key, CancellationToken.None)) { if (symbolFile != null) { CompareStreams(file.Stream, symbolFile.Stream); } } } } }