/// Symbol server URLs
/// </summary>
public const string MsdlSymbolServer = "https://msdl.microsoft.com/download/symbols/";
- public const string SymwebSymbolServer = "https://symweb/";
private readonly IHost _host;
private string _defaultSymbolCache;
/// </summary>
public bool IsSymbolStoreEnabled => _symbolStore != null;
+ /// <summary>
+ /// The default symbol server URL (normally msdl) when not overridden in AddSymbolServer.
+ /// </summary>
+ public string DefaultSymbolPath { get; set; } = MsdlSymbolServer;
+
/// <summary>
/// The default symbol cache path:
- ///
/// * dbgeng on Windows uses the dbgeng symbol cache path: %PROGRAMDATA%\dbg\sym
/// * dotnet-dump on Windows uses the VS symbol cache path: %TEMPDIR%\SymbolCache
/// * dotnet-dump/lldb on Linux/MacOS uses: $HOME/.dotnet/symbolcache
}
if (symbolServerPath != null)
{
- if (!AddSymbolServer(msdl: false, symweb: false, symbolServerPath.Trim()))
+ if (!AddSymbolServer(symbolServerPath: symbolServerPath.Trim()))
{
return false;
}
/// <summary>
/// Add symbol server to search path.
/// </summary>
- /// <param name="msdl">if true, use the public Microsoft server</param>
- /// <param name="symweb">if true, use symweb internal server and protocol (file.ptr)</param>
- /// <param name="symbolServerPath">symbol server url (optional)</param>
+ /// <param name="symbolServerPath">symbol server url (optional, uses <see cref="DefaultSymbolPath"/> if null)</param>
/// <param name="authToken">PAT for secure symbol server (optional)</param>
/// <param name="timeoutInMinutes">symbol server timeout in minutes (optional uses <see cref="DefaultTimeout"/> if null)</param>
/// <param name="retryCount">number of retries (optional uses <see cref="DefaultRetryCount"/> if null)</param>
/// <returns>if false, failure</returns>
public bool AddSymbolServer(
- bool msdl,
- bool symweb,
string symbolServerPath = null,
string authToken = null,
int? timeoutInMinutes = null,
int? retryCount = null)
{
- bool internalServer = false;
-
// Add symbol server URL if exists
- if (symbolServerPath == null)
- {
- if (msdl)
- {
- symbolServerPath = MsdlSymbolServer;
- }
- else if (symweb)
- {
- symbolServerPath = SymwebSymbolServer;
- internalServer = true;
- }
- }
- else
- {
- // Use the internal symbol store for symweb
- internalServer = symbolServerPath.Contains("symweb");
- }
-
- // Return error if symbol server path is null and msdl and symweb are false.
- if (symbolServerPath == null)
- {
- return false;
- }
+ symbolServerPath ??= DefaultSymbolPath;
// Validate symbol server path
if (!Uri.TryCreate(symbolServerPath.TrimEnd('/') + '/', UriKind.Absolute, out Uri uri))
if (!IsDuplicateSymbolStore<HttpSymbolStore>(store, (httpSymbolStore) => uri.Equals(httpSymbolStore.Uri)))
{
// Create http symbol server store
- HttpSymbolStore httpSymbolStore;
- if (internalServer)
- {
- httpSymbolStore = new SymwebHttpSymbolStore(Tracer.Instance, store, uri);
- }
- else
- {
- httpSymbolStore = new HttpSymbolStore(Tracer.Instance, store, uri, personalAccessToken: authToken);
- }
+ HttpSymbolStore httpSymbolStore = new(Tracer.Instance, store, uri, personalAccessToken: authToken);
httpSymbolStore.Timeout = TimeSpan.FromMinutes(timeoutInMinutes.GetValueOrDefault(DefaultTimeout));
httpSymbolStore.RetryCount = retryCount.GetValueOrDefault(DefaultRetryCount);
SetSymbolStore(httpSymbolStore);
/// </summary>
bool IsSymbolStoreEnabled { get; }
+ /// <summary>
+ /// The default symbol server URL (normally msdl) when not overridden in AddSymbolServer.
+ /// </summary>
+ string DefaultSymbolPath { get; }
+
/// <summary>
/// The default symbol cache path:
- ///
/// * dbgeng on Windows uses the dbgeng symbol cache path: %PROGRAMDATA%\dbg\sym
/// * dotnet-dump on Windows uses the VS symbol cache path: %TEMPDIR%\SymbolCache
/// * dotnet-dump/lldb on Linux/MacOS uses: $HOME/.dotnet/symbolcache
/// </summary>
- string DefaultSymbolCache { get; set; }
+ string DefaultSymbolCache { get; }
/// <summary>
/// The time out in minutes passed to the HTTP symbol store when not overridden in AddSymbolServer.
/// </summary>
- int DefaultTimeout { get; set; }
+ int DefaultTimeout { get; }
/// <summary>
/// The retry count passed to the HTTP symbol store when not overridden in AddSymbolServer.
/// </summary>
- int DefaultRetryCount { get; set; }
+ int DefaultRetryCount { get; }
/// <summary>
/// Reset any HTTP symbol stores marked with a client failure
/// <summary>
/// Add symbol server to search path.
/// </summary>
- /// <param name="msdl">if true, use the public Microsoft server</param>
- /// <param name="symweb">if true, use symweb internal server and protocol (file.ptr)</param>
- /// <param name="symbolServerPath">symbol server url (optional)</param>
+ /// <param name="symbolServerPath">symbol server url (optional, uses <see cref="DefaultSymbolPath"/> if null)</param>
/// <param name="authToken">PAT for secure symbol server (optional)</param>
- /// <param name="timeoutInMinutes">symbol server timeout in minutes (optional uses <see cref="DefaultTimeout"/> if null)</param>
- /// <param name="retryCount">number of retries (optional uses <see cref="DefaultRetryCount"/> if null)</param>
+ /// <param name="timeoutInMinutes">symbol server timeout in minutes (optional, uses <see cref="DefaultTimeout"/> if null)</param>
+ /// <param name="retryCount">number of retries (optional, uses <see cref="DefaultRetryCount"/> if null)</param>
/// <returns>if false, failure</returns>
- bool AddSymbolServer(bool msdl, bool symweb, string symbolServerPath = null, string authToken = null, int? timeoutInMinutes = null, int? retryCount = null);
+ bool AddSymbolServer(string symbolServerPath = null, string authToken = null, int? timeoutInMinutes = null, int? retryCount = null);
/// <summary>
/// Add cache path to symbol search path
[Option(Name = "--ms", Aliases = new string[] { "-ms" }, Help = "Use the public Microsoft symbol server.")]
public bool MicrosoftSymbolServer { get; set; }
- [Option(Name = "--mi", Aliases = new string[] { "-mi" }, Help = "Use the internal symweb symbol server.")]
- public bool InternalSymbolServer { get; set; }
-
[Option(Name = "--disable", Aliases = new string[] { "-disable" }, Help = "Clear or disable symbol download support.")]
public bool Disable { get; set; }
public override void Invoke()
{
- if (MicrosoftSymbolServer && InternalSymbolServer)
- {
- throw new DiagnosticsException("Cannot have both -ms and -mi options");
- }
- if ((MicrosoftSymbolServer || InternalSymbolServer) && !string.IsNullOrEmpty(SymbolServerUrl))
+ if (MicrosoftSymbolServer && !string.IsNullOrEmpty(SymbolServerUrl))
{
- throw new DiagnosticsException("Cannot have -ms or -mi option and a symbol server path");
+ throw new DiagnosticsException("Cannot have -ms option and a symbol server path");
}
if (Disable)
{
{
SymbolService.Reset();
}
- if (MicrosoftSymbolServer || InternalSymbolServer || !string.IsNullOrEmpty(SymbolServerUrl))
+ if (MicrosoftSymbolServer || !string.IsNullOrEmpty(SymbolServerUrl))
{
if (string.IsNullOrEmpty(Cache))
{
Cache = SymbolService.DefaultSymbolCache;
}
- SymbolService.AddSymbolServer(MicrosoftSymbolServer, InternalSymbolServer, SymbolServerUrl, AccessToken, Timeout, RetryCount);
+ SymbolService.AddSymbolServer(SymbolServerUrl, AccessToken, Timeout, RetryCount);
}
if (!string.IsNullOrEmpty(Cache))
{
_serviceContainer.AddService<ISymbolService>(_symbolService);
// Automatically enable symbol server support
- _symbolService.AddSymbolServer(msdl: true, symweb: false, timeoutInMinutes: 6, retryCount: 5);
+ _symbolService.AddSymbolServer(timeoutInMinutes: 6, retryCount: 5);
_symbolService.AddCachePath(_symbolService.DefaultSymbolCache);
}
/// <summary>
/// The symbol store for the internal symweb symbol server that handles the "file.ptr" support.
/// </summary>
+ [Obsolete]
public sealed class SymwebHttpSymbolStore : HttpSymbolStore
{
/// <summary>
#region Symbol service delegates
- [UnmanagedFunctionPointer(CallingConvention.Winapi)]
- private delegate bool IsSymbolStoreEnabledDelegate(
- [In] IntPtr self);
-
- [UnmanagedFunctionPointer(CallingConvention.Winapi)]
- private delegate bool InitializeSymbolStoreDelegate(
- [In] IntPtr self,
- [In] bool msdl,
- [In] bool symweb,
- [In] string symbolServerPath,
- [In] string authToken,
- [In] int timeoutInMinutes,
- [In] string symbolCachePath,
- [In] string symbolDirectoryPath);
-
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
private delegate bool ParseSymbolPathDelegate(
[In] IntPtr self,
[In] string windowsSymbolPath);
- [UnmanagedFunctionPointer(CallingConvention.Winapi)]
- private delegate void DisplaySymbolStoreDelegate(
- [In] IntPtr self,
- [In] WriteLine writeLine);
-
- [UnmanagedFunctionPointer(CallingConvention.Winapi)]
- private delegate void DisableSymbolStoreDelegate(
- [In] IntPtr self);
-
- [UnmanagedFunctionPointer(CallingConvention.Winapi)]
- private delegate void LoadNativeSymbolsDelegate(
- [In] IntPtr self,
- [In] SymbolFileCallback callback,
- [In] IntPtr parameter,
- [In] RuntimeConfiguration config,
- [In] string moduleFilePath,
- [In] ulong address,
- [In] uint size);
-
- [UnmanagedFunctionPointer(CallingConvention.Winapi)]
- private delegate void LoadNativeSymbolsFromIndexDelegate(
- [In] IntPtr self,
- [In] SymbolFileCallback callback,
- [In] IntPtr parameter,
- [In] RuntimeConfiguration config,
- [In] string moduleFilePath,
- [In] bool specialKeys,
- [In] int moduleIndexSize,
- [In] IntPtr moduleIndex);
-
[UnmanagedFunctionPointer(CallingConvention.Winapi)]
private delegate IntPtr LoadSymbolsForModuleDelegate(
[In] IntPtr self,
contextService.SetCurrentTarget(target);
// Automatically enable symbol server support, default cache and search for symbols in the dump directory
- symbolService.AddSymbolServer(msdl: true, symweb: false, retryCount: 3);
+ symbolService.AddSymbolServer(retryCount: 3);
symbolService.AddCachePath(symbolService.DefaultSymbolCache);
symbolService.AddDirectoryPath(Path.GetDirectoryName(dump_path.FullName));
{
public Uri Uri;
public string PersonalAccessToken;
- public bool InternalSymwebServer;
}
private readonly List<string> InputFilePaths = new();
program.SymbolServers.Add(new ServerInfo { Uri = uri, PersonalAccessToken = null });
break;
- case "--internal-server":
- Uri.TryCreate("https://symweb/", UriKind.Absolute, out uri);
- program.SymbolServers.Add(new ServerInfo { Uri = uri, PersonalAccessToken = null, InternalSymwebServer = true });
- break;
-
case "--authenticated-server-path":
if (++i < args.Length)
{
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);
- }
+ store = new HttpSymbolStore(Tracer, store, server.Uri, server.PersonalAccessToken);
if (Timeout.HasValue && store is HttpSymbolStore http)
{
http.Timeout = Timeout.Value;
///
///Options:
/// --microsoft-symbol-server Add 'https://msdl.microsoft.com/download/symbols' symbol server path (default).
- /// --internal-server Add 'https://symweb' internal symbol server path.
/// --server-path <symbol server path> Add a http server path.
- /// --authenticated-server-path <pat> <server path> Add a http PAT authenticated s [rest of string was truncated]";.
+ /// --authenticated-server-path <pat> <server path> Add a http PAT authenticated server path.
+ /// --cache-directory <file cache directory> Add a cache directory.
+ /// --timeout <m [rest of string was truncated]";.
/// </summary>
internal static string UsageOptions {
get {
Options:
--microsoft-symbol-server Add 'https://msdl.microsoft.com/download/symbols' symbol server path (default).
- --internal-server Add 'https://symweb' internal symbol server path.
--server-path <symbol server path> Add a http server path.
--authenticated-server-path <pat> <server path> Add a http PAT authenticated server path.
--cache-directory <file cache directory> Add a cache directory.
<data name="WritingFilesToOutput" xml:space="preserve">
<value>Writing files to {0}</value>
</data>
-</root>
\ No newline at end of file
+</root>
Options:
--microsoft-symbol-server Add 'https://msdl.microsoft.com/download/symbols' symbol server path (default).
- --internal-server Add 'https://symweb' internal symbol server path.
--server-path <symbol server path> Add a http server path.
--authenticated-server-path <pat> <server path> Add a http PAT authenticated server path.
--cache-directory <file cache directory> Add a cache directory.
To download the symbol files for a specific assembly:
- dotnet-symbol --symbols --cache-directory c:\temp\symcache --server-path https://symweb --output c:\temp\symout System.Threading.dll
+ dotnet-symbol --symbols --cache-directory c:\temp\symcache --server-path https://msdl.microsoft.com/download/symbols --output c:\temp\symout System.Threading.dll
Downloads all the symbol files for the shared runtime:
if (_symbolService is null)
{
_symbolService = new SymbolService(this);
- _symbolService.AddSymbolServer(msdl: true, symweb: false, timeoutInMinutes: 6, retryCount: 5);
+ _symbolService.AddSymbolServer(timeoutInMinutes: 6, retryCount: 5);
_symbolService.AddCachePath(SymbolService.DefaultSymbolCache);
}
return _symbolService;
Assert.Equal(defaultPath, symbolService.FormatSymbolStores());
symbolService.DisableSymbolStore();
- Assert.True(symbolService.ParseSymbolPath($"srv*{localSymbolCache}*{SymbolService.SymwebSymbolServer}"));
- string testpath1 = $"Cache: {localSymbolCache} Server: {SymbolService.SymwebSymbolServer}";
+ Assert.True(symbolService.ParseSymbolPath($"srv*{localSymbolCache}*https://symweb/"));
+ string testpath1 = $"Cache: {localSymbolCache} Server: https://symweb/";
Assert.Equal(testpath1, symbolService.FormatSymbolStores());
symbolService.DisableSymbolStore();
{
using (Stream compareStream = File.OpenRead("TestBinaries/dir1/System.Threading.Thread.pdb"))
{
- await DownloadFile(downloadStream, compareStream, ms: true, mi: false, KeyTypeFlags.SymbolKey);
+ await DownloadFile(downloadStream, compareStream, flags: KeyTypeFlags.SymbolKey);
}
}
}
- [Fact]
- public async Task SymwebHttpSymbolStore()
- {
- using (FileStream downloadStream = File.OpenRead("TestBinaries/dir2/System.Threading.Thread.dll"))
- {
- await DownloadFile(downloadStream, downloadStream, ms: false, mi: true, KeyTypeFlags.IdentityKey);
- }
- }
-
- private async Task DownloadFile(FileStream downloadStream, Stream compareStream, bool ms, bool mi, KeyTypeFlags flags)
+ private async Task DownloadFile(FileStream downloadStream, Stream compareStream, KeyTypeFlags flags)
{
SymbolStoreFile file = new SymbolStoreFile(downloadStream, downloadStream.Name);
- SymbolStores.SymbolStore store = null;
- if (ms)
- {
- Uri.TryCreate("https://msdl.microsoft.com/download/symbols/", UriKind.Absolute, out Uri uri);
- store = new HttpSymbolStore(_tracer, store, uri);
- }
- if (mi)
- {
- Uri.TryCreate("https://symweb/", UriKind.Absolute, out Uri uri);
- store = new SymwebHttpSymbolStore(_tracer, store, uri);
- }
+
+ Uri.TryCreate("https://msdl.microsoft.com/download/symbols/", UriKind.Absolute, out Uri uri);
+ SymbolStores.SymbolStore store = new HttpSymbolStore(_tracer, backingStore: null, uri);
+
var generator = new FileKeyGenerator(_tracer, file);
IEnumerable<SymbolStoreKey> keys = generator.GetKeys(flags);