[main] Update dependencies from microsoft/clrmd (#4739)
authordotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com>
Wed, 26 Jun 2024 23:49:48 +0000 (23:49 +0000)
committerGitHub <noreply@github.com>
Wed, 26 Jun 2024 23:49:48 +0000 (23:49 +0000)
[main] Update dependencies from microsoft/clrmd

 - SOS changes for clrmd 4.0

Add -major host runtime version option

eng/Version.Details.xml
eng/Versions.props
src/SOS/Strike/sosdocs.txt
src/SOS/Strike/sosdocsunix.txt
src/SOS/Strike/strike.cpp
src/SOS/extensions/extensions.cpp
src/SOS/extensions/extensions.h
src/SOS/extensions/hostcoreclr.cpp
src/SOS/lldbplugin/sethostruntimecommand.cpp

index 4657361ee463ee74549a37babe97363b2fe287e4..c899d723becd9807cfc79f0dcb1b5610e1614035 100644 (file)
@@ -1,12 +1,12 @@
 <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>
index d67327b9b7bed1d9f22da54418e32547d88482ea..04649e324116cce5077f032c31528d4df3d07b21 100644 (file)
     <!-- 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>
index 0d424296be6f38688d9ccae93d7410ea68b59836..889b88925e6236362c67236ff0b5160228371af5 100644 (file)
@@ -2614,31 +2614,33 @@ COMMAND: sethostruntime.
 -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.
index d8cb6c21162752196f2f6882460350fc733e3707..2d62683ac8f666270836bbfcde91258461964858 100644 (file)
@@ -2249,26 +2249,27 @@ SetHostRuntime [-c][-netcore] [-none] [-clear] <runtime-directory>
 -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.
index f1fd17b96347416bd29ba2bfce7f1c8a115e8838..55e13a15491ec832ac1c0e81448c9fa8fcde13a9 100644 (file)
@@ -13438,6 +13438,7 @@ DECLARE_API(SetHostRuntime)
     BOOL bNetCore = FALSE;
     BOOL bNone = FALSE;
     BOOL bClear = FALSE;
+    DWORD_PTR majorRuntimeVersion = 0;
     CMDOption option[] =
     {   // name, vptr, type, hasValue
         {"-netfx", &bNetFx, COBOOL, FALSE},
@@ -13446,6 +13447,7 @@ DECLARE_API(SetHostRuntime)
         {"-c", &bNetCore, COBOOL, FALSE},
         {"-none", &bNone, COBOOL, FALSE},
         {"-clear", &bClear, COBOOL, FALSE},
+        {"-major", &majorRuntimeVersion, COSIZE_T, TRUE},
     };
     StringHolder hostRuntimeDirectory;
     CMDValue arg[] =
@@ -13457,56 +13459,55 @@ DECLARE_API(SetHostRuntime)
     {
         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);
index 2015805765e69a637a3587d43eaa35c3d2f7eff7..3c4b70fdff1549bbd163e462ee1e11f978f8df2a 100644 (file)
@@ -234,6 +234,24 @@ bool GetAbsolutePath(const char* path, std::string& absolutePath)
     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>
index 38eaff9d21fe6eb6e3372c915580775ef728ce5c..b24862655ac790ec78bb6999ed3683fd61596464 100644 (file)
@@ -21,11 +21,10 @@ enum HostRuntimeFlavor
 
 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" {
index 002ec7dc832596c411a3862309b0b826549efa9d..8d9619e63710499f9030c3d27460e0ee5c9337e8 100644 (file)
 #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
@@ -54,24 +60,19 @@ extern HMODULE g_hInstance;
 
 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},
     };
 
@@ -333,6 +334,12 @@ static std::string GetTpaListForRuntimeVersion(
     //               ...
     //           }
 
+    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);
@@ -379,7 +386,6 @@ static bool FindDotNetVersion(const RuntimeVersion& runtimeVersion, std::string&
         return true;
     }
 
-
     return false;
 }
 
@@ -527,8 +533,11 @@ static HRESULT GetHostRuntime(std::string& coreClrPath, std::string& hostRuntime
 
         // 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"));
@@ -680,26 +689,9 @@ static HRESULT InitializeNetCoreHost()
 }
 
 /**********************************************************************\
- * 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)
     {
@@ -709,22 +701,40 @@ bool SetHostRuntimeDirectory(LPCSTR hostRuntimeDirectory)
             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;
 }
 
 /**********************************************************************\
index 309c462050ff73703b0c5932239b2ffbe2558463..a6e3166d955f49740e0992522c916476923b8900 100644 (file)
@@ -20,6 +20,10 @@ public:
                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)
@@ -32,39 +36,58 @@ public:
             }
             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();
     }