<MicrosoftAspNetCoreApp30Version>$(MicrosoftNETCoreApp30Version)</MicrosoftAspNetCoreApp30Version>
<MicrosoftNETCoreApp31Version>3.1.0</MicrosoftNETCoreApp31Version>
<MicrosoftAspNetCoreApp31Version>$(MicrosoftNETCoreApp31Version)</MicrosoftAspNetCoreApp31Version>
- <MicrosoftNETCoreAppVersion>5.0.0-alpha.1.19627.5</MicrosoftNETCoreAppVersion>
- <MicrosoftAspNetCoreAppRefVersion>5.0.0-alpha.1.19614.22</MicrosoftAspNetCoreAppRefVersion>
+ <MicrosoftNETCoreAppVersion>5.0.0-alpha.1.19562.8</MicrosoftNETCoreAppVersion>
+ <MicrosoftAspNetCoreAppRefVersion>5.0.0-alpha.1.19626.3</MicrosoftAspNetCoreAppRefVersion>
</PropertyGroup>
<PropertyGroup>
<!-- Opt-in/out repo features -->
public TargetStream(ulong address, int size, ReadMemoryDelegate readMemory)
: base()
{
+ Debug.Assert(address != 0);
+ Debug.Assert(size != 0);
_address = address;
_readMemory = readMemory;
Length = size;
s_tracer.Verbose("{0} {1}", key.FullPathName, key.Index);
// Don't download the sos binaries that come with the runtime
- if (moduleFileName != "SOS.NETCore.dll" && !moduleFileName.StartsWith("libsos."))
+ if (!IsPathEqual(moduleFileName, "SOS.NETCore.dll") &&
+ !IsPathEqual(moduleFileName, "sos.dll") &&
+ !moduleFileName.StartsWith("libsos."))
{
string downloadFilePath = GetSymbolFile(key);
if (downloadFilePath != null)
}
try
{
- await RunSosCommand("sosstatus");
+ await RunSosCommand("SOSStatus");
}
catch (Exception ex)
{
- WriteLine("Exception executing sosstatus {0}", ex.ToString());
+ WriteLine("Exception executing SOSStatus {0}", ex.ToString());
}
throw;
}
Task<CommandResult> currentTask = null;
lock (this)
{
+ if (_taskQueue.Count == 0)
+ {
+ return false;
+ }
currentTask = _taskQueue[0];
_taskQueue.RemoveAt(0);
}
Task<CommandResult> currentTask = null;
lock (this)
{
+ Debug.Assert(_taskQueue.Count > 0);
currentTask = _taskQueue[0];
}
return currentTask;
#define VER_PRODUCTVERSION_W (0x0100)
-extern void SOSShutdown();
-
//
// globals
//
WINDBG_EXTENSION_APIS ExtensionApis;
-OnUnloadTask *OnUnloadTask::s_pUnloadTaskList = NULL;
-
//
// Valid for the lifetime of the debug session.
//
#endif // FEATURE_PAL
+OnUnloadTask *OnUnloadTask::s_pUnloadTaskList = NULL;
+
IMachine* g_targetMachine = NULL;
BOOL g_bDacBroken = FALSE;
extern "C" HRESULT
ExtQuery(PDEBUG_CLIENT client)
{
+ HRESULT Status;
g_ExtClient = client;
#else
extern "C" HRESULT
g_palInitialized = true;
}
g_ExtServices = services;
- services->QueryInterface(__uuidof(ILLDBServices2), (void**)&g_ExtServices2);
+ HRESULT Status = services->QueryInterface(__uuidof(ILLDBServices2), (void**)&g_ExtServices2);
+ if (FAILED(Status))
+ {
+ g_ExtServices = NULL;
+ return Status;
+ }
DebugClient* client = new DebugClient(services, g_ExtServices2);
g_DebugClient = client;
#endif
- HRESULT Status;
SOS_ExtQueryFailGo(g_ExtControl, IDebugControl2);
SOS_ExtQueryFailGo(g_ExtData, IDebugDataSpaces);
SOS_ExtQueryFailGo(g_ExtRegisters, IDebugRegisters);
ExtRelease();
OnUnloadTask::Register(CleanupEventCallbacks);
- OnUnloadTask::Register(SOSShutdown);
g_pCallbacksClient = DebugClient;
EventCallbacks* pCallbacksObj = new EventCallbacks(DebugClient);
IDebugEventCallbacks* pCallbacks = NULL;
CALLBACK
DebugExtensionNotify(ULONG Notify, ULONG64 /*Argument*/)
{
- return;
}
extern "C"
CALLBACK
DebugExtensionUninitialize(void)
{
- // execute all registered cleanup tasks
+ // Execute all registered cleanup tasks
OnUnloadTask::Run();
- return;
}
-BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
+BOOL WINAPI
+DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
#else // FEATURE_PAL
+__attribute__((destructor))
+void
+Uninitialize(void)
+{
+ // Execute all registered cleanup tasks
+ OnUnloadTask::Run();
+}
+
HRESULT
DebugClient::QueryInterface(
REFIID InterfaceId,
{
if (!ControlC && g_ExtControl->GetInterrupt() == S_OK)
{
- ExtOut("Command cancelled at the user's request.\n");
+ ExtOut("Command canceled at the user's request.\n");
ControlC = TRUE;
}
return S_OK;
}
-//
-// Returns the unique temporary directory for this instnace of SOS
-//
-static LPCSTR GetTempDirectory()
+/**********************************************************************\
+ * Returns the unique temporary directory for this instance of SOS
+\**********************************************************************/
+LPCSTR GetTempDirectory()
{
if (g_tmpPath == nullptr)
{
CreateDirectoryA(tmpPath, NULL);
g_tmpPath = _strdup(tmpPath);
+ OnUnloadTask::Register(CleanupTempDirectory);
}
return g_tmpPath;
}
/**********************************************************************\
* Clean up the temporary directory files and DAC symlink.
\**********************************************************************/
-#ifdef FEATURE_PAL
-__attribute__((destructor))
-#endif
-void SOSShutdown()
+void CleanupTempDirectory()
{
LPCSTR tmpPath = (LPCSTR)InterlockedExchangePointer((PVOID *)&g_tmpPath, nullptr);
if (tmpPath != nullptr)
IfFailRet(InitializeHosting());
_ASSERTE(g_SOSNetCoreCallbacks.InitializeSymbolStoreDelegate != nullptr);
- if (!g_SOSNetCoreCallbacks.InitializeSymbolStoreDelegate(logging, msdl, symweb, GetTempDirectory(), symbolServer, timeoutInMinutes, 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;
{
if (strlen(symbolPath) > 0)
{
- if (!g_SOSNetCoreCallbacks.InitializeSymbolStoreDelegate(false, false, false, GetTempDirectory(), nullptr, 0, nullptr, nullptr, symbolPath))
+ if (!g_SOSNetCoreCallbacks.InitializeSymbolStoreDelegate(
+ false, // logging
+ false, // msdl
+ false, // symweb
+ GetTempDirectory(), // tempDirectory
+ nullptr, // symbolServerPath
+ 0, // timeoutInMinutes
+ nullptr, // symbolCachePath
+ nullptr, // symbolDirectoryPath
+ symbolPath)) // windowsSymbolPath
{
ExtErr("Windows symbol path parsing FAILED\n");
return;
ExtOut("LoadSymbols moduleData.Request FAILED 0x%08x\n", hr);
return hr;
#else
- ULONG64 modBase;
- hr = GetClrModuleImages(pModule, CLRDATA_MODULE_PE_FILE, &modBase);
+ ULONG64 moduleBase;
+ ULONG64 moduleSize;
+ hr = GetClrModuleImages(pModule, CLRDATA_MODULE_PE_FILE, &moduleBase, &moduleSize);
if (FAILED(hr))
{
ExtOut("LoadSymbols GetClrModuleImages FAILED 0x%08x\n", hr);
return hr;
}
- hr = LoadSymbolsForWindowsPDB(pMD, modBase, pModuleName, FALSE);
+ hr = LoadSymbolsForWindowsPDB(pMD, moduleBase, pModuleName, FALSE);
if (SUCCEEDED(hr))
{
return hr;
}
- moduleData.LoadedPEAddress = modBase;
+ moduleData.LoadedPEAddress = moduleBase;
+ moduleData.LoadedPESize = moduleSize;
moduleData.IsFileLayout = TRUE;
#endif
}
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*, int, const char*, const char*, const char*);
+typedef BOOL (*InitializeSymbolStoreDelegate)(
+ BOOL logging,
+ BOOL msdl,
+ BOOL symweb,
+ const char* tempDirectory,
+ const char* symbolServerPath,
+ int timeoutInMinutes,
+ const char* symbolCacehPath,
+ const char* symbolDirectoryPath,
+ const char* windowsSymbolPath);
+
typedef void (*DisplaySymbolStoreDelegate)(WriteLineDelegate);
typedef void (*DisableSymbolStoreDelegate)();
typedef void (*LoadNativeSymbolsDelegate)(SymbolFileCallbackDelegate, void*, const char*, ULONG64, int, ReadMemoryDelegate);
extern HRESULT GetRuntimeDirectory(LPWSTR modulePath, int modulePathSize);
extern LPCSTR GetDacFilePath();
extern LPCSTR GetDbiFilePath();
+extern LPCSTR GetTempDirectory();
+extern void CleanupTempDirectory();
extern BOOL IsHostingInitialized();
extern HRESULT InitializeHosting();
inline void CheckInterrupt()
{
if (g_ExtControl->GetInterrupt() == S_OK)
- Throw<Exception>("User interrupt.");
+ Throw<Exception>("Command canceled at the user's request.");
}
/* ThinLock struct. Use Object::GetThinLock to fill the struct.
* instance passed in, and the extent type requested. *
* *
\**********************************************************************/
-HRESULT GetClrModuleImages(__in IXCLRDataModule* module, __in CLRDataModuleExtentType desiredType, __out PULONG64 firstAdd)
+HRESULT GetClrModuleImages(__in IXCLRDataModule* module, __in CLRDataModuleExtentType desiredType, __out PULONG64 pBase, __out PULONG64 pSize)
{
CLRDATA_ENUM enumExtents;
HRESULT hr;
- _ASSERTE(firstAdd != nullptr);
- *firstAdd = 0;
+ _ASSERTE(pBase != nullptr);
+ _ASSERTE(pSize != nullptr);
+ *pBase = 0;
+ *pSize = 0;
if (FAILED(hr = module->StartEnumExtents(&enumExtents)))
{
{
if ((desiredType == CLRDATA_MODULE_OTHER) || (desiredType == extent.type))
{
- ULONG64 modBase;
- if (FAILED(hr = g_ExtSymbols->GetModuleByOffset(extent.base, 0, nullptr, &modBase)))
+ ULONG64 moduleBase;
+ if (FAILED(hr = g_ExtSymbols->GetModuleByOffset(extent.base, 0, nullptr, &moduleBase)))
+ {
+ if (desiredType == CLRDATA_MODULE_PE_FILE)
+ {
+ *pBase = extent.base;
+ *pSize = extent.length;
+ hr = S_OK;
+ }
+ break;
+ }
+ DEBUG_MODULE_PARAMETERS params;
+ if (FAILED(hr = g_ExtSymbols->GetModuleParameters(1, &moduleBase, 0, ¶ms)))
{
break;
}
- *firstAdd = modBase;
+ *pBase = moduleBase;
+ *pSize = params.Size;
hr = S_OK;
break;
}
#ifdef FEATURE_PAL
return hr;
#else
- hr = GetClrModuleImages(module, CLRDATA_MODULE_PE_FILE, &moduleData.LoadedPEAddress);
+ hr = GetClrModuleImages(module, CLRDATA_MODULE_PE_FILE, &moduleData.LoadedPEAddress, &moduleData.LoadedPESize);
if (FAILED(hr))
{
return hr;
};
#ifndef FEATURE_PAL
-HRESULT GetClrModuleImages(__in IXCLRDataModule* module, __in CLRDataModuleExtentType desiredType, __out PULONG64 firstAdd);
+HRESULT GetClrModuleImages(__in IXCLRDataModule* module, __in CLRDataModuleExtentType desiredType, __out PULONG64 pBase, __out PULONG64 pSize);
#endif
HRESULT GetMethodDefinitionsFromName(DWORD_PTR ModulePtr, IXCLRDataModule* mod, const char* name, IXCLRDataMethodDefinition **ppMethodDefinitions, int numMethods, int *numMethodsNeeded);
HRESULT GetMethodDescsFromName(DWORD_PTR ModulePtr, IXCLRDataModule* mod, const char* name, DWORD_PTR **pOut, int *numMethodDescs);
m_lldbservices2(lldbservices2)
{
m_lldbservices->AddRef();
- if (m_lldbservices2 != nullptr) {
- m_lldbservices2->AddRef();
- }
+ m_lldbservices2->AddRef();
}
//----------------------------------------------------------------------------
ULONG bufferSize,
PULONG versionInfoSize)
{
- if (m_lldbservices2 == nullptr) {
- return E_NOINTERFACE;
- }
return m_lldbservices2->GetModuleVersionInformation(index, base, item, buffer, bufferSize, versionInfoSize);
}
size += section.GetByteSize();
}
}
-
- return size;
+ // For core dumps lldb doesn't return the section sizes when it
+ // doesn't have access to the actual module file, but SOS (like
+ // the SymbolReader code) still needs a non-zero module size.
+ return size != 0 ? size : LONG_MAX;
}
//----------------------------------------------------------------------------
interpreter.AddCommand("sympath", new sosCommand("SetSymbolServer", "-sympath"), "Add server, cache and directory paths in the Windows symbol path format.");
interpreter.AddCommand("soshelp", new sosCommand("Help"), "Displays all available commands when no parameter is specified, or displays detailed help information about the specified command. soshelp <command>");
interpreter.AddCommand("sosstatus", new sosCommand("SOSStatus"), "Displays the global SOS status.");
+ interpreter.AddCommand("sosflush", new sosCommand("SOSFlush"), "Flushes the DAC caches.");
return true;
}