Skip to content

Commit

Permalink
SymbolReader doesn't support UNC symbol paths. Issue: dotnet#674
Browse files Browse the repository at this point in the history
  • Loading branch information
mikem8361 committed Dec 11, 2019
1 parent 2ed41f8 commit 710720b
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions src/SOS/SOS.NETCore/SymbolReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1106,43 +1106,41 @@ private static bool GetServerSymbolStore(ref SymbolStore store, bool msdl, bool
{
// Use the internal symbol store for symweb
internalServer = symbolServerPath.Contains("symweb");

// Make sure the server Uri ends with "/"
symbolServerPath = symbolServerPath.TrimEnd('/') + '/';
}

if (symbolServerPath != null)
{
// Validate symbol server path
if (!Uri.TryCreate(symbolServerPath, UriKind.Absolute, out Uri uri) || uri.IsFile)
if (!Uri.TryCreate(symbolServerPath.TrimEnd('/') + '/', UriKind.Absolute, out Uri uri))
{
return false;
}

if (!IsDuplicateSymbolStore<HttpSymbolStore>(store, (httpSymbolStore) => uri.Equals(httpSymbolStore.Uri)))
// Add a cache symbol store if file or UNC path
if (uri.IsFile || uri.IsUnc)
{
// Create symbol server store
if (internalServer)
{
store = new SymwebHttpSymbolStore(s_tracer, store, uri);
}
else
AddCachePath(ref store, symbolServerPath);
}
else
{
if (!IsDuplicateSymbolStore<HttpSymbolStore>(store, (httpSymbolStore) => uri.Equals(httpSymbolStore.Uri)))
{
store = new HttpSymbolStore(s_tracer, store, uri);
// Create symbol server store
if (internalServer)
{
store = new SymwebHttpSymbolStore(s_tracer, store, uri);
}
else
{
store = new HttpSymbolStore(s_tracer, store, uri);
}
}
}
}

if (symbolCachePath != null)
{
symbolCachePath = Path.GetFullPath(symbolCachePath);

// Check only the first symbol store for duplication. The same cache directory can be
// added more than once but just not more than once in a row.
if (!(store is CacheSymbolStore cacheSymbolStore && IsPathEqual(symbolCachePath, cacheSymbolStore.CacheDirectory)))
{
store = new CacheSymbolStore(s_tracer, store, symbolCachePath);
}
AddCachePath(ref store, symbolCachePath);
}

if (symbolDirectoryPath != null)
Expand All @@ -1158,6 +1156,18 @@ private static bool GetServerSymbolStore(ref SymbolStore store, bool msdl, bool
return true;
}

private static void AddCachePath(ref SymbolStore store, string symbolCachePath)
{
symbolCachePath = Path.GetFullPath(symbolCachePath);

// Check only the first symbol store for duplication. The same cache directory can be
// added more than once but just not more than once in a row.
if (!(store is CacheSymbolStore cacheSymbolStore && IsPathEqual(symbolCachePath, cacheSymbolStore.CacheDirectory)))
{
store = new CacheSymbolStore(s_tracer, store, symbolCachePath);
}
}

private static bool IsDuplicateSymbolStore<T>(SymbolStore symbolStore, Func<T, bool> match)
where T : SymbolStore
{
Expand Down

0 comments on commit 710720b

Please sign in to comment.