From: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Wed, 26 Jun 2024 23:49:48 +0000 (+0000) Subject: [main] Update dependencies from microsoft/clrmd (#4739) X-Git-Tag: accepted/tizen/unified/20241231.014852~39^2^2~165 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=24e70219872cf1f46c9e291bf110ee4baf9c9ba8;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git [main] Update dependencies from microsoft/clrmd (#4739) [main] Update dependencies from microsoft/clrmd - SOS changes for clrmd 4.0 Add -major host runtime version option --- diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 4657361ee..c899d723b 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,12 +1,12 @@ - + https://github.com/microsoft/clrmd - d5923fbec06fc227cde5e5a2d7ea58c02802e971 + 12a72becaf8e8c2254b3337b8c771c7a17b64cbb - + https://github.com/microsoft/clrmd - d5923fbec06fc227cde5e5a2d7ea58c02802e971 + 12a72becaf8e8c2254b3337b8c771c7a17b64cbb diff --git a/eng/Versions.props b/eng/Versions.props index d67327b9b..04649e324 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -30,11 +30,11 @@ - 5.0.0 - 6.0.0 + 8.0.0 + 8.0.0 6.0.0 - 3.1.525101 + 4.0.0-beta.24325.1 17.10.0-beta1.24272.1 3.0.7 6.0.0 diff --git a/src/SOS/Strike/sosdocs.txt b/src/SOS/Strike/sosdocs.txt index 0d424296b..889b88925 100644 --- a/src/SOS/Strike/sosdocs.txt +++ b/src/SOS/Strike/sosdocs.txt @@ -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 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 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. diff --git a/src/SOS/Strike/sosdocsunix.txt b/src/SOS/Strike/sosdocsunix.txt index d8cb6c211..2d62683ac 100644 --- a/src/SOS/Strike/sosdocsunix.txt +++ b/src/SOS/Strike/sosdocsunix.txt @@ -2249,26 +2249,27 @@ SetHostRuntime [-c][-netcore] [-none] [-clear] -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 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. diff --git a/src/SOS/Strike/strike.cpp b/src/SOS/Strike/strike.cpp index f1fd17b96..55e13a154 100644 --- a/src/SOS/Strike/strike.cpp +++ b/src/SOS/Strike/strike.cpp @@ -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 = ""; - 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); diff --git a/src/SOS/extensions/extensions.cpp b/src/SOS/extensions/extensions.cpp index 201580576..3c4b70fdf 100644 --- a/src/SOS/extensions/extensions.cpp +++ b/src/SOS/extensions/extensions.cpp @@ -234,6 +234,24 @@ bool GetAbsolutePath(const char* path, std::string& absolutePath) return false; } +/// +// Returns just the file name portion of a file path +/// +/// full path to get file name +/// just the file name +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); +} + /// /// Internal output helper function /// diff --git a/src/SOS/extensions/extensions.h b/src/SOS/extensions/extensions.h index 38eaff9d2..b24862655 100644 --- a/src/SOS/extensions/extensions.h +++ b/src/SOS/extensions/extensions.h @@ -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" { diff --git a/src/SOS/extensions/hostcoreclr.cpp b/src/SOS/extensions/hostcoreclr.cpp index 002ec7dc8..8d9619e63 100644 --- a/src/SOS/extensions/hostcoreclr.cpp +++ b/src/SOS/extensions/hostcoreclr.cpp @@ -44,6 +44,12 @@ #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; } /**********************************************************************\ diff --git a/src/SOS/lldbplugin/sethostruntimecommand.cpp b/src/SOS/lldbplugin/sethostruntimecommand.cpp index 309c46205..a6e3166d9 100644 --- a/src/SOS/lldbplugin/sethostruntimecommand.cpp +++ b/src/SOS/lldbplugin/sethostruntimecommand.cpp @@ -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 = ""; - 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(); }