Skip to content

Commit

Permalink
Add -timeout option to SetSymbolServer command. Issue: #602
Browse files Browse the repository at this point in the history
  • Loading branch information
mikem8361 committed Dec 12, 2019
1 parent d9e53ba commit bcd3d8d
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 16 deletions.
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<MicrosoftWin32PrimitivesVersion>4.3.0</MicrosoftWin32PrimitivesVersion>
<!-- Other libs -->
<MicrosoftSymbolStoreVersion>1.0.55801</MicrosoftSymbolStoreVersion>
<MicrosoftDiagnosticsRuntimeVersion>1.1.46104</MicrosoftDiagnosticsRuntimeVersion>
<MicrosoftDiagnosticsRuntimeVersion>1.1.57004</MicrosoftDiagnosticsRuntimeVersion>
<MicrosoftDiaSymReaderNativePackageVersion>1.7.0</MicrosoftDiaSymReaderNativePackageVersion>
<MicrosoftDiagnosticsTracingTraceEventVersion>2.0.44</MicrosoftDiagnosticsTracingTraceEventVersion>
<SystemCommandLineExperimentalVersion>0.3.0-alpha.19602.1</SystemCommandLineExperimentalVersion>
Expand Down
1 change: 1 addition & 0 deletions src/SOS/SOS.Hosting/SOSHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private delegate bool InitializeSymbolStoreDelegate(
bool symweb,
string tempDirectory,
string symbolServerPath,
int timeoutInMintues,
string symbolCachePath,
string symbolDirectoryPath,
string windowsSymbolPath);
Expand Down
32 changes: 24 additions & 8 deletions src/SOS/SOS.NETCore/SymbolReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,25 @@ public override void Write(byte[] buffer, int offset, int count)
/// symbol servers. This API can be called more than once to add more servers to search.
/// </summary>
/// <param name="logging">if true, enable logging diagnostics to console</param>
/// <param name="msdl">if true, use the public microsoft server</param>
/// <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="tempDirectory">temp directory unique to this instance of SOS</param>
/// <param name="symbolServerPath">symbol server url (optional)</param>
/// <param name="timeoutInMinutes">symbol server timeout in minutes (optional)</param>
/// <param name="symbolCachePath">symbol cache directory path (optional)</param>
/// <param name="symbolDirectoryPath">symbol directory path to search (optional)</param>
/// <param name="windowsSymbolPath">windows symbol path (optional)</param>
/// <returns>if false, failure</returns>
public static bool InitializeSymbolStore(bool logging, bool msdl, bool symweb, string tempDirectory, string symbolServerPath, string symbolCachePath, string symbolDirectoryPath, string windowsSymbolPath)
public static bool InitializeSymbolStore(
bool logging,
bool msdl,
bool symweb,
string tempDirectory,
string symbolServerPath,
int timeoutInMinutes,
string symbolCachePath,
string symbolDirectoryPath,
string windowsSymbolPath)
{
if (logging) {
// Uses the standard console to do the logging instead of sending it to the hosting debugger console
Expand Down Expand Up @@ -209,7 +219,7 @@ public static bool InitializeSymbolStore(bool logging, bool msdl, bool symweb, s
}
}
// Build the symbol stores using the other parameters
if (!GetServerSymbolStore(ref store, msdl, symweb, symbolServerPath, symbolCachePath, symbolDirectoryPath)) {
if (!GetServerSymbolStore(ref store, msdl, symweb, symbolServerPath, timeoutInMinutes, symbolCachePath, symbolDirectoryPath)) {
return false;
}
}
Expand Down Expand Up @@ -1075,7 +1085,7 @@ private static bool ParseSymbolPath(ref SymbolStore store, string symbolPath)
}

// Add the symbol stores to the chain
if (!GetServerSymbolStore(ref store, msdl, false, symbolServerPath, symbolCachePath, symbolDirectoryPath))
if (!GetServerSymbolStore(ref store, msdl, false, symbolServerPath, 0, symbolCachePath, symbolDirectoryPath))
{
return false;
}
Expand All @@ -1085,7 +1095,7 @@ private static bool ParseSymbolPath(ref SymbolStore store, string symbolPath)
return true;
}

