<Dependencies>
<ProductDependencies>
- <Dependency Name="Microsoft.Diagnostics.Runtime" Version="3.1.525101">
+ <Dependency Name="Microsoft.Diagnostics.Runtime" Version="4.0.0-beta.24325.1">
<Uri>https://github.com/microsoft/clrmd</Uri>
- <Sha>d5923fbec06fc227cde5e5a2d7ea58c02802e971</Sha>
+ <Sha>12a72becaf8e8c2254b3337b8c771c7a17b64cbb</Sha>
</Dependency>
- <Dependency Name="Microsoft.Diagnostics.Runtime.Utilities" Version="3.1.525101">
+ <Dependency Name="Microsoft.Diagnostics.Runtime.Utilities" Version="4.0.0-beta.24325.1">
<Uri>https://github.com/microsoft/clrmd</Uri>
- <Sha>d5923fbec06fc227cde5e5a2d7ea58c02802e971</Sha>
+ <Sha>12a72becaf8e8c2254b3337b8c771c7a17b64cbb</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<!-- Uncomment this line to use the custom version of roslyn as needed. -->
<!-- <UsingToolMicrosoftNetCompilers Condition="'$(DotNetBuildSourceOnly)' != 'true'">true</UsingToolMicrosoftNetCompilers> -->
<!-- CoreFX -->
- <SystemReflectionMetadataVersion>5.0.0</SystemReflectionMetadataVersion>
- <SystemCollectionsImmutableVersion>6.0.0</SystemCollectionsImmutableVersion>
+ <SystemReflectionMetadataVersion>8.0.0</SystemReflectionMetadataVersion>
+ <SystemCollectionsImmutableVersion>8.0.0</SystemCollectionsImmutableVersion>
<!-- Other libs -->
<MicrosoftBclAsyncInterfacesVersion>6.0.0</MicrosoftBclAsyncInterfacesVersion>
- <MicrosoftDiagnosticsRuntimeVersion>3.1.525101</MicrosoftDiagnosticsRuntimeVersion>
+ <MicrosoftDiagnosticsRuntimeVersion>4.0.0-beta.24325.1</MicrosoftDiagnosticsRuntimeVersion>
<MicrosoftDiaSymReaderNativeVersion>17.10.0-beta1.24272.1</MicrosoftDiaSymReaderNativeVersion>
<MicrosoftDiagnosticsTracingTraceEventVersion>3.0.7</MicrosoftDiagnosticsTracingTraceEventVersion>
<MicrosoftExtensionsLoggingVersion>6.0.0</MicrosoftExtensionsLoggingVersion>
-c, -netcore - switch to hosting on the .NET Core runtime
-f, -netfx - switch to hosting on the desktop .NET Framework runtime if loaded.
-none - disable hosting managed code (for testing).
+-major - set the .NET Core's runtime version (used with the <runtime-directory> argument).
-clear - clear the .NET Core host runtime path.
-This command controls the runtime that is used to host the maanged code that
-runs as part of SOS in the debugger (cdb/windbg). The default is the desktop
-.NET Framework. The "-netcore" option allows the installed .NET Core runtime
-be used. The "-netfx" option allows switches back to the .NET Framework runtime.
+This command controls the runtime that is used to host the manged code that
+runs as part of SOS in the debugger (cdb/windbg). The default is the .NET Core
+runtime. The "-netfx" option allows the .NET Framework runtime to be used to
+host the managed SOS code. The "-netcore" option switches the installed .NET
+Core runtime.
If a <runtime-directory> is given, the command assumes it is a path to a .NET
-Core runtime which needs to be at least version 2.1.0 or greater. If there are
+Core runtime which needs to be at least version 6.0 or greater. If there are
spaces in directory, it needs to be single-quoted (').
Normally, SOS attempts to find an installed .NET Core runtime to run its
managed code automatically but this command is available if it fails. The
default is to use the same runtime (coreclr.dll) being debugged. Use this
command if the default runtime being debugged isn't working enough to run
-the SOS code or if the version is less than 2.1.0.
+the SOS code or if the version is less than 6.0.
If you received the following error message when running a SOS command, use
-this command to set the path to 2.0.0 or greater .NET Core runtime.
+this command to set the path to 6.0 or greater .NET Core runtime.
0:000> !clrstack
Error: Fail to initialize CoreCLR 80004005
ClrStack failed
- 0:000> sethostruntime "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.1.6"
+ 0:000> sethostruntime -major 6 "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.30"
You can use the "dotnet --info" in a command shell to find the path of an installed
.NET Core runtime.
-c, -netcore - switch to hosting on the .NET Core runtime
-none - disable hosting managed code (for testing).
-clear - clear the .NET Core host runtime path.
+-major - set the .NET Core's runtime version (used with the <runtime-directory> argument).
This command sets the path to the .NET Core runtime to use to host the managed
code that runs as part of SOS in the debugger (lldb). The runtime needs
-to be at least version 2.1.0 or greater. If there are spaces in directory, it
+to be at least version 6.0 or greater. If there are spaces in directory, it
needs to be single-quoted (').
Normally, SOS attempts to find an installed .NET Core runtime to run its
managed code automatically but this command is available if it fails. The
default is to use the same runtime (libcoreclr) being debugged. Use this
command if the default runtime being debugged isn't working enough to run
-the SOS code or if the version is less than 2.1.0.
+the SOS code or if the version is less than 6.0.
If you received the following error message when running a SOS command, use
-this command to set the path to 2.1.0 or greater .NET Core runtime.
+this command to set the path to 6.0 or greater .NET Core runtime.
(lldb) clrstack
Error: Fail to initialize CoreCLR 80004005
ClrStack failed
- (lldb) sethostruntime /usr/share/dotnet/shared/Microsoft.NETCore.App/2.1.6
+ (lldb) sethostruntime -major 6 /usr/share/dotnet/shared/Microsoft.NETCore.App/6.0.30
You can use the "dotnet --info" in a command shell to find the path of an installed
.NET Core runtime.
BOOL bNetCore = FALSE;
BOOL bNone = FALSE;
BOOL bClear = FALSE;
+ DWORD_PTR majorRuntimeVersion = 0;
CMDOption option[] =
{ // name, vptr, type, hasValue
{"-netfx", &bNetFx, COBOOL, FALSE},
{"-c", &bNetCore, COBOOL, FALSE},
{"-none", &bNone, COBOOL, FALSE},
{"-clear", &bClear, COBOOL, FALSE},
+ {"-major", &majorRuntimeVersion, COSIZE_T, TRUE},
};
StringHolder hostRuntimeDirectory;
CMDValue arg[] =
{
return E_INVALIDARG;
}
- if (narg > 0 || bNetCore || bNetFx || bNone)
+ HostRuntimeFlavor flavor = HostRuntimeFlavor::NetCore;
+ int major = 0, minor = 0;
+ if (narg > 0 || majorRuntimeVersion > 0 || bClear || bNetCore || bNetFx || bNone)
{
if (IsHostingInitialized())
{
ExtErr("Runtime hosting already initialized\n");
goto exit;
}
- }
- if (bClear)
- {
- SetHostRuntimeDirectory(nullptr);
- }
- else if (bNone)
- {
- SetHostRuntimeFlavor(HostRuntimeFlavor::None);
- }
- else if (bNetCore)
- {
- SetHostRuntimeFlavor(HostRuntimeFlavor::NetCore);
- }
- else if (bNetFx)
- {
- SetHostRuntimeFlavor(HostRuntimeFlavor::NetFx);
- }
- if (narg > 0)
- {
- if (!SetHostRuntimeDirectory(hostRuntimeDirectory.data))
+ if (bClear)
+ {
+ SetHostRuntime(HostRuntimeFlavor::NetCore, 0, 0, nullptr);
+ }
+ if (bNone)
+ {
+ flavor = HostRuntimeFlavor::None;
+ }
+ else if (bNetCore)
+ {
+ flavor = HostRuntimeFlavor::NetCore;
+ }
+ else if (bNetFx)
+ {
+ flavor = HostRuntimeFlavor::NetFx;
+ }
+ major = (int)majorRuntimeVersion;
+ if (!SetHostRuntime(flavor, major, minor, hostRuntimeDirectory.data))
{
ExtErr("Invalid host runtime path %s\n", hostRuntimeDirectory.data);
return E_FAIL;
}
}
exit:
- const char* flavor = "<unknown>";
- switch (GetHostRuntimeFlavor())
+ LPCSTR directory = nullptr;
+ GetHostRuntime(flavor, major, minor, directory);
+ switch (flavor)
{
case HostRuntimeFlavor::None:
- flavor = "no";
+ ExtOut("Using no runtime to host the managed SOS code\n");
break;
case HostRuntimeFlavor::NetCore:
- flavor = ".NET Core";
+ ExtOut("Using .NET Core runtime (version %d.%d) to host the managed SOS code\n", major, minor);
break;
case HostRuntimeFlavor::NetFx:
- flavor = "desktop .NET Framework";
+ ExtOut("Using desktop .NET Framework runtime to host the managed SOS code\n");
break;
default:
break;
}
- ExtOut("Using %s runtime to host the managed SOS code\n", flavor);
- const char* directory = GetHostRuntimeDirectory();
if (directory != nullptr)
{
ExtOut("Host runtime path: %s\n", directory);
return false;
}
+/// <summary>
+// Returns just the file name portion of a file path
+/// </summary>
+/// <param name="filePath">full path to get file name</param>
+/// <returns>just the file name</returns>
+const std::string
+GetFileName(const std::string& filePath)
+{
+ size_t last = filePath.rfind(DIRECTORY_SEPARATOR_STR_A);
+ if (last != std::string::npos) {
+ last++;
+ }
+ else {
+ last = 0;
+ }
+ return filePath.substr(last);
+}
+
/// <summary>
/// Internal output helper function
/// </summary>
extern BOOL IsHostingInitialized();
extern HRESULT InitializeHosting();
-extern LPCSTR GetHostRuntimeDirectory();
-extern bool SetHostRuntimeDirectory(LPCSTR hostRuntimeDirectory);
-extern HostRuntimeFlavor GetHostRuntimeFlavor();
-extern bool SetHostRuntimeFlavor(HostRuntimeFlavor flavor);
+extern bool SetHostRuntime(HostRuntimeFlavor flavor, int major, int minor, LPCSTR hostRuntimeDirectory);
+extern void GetHostRuntime(HostRuntimeFlavor& flavor, int& major, int& minor, LPCSTR& hostRuntimeDirectory);
extern bool GetAbsolutePath(const char* path, std::string& absolutePath);
+extern const std::string GetFileName(const std::string& filePath);
#ifdef __cplusplus
extern "C" {
#define DT_LNK 10
#endif
+struct RuntimeVersion
+{
+ uint32_t Major;
+ uint32_t Minor;
+};
+
#if !defined(FEATURE_PAL) && !defined(HOST_ARM64) && !defined(HOST_ARM)
extern HRESULT InitializeDesktopClrHost();
#endif
extern void TraceError(PCSTR format, ...);
-static HostRuntimeFlavor g_hostRuntimeFlavor = HostRuntimeFlavor::NetCore;
bool g_hostingInitialized = false;
+static HostRuntimeFlavor g_hostRuntimeFlavor = HostRuntimeFlavor::NetCore;
+static RuntimeVersion g_hostRuntimeVersion = { };
static LPCSTR g_hostRuntimeDirectory = nullptr;
static ExtensionsInitializeDelegate g_extensionsInitializeFunc = nullptr;
-struct RuntimeVersion
-{
- uint32_t Major;
- uint32_t Minor;
-};
-
namespace RuntimeHostingConstants
{
// This list is in probing order.
constexpr RuntimeVersion SupportedHostRuntimeVersions[] = {
+ {8, 0},
{7, 0},
{6, 0},
- {8, 0},
{9, 0},
};
// ...
// }
+ if (hostRuntimeVersion.Major > 0 && hostRuntimeVersion.Major < 8)
+ {
+ AddFileToTpaList(directory, "System.Collections.Immutable.dll", tpaList);
+ AddFileToTpaList(directory, "System.Reflection.Metadata.dll", tpaList);
+ }
+
// Trust the runtime assemblies that are newer than the ones needed and provided by SOS's managed
// components.
AddFilesFromDirectoryToTpaList(hostRuntimeDirectory.c_str(), tpaList);
return true;
}
-
return false;
}
// Save away the runtime version we are going to use to host the SOS managed code
g_hostRuntimeDirectory = _strdup(hostRuntimeDirectory.c_str());
+ g_hostRuntimeVersion = hostRuntimeVersion;
}
hostRuntimeDirectory.assign(g_hostRuntimeDirectory);
+ hostRuntimeVersion = g_hostRuntimeVersion;
+
coreClrPath.assign(g_hostRuntimeDirectory);
coreClrPath.append(DIRECTORY_SEPARATOR_STR_A);
coreClrPath.append(MAKEDLLNAME_A("coreclr"));
}
/**********************************************************************\
- * Gets the host runtime flavor
-\**********************************************************************/
-HostRuntimeFlavor GetHostRuntimeFlavor()
-{
- return g_hostRuntimeFlavor;
-}
-
-/**********************************************************************\
- * Sets the host runtime flavor
+ * Sets the host runtime info
\**********************************************************************/
-bool SetHostRuntimeFlavor(HostRuntimeFlavor flavor)
-{
- g_hostRuntimeFlavor = flavor;
- return true;
-}
-
-/**********************************************************************\
- * Sets the host runtime directory path
-\**********************************************************************/
-bool SetHostRuntimeDirectory(LPCSTR hostRuntimeDirectory)
+bool SetHostRuntime(HostRuntimeFlavor flavor, int major, int minor, LPCSTR hostRuntimeDirectory)
{
if (hostRuntimeDirectory != nullptr)
{
return false;
}
hostRuntimeDirectory = _strdup(fullPath.c_str());
+
+ // Try to get the runtime version from the host runtime directory
+ if (major == 0)
+ {
+ uint32_t majorVersion = 0;
+ uint32_t minorVersion = 0;
+ uint32_t revision = 0;
+ if (sscanf(GetFileName(fullPath).c_str(), "%d.%d.%d", &majorVersion, &minorVersion, &revision) == 3)
+ {
+ major = majorVersion;
+ minor = minorVersion;
+ }
+ }
}
if (g_hostRuntimeDirectory != nullptr)
{
free((void*)g_hostRuntimeDirectory);
}
+ g_hostRuntimeFlavor = flavor;
+ g_hostRuntimeVersion.Major = major;
+ g_hostRuntimeVersion.Minor = minor;
g_hostRuntimeDirectory = hostRuntimeDirectory;
- g_hostRuntimeFlavor = HostRuntimeFlavor::NetCore;
return true;
}
/**********************************************************************\
- * Gets the current host runtime directory path or null if not set
+ * Gets the current host runtime information
\**********************************************************************/
-LPCSTR GetHostRuntimeDirectory()
+void GetHostRuntime(HostRuntimeFlavor& flavor, int& major, int& minor, LPCSTR& hostRuntimeDirectory)
{
- return g_hostRuntimeDirectory;
+ flavor = g_hostRuntimeFlavor;
+ major = g_hostRuntimeVersion.Major;
+ minor = g_hostRuntimeVersion.Minor;
+ hostRuntimeDirectory = g_hostRuntimeDirectory;
}
/**********************************************************************\
char** arguments,
lldb::SBCommandReturnObject &result)
{
+ HostRuntimeFlavor flavor = HostRuntimeFlavor::NetCore;
+ LPCSTR hostRuntimeDirectory = nullptr;
+ int major = 0, minor = 0;
+
result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
if (arguments != nullptr && arguments[0] != nullptr)
}
else
{
- if (strcmp(arguments[0], "-none") == 0)
+ if (*arguments != nullptr && strcmp(*arguments, "-clear") == 0)
+ {
+ SetHostRuntime(HostRuntimeFlavor::NetCore, 0, 0, nullptr);
+ arguments++;
+ }
+ if (*arguments != nullptr && strcmp(*arguments, "-none") == 0)
+ {
+ flavor = HostRuntimeFlavor::None;
+ arguments++;
+ }
+ else if (*arguments != nullptr && strcmp(*arguments, "-netcore") == 0)
+ {
+ flavor = HostRuntimeFlavor::NetCore;
+ arguments++;
+ }
+ if (*arguments != nullptr && strcmp(*arguments, "-major") == 0)
{
- SetHostRuntimeFlavor(HostRuntimeFlavor::None);
+ arguments++;
+ if (*arguments != nullptr)
+ {
+ major = atoi(*arguments);
+ arguments++;
+ }
}
- else if (strcmp(arguments[0], "-netcore") == 0)
+ if (*arguments != nullptr)
{
- SetHostRuntimeFlavor(HostRuntimeFlavor::NetCore);
+ hostRuntimeDirectory = *arguments;
+ arguments++;
}
- else if (!SetHostRuntimeDirectory(arguments[0]))
+ if (!SetHostRuntime(flavor, major, minor, hostRuntimeDirectory))
{
- result.Printf("Invalid host runtime path: %s\n", arguments[0]);
+ result.Printf("Invalid host runtime path: %s\n", hostRuntimeDirectory);
result.SetStatus(lldb::eReturnStatusFailed);
return result.Succeeded();
}
}
}
- const char* flavor = "<unknown>";
- switch (GetHostRuntimeFlavor())
+ GetHostRuntime(flavor, major, minor, hostRuntimeDirectory);
+ switch (flavor)
{
case HostRuntimeFlavor::None:
- flavor = "no";
+ result.Printf("Using no runtime to host the managed SOS code\n");
break;
case HostRuntimeFlavor::NetCore:
- flavor = ".NET Core";
+ result.Printf("Using .NET Core runtime (version %d.%d) to host the managed SOS code\n", major, minor);
break;
default:
break;
}
- result.Printf("Using %s runtime to host the managed SOS code\n", flavor);
- const char* directory = GetHostRuntimeDirectory();
- if (directory != nullptr)
+ if (hostRuntimeDirectory != nullptr)
{
- result.Printf("Host runtime path: %s\n", directory);
+ result.Printf("Host runtime path: %s\n", hostRuntimeDirectory);
}
return result.Succeeded();
}