forked from dotnet/diagnostics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve SymbolService.ParseSymbolPath support for Watson. Issue dotne…
…t#2512. Can now handle the various symbol paths that Watson can throw at us. Doesn't support actually calling the symbol server dll like in the symsrv*symaudit.dll*\\server\share syntax. The dll is ignored.
- Loading branch information
Showing
6 changed files
with
210 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/SymbolServiceTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Microsoft.Diagnostics.DebugServices.Implementation; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.InteropServices; | ||
using Xunit; | ||
|
||
namespace Microsoft.Diagnostics.DebugServices.UnitTests | ||
{ | ||
/// <summary> | ||
/// Test the service event implementation | ||
/// </summary> | ||
public class SymbolServiceTests : IHost | ||
{ | ||
public SymbolServiceTests() | ||
{ | ||
} | ||
|
||
[Fact] | ||
public void SymbolPathTests() | ||
{ | ||
var symbolService = new SymbolService(this); | ||
Assert.False(symbolService.ParseSymbolPath("srv")); | ||
Assert.False(symbolService.ParseSymbolPath("cache")); | ||
Assert.False(symbolService.ParseSymbolPath("symsrv")); | ||
|
||
string defaultServer = $"Server: {SymbolService.MsdlSymbolServer}"; | ||
string defaultPath = $"Cache: {symbolService.DefaultSymbolCache} {defaultServer}"; | ||
string localSymbolCache = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "c:\\localsymbolcache" : "/home/foo/localsymbolcache"; | ||
|
||
Assert.True(symbolService.ParseSymbolPath("srv*")); | ||
Assert.Equal(defaultServer, symbolService.FormatSymbolStores()); | ||
symbolService.DisableSymbolStore(); | ||
|
||
Assert.True(symbolService.ParseSymbolPath("srv**")); | ||
Assert.Equal(defaultPath, symbolService.FormatSymbolStores()); | ||
symbolService.DisableSymbolStore(); | ||
|
||
Assert.True(symbolService.ParseSymbolPath("symsrv*symsrv.dll*")); | ||
Assert.Equal(defaultServer, symbolService.FormatSymbolStores()); | ||
symbolService.DisableSymbolStore(); | ||
|
||
Assert.True(symbolService.ParseSymbolPath("cache*;srv*")); | ||
Assert.Equal(defaultPath, symbolService.FormatSymbolStores()); | ||
symbolService.DisableSymbolStore(); | ||
|
||
Assert.True(symbolService.ParseSymbolPath("srv*http://msdl.microsoft.com/download/symbols/")); | ||
Assert.Equal(defaultServer, symbolService.FormatSymbolStores()); | ||
symbolService.DisableSymbolStore(); | ||
|
||
Assert.True(symbolService.ParseSymbolPath($"srv**{SymbolService.MsdlSymbolServer}")); | ||
Assert.Equal(defaultPath, symbolService.FormatSymbolStores()); | ||
symbolService.DisableSymbolStore(); | ||
|
||
Assert.True(symbolService.ParseSymbolPath($"srv*{localSymbolCache}*{SymbolService.SymwebSymbolServer}")); | ||
string testpath1 = $"Cache: {localSymbolCache} Server: {SymbolService.SymwebSymbolServer}"; | ||
Assert.Equal(testpath1, symbolService.FormatSymbolStores()); | ||
symbolService.DisableSymbolStore(); | ||
|
||
Assert.True(symbolService.ParseSymbolPath($"cache*{localSymbolCache};srv*")); | ||
string testpath2 = $"Cache: {localSymbolCache} Server: {SymbolService.MsdlSymbolServer}"; | ||
Assert.Equal(testpath2, symbolService.FormatSymbolStores()); | ||
symbolService.DisableSymbolStore(); | ||
|
||
Assert.True(symbolService.ParseSymbolPath($"srv**{localSymbolCache}*http://msdl.microsoft.com/download/symbols/")); | ||
Assert.Equal($"Cache: {symbolService.DefaultSymbolCache} Cache: {localSymbolCache} Server: http://msdl.microsoft.com/download/symbols/", symbolService.FormatSymbolStores()); | ||
symbolService.DisableSymbolStore(); | ||
|
||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
{ | ||
Assert.True(symbolService.ParseSymbolPath($"symsrv*symsrv.dll*{localSymbolCache}*\\\\server\\share")); | ||
Assert.Equal($"Cache: {localSymbolCache} Cache: \\\\server\\share", symbolService.FormatSymbolStores()); | ||
symbolService.DisableSymbolStore(); | ||
|
||
Assert.True(symbolService.ParseSymbolPath("symsrv*symsrv.dll*d:\\data\\SYM\\symcache*\\\\aw0eus0symcache.file.core.windows.net\\Symbols*http://localhost/remote200/30e07e1454924e55901d7f693f7eddf1/0/x64/4542784547/remote")); | ||
Assert.Equal("Cache: d:\\data\\SYM\\symcache Cache: \\\\aw0eus0symcache.file.core.windows.net\\Symbols Server: http://localhost/remote200/30e07e1454924e55901d7f693f7eddf1/0/x64/4542784547/remote/", symbolService.FormatSymbolStores()); | ||
symbolService.DisableSymbolStore(); | ||
} | ||
|
||
string symbolDirectory = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "c:\\symbols\\" : "/home/foo/symbols/"; | ||
Assert.True(symbolService.ParseSymbolPath(symbolDirectory)); | ||
Assert.Equal($"Directory: {symbolDirectory}", symbolService.FormatSymbolStores()); | ||
symbolService.DisableSymbolStore(); | ||
|
||
string symbolDirectory2 = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "c:\\foo\\bar" : "/home/foo/bar"; | ||
Assert.True(symbolService.ParseSymbolPath($"{symbolDirectory};{symbolDirectory2};srv*")); | ||
Assert.Equal($"Directory: {symbolDirectory} Directory: {symbolDirectory2} " + defaultServer, symbolService.FormatSymbolStores()); | ||
symbolService.DisableSymbolStore(); | ||
} | ||
|
||
#region IHost | ||
|
||
public IServiceEvent OnShutdownEvent { get; } = new ServiceEvent(); | ||
|
||
HostType IHost.HostType => HostType.DotnetDump; | ||
|
||
IServiceProvider IHost.Services => throw new NotImplementedException(); | ||
|
||
IEnumerable<ITarget> IHost.EnumerateTargets() => throw new NotImplementedException(); | ||
|
||
void IHost.DestroyTarget(ITarget target) => throw new NotImplementedException(); | ||
|
||
#endregion | ||
} | ||
public static class SymbolServiceExtensions | ||
{ | ||
public static string FormatSymbolStores( | ||
this ISymbolService symbolService) | ||
{ | ||
return symbolService.ToString().Replace(Environment.NewLine, " ").TrimEnd(); | ||
} | ||
} | ||
} |