private static bool GetServerSymbolStore(ref SymbolStore store, bool msdl, bool symweb, string symbolServerPath, string symbolCachePath, string symbolDirectoryPath)
private static bool GetServerSymbolStore(ref SymbolStore store, bool msdl, bool symweb, string symbolServerPath, int timeoutInMinutes, string symbolCachePath, string symbolDirectoryPath)
{
bool internalServer = false;

Expand Down Expand Up @@ -1125,15 +1135,21 @@ private static bool GetServerSymbolStore(ref SymbolStore store, bool msdl, bool
{
if (!IsDuplicateSymbolStore<HttpSymbolStore>(store, (httpSymbolStore) => uri.Equals(httpSymbolStore.Uri)))
{
// Create symbol server store
// Create http symbol server store
HttpSymbolStore httpSymbolStore;
if (internalServer)
{
store = new SymwebHttpSymbolStore(s_tracer, store, uri);
httpSymbolStore = new SymwebHttpSymbolStore(s_tracer, store, uri);
}
else
{
store = new HttpSymbolStore(s_tracer, store, uri);
httpSymbolStore = new HttpSymbolStore(s_tracer, store, uri);
}
if (timeoutInMinutes != 0)
{
httpSymbolStore.Timeout = TimeSpan.FromMinutes(timeoutInMinutes);
}
store = httpSymbolStore;
}
}
}
Expand Down
14 changes: 11 additions & 3 deletions src/SOS/Strike/hostcoreclr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,13 +766,21 @@ static int ReadMemoryForSymbols(ULONG64 address, uint8_t *buffer, int cb)
/**********************************************************************\
* Setup and initialize the symbol server support.
\**********************************************************************/
HRESULT InitializeSymbolStore(BOOL logging, BOOL msdl, BOOL symweb, const char* symbolServer, const char* cacheDirectory, const char* searchDirectory, const char* windowsSymbolPath)
HRESULT InitializeSymbolStore(
BOOL logging,
BOOL msdl,
BOOL symweb,
const char* symbolServer,
int timeoutInMinutes,
const char* cacheDirectory,
const char* searchDirectory,
const char* windowsSymbolPath)
{
HRESULT Status = S_OK;
IfFailRet(InitializeHosting());
_ASSERTE(g_SOSNetCoreCallbacks.InitializeSymbolStoreDelegate != nullptr);

if (!g_SOSNetCoreCallbacks.InitializeSymbolStoreDelegate(logging, msdl, symweb, GetTempDirectory(), symbolServer, cacheDirectory, searchDirectory, windowsSymbolPath))
if (!g_SOSNetCoreCallbacks.InitializeSymbolStoreDelegate(logging, msdl, symweb, GetTempDirectory(), symbolServer, timeoutInMinutes, cacheDirectory, searchDirectory, windowsSymbolPath))
{
ExtErr("Error initializing symbol server support\n");
return E_FAIL;
Expand Down Expand Up @@ -815,7 +823,7 @@ void InitializeSymbolStoreFromSymPath()
{
if (strlen(symbolPath) > 0)
{
if (!g_SOSNetCoreCallbacks.InitializeSymbolStoreDelegate(false, false, false, GetTempDirectory(), nullptr, nullptr, nullptr, symbolPath))
if (!g_SOSNetCoreCallbacks.InitializeSymbolStoreDelegate(false, false, false, GetTempDirectory(), nullptr, 0, nullptr, nullptr, symbolPath))
{
ExtErr("Windows symbol path parsing FAILED\n");
return;
Expand Down
15 changes: 13 additions & 2 deletions src/SOS/Strike/hostcoreclr.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ typedef void (*WriteLineDelegate)(const char*);
typedef int (*ReadMemoryDelegate)(ULONG64, uint8_t*, int);
typedef void (*SymbolFileCallbackDelegate)(void*, const char* moduleFileName, const char* symbolFilePath);

typedef BOOL (*InitializeSymbolStoreDelegate)(BOOL, BOOL, BOOL, const char*, const char*, const char*, const char*, const char*);
typedef BOOL (*InitializeSymbolStoreDelegate)(BOOL, BOOL, BOOL, const char*, const char*, int, const char*, const char*, const char*);
typedef void (*DisplaySymbolStoreDelegate)(WriteLineDelegate);
typedef void (*DisableSymbolStoreDelegate)();
typedef void (*LoadNativeSymbolsDelegate)(SymbolFileCallbackDelegate, void*, const char*, ULONG64, int, ReadMemoryDelegate);
Expand Down Expand Up @@ -71,10 +71,21 @@ extern LPCSTR GetDacFilePath();
extern LPCSTR GetDbiFilePath();
extern BOOL IsHostingInitialized();
extern HRESULT InitializeHosting();
extern HRESULT InitializeSymbolStore(BOOL logging, BOOL msdl, BOOL symweb, const char* symbolServer, const char* cacheDirectory, const char* searchDirectory, const char* windowsSymbolPath);

extern HRESULT InitializeSymbolStore(
BOOL logging,
BOOL msdl,
BOOL symweb,
const char* symbolServer,
int timeoutInMinutes,
const char* cacheDirectory,
const char* searchDirectory,
const char* windowsSymbolPath);

#ifndef FEATURE_PAL
extern void InitializeSymbolStoreFromSymPath();
#endif

extern HRESULT LoadNativeSymbols(bool runtimeOnly = false);
extern void DisplaySymbolStore();
extern void DisableSymbolStore();
Expand Down
4 changes: 3 additions & 1 deletion src/SOS/Strike/strike.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15906,6 +15906,7 @@ DECLARE_API(SetSymbolServer)
StringHolder symbolCache;
StringHolder searchDirectory;
StringHolder windowsSymbolPath;
size_t timeoutInMinutes = 0;
BOOL disable = FALSE;
BOOL loadNative = FALSE;
BOOL msdl = FALSE;
Expand All @@ -15916,6 +15917,7 @@ DECLARE_API(SetSymbolServer)
{"-disable", &disable, COBOOL, FALSE},
{"-cache", &symbolCache.data, COSTRING, TRUE},
{"-directory", &searchDirectory.data, COSTRING, TRUE},
{"-timeout", &timeoutInMinutes, COSIZE_T, TRUE},
{"-ms", &msdl, COBOOL, FALSE},
{"-log", &logging, COBOOL, FALSE},
{"-loadsymbols", &loadNative, COBOOL, FALSE},
Expand Down Expand Up @@ -15954,7 +15956,7 @@ DECLARE_API(SetSymbolServer)

if (msdl || symweb || symbolServer.data != nullptr || symbolCache.data != nullptr || searchDirectory.data != nullptr || windowsSymbolPath.data != nullptr)
{
Status = InitializeSymbolStore(logging, msdl, symweb, symbolServer.data, symbolCache.data, searchDirectory.data, windowsSymbolPath.data);
Status = InitializeSymbolStore(logging, msdl, symweb, symbolServer.data, (int)timeoutInMinutes, symbolCache.data, searchDirectory.data, windowsSymbolPath.data);
if (FAILED(Status))
{
return Status;
Expand Down
11 changes: 10 additions & 1 deletion src/Tools/dotnet-dump/Analyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,16 @@ public async Task<int> Analyze(FileInfo dump_path, string[] command)
AddServices(target);

// Automatically enable symbol server support
SymbolReader.InitializeSymbolStore(logging: false, msdl: true, symweb: false, tempDirectory: null, symbolServerPath: null, symbolCachePath: null, symbolDirectoryPath: null, windowsSymbolPath: null);
SymbolReader.InitializeSymbolStore(
logging: false,
msdl: true,
symweb: false,
tempDirectory: null,
symbolServerPath: null,
timeoutInMinutes: 0,
symbolCachePath: null,
symbolDirectoryPath: null,
windowsSymbolPath: null);

// Run the commands from the dotnet-dump command line
if (command != null)
Expand Down

0 comments on commit bcd3d8d

Please sign in to comment.