From ac9b0dcac13670a25028d1da34372fb6c131068d Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Tue, 22 Nov 2022 14:47:48 -0800 Subject: [PATCH] Add the ALC to `DumpMT` (#3508) * Add the ALC to DumpMT * Update to use DML for ALC * Reduce change for testing * Reduce change for testing * Bring back QI for ISOSDacInterface8 * Acquire ALC * Revert back to original fix * Disable dumpmt for 7.0 * Check for at least .NET 7 * Don't leave a failure status code. Co-authored-by: Juan Sebastian Hoyos Ayala --- .../Scripts/OtherCommands.script | 3 ++ src/SOS/Strike/strike.cpp | 28 +++++++++++++++---- src/SOS/Strike/util.cpp | 15 +++------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/SOS/SOS.UnitTests/Scripts/OtherCommands.script b/src/SOS/SOS.UnitTests/Scripts/OtherCommands.script index f90ca8f5b0..0b0ef66ef5 100644 --- a/src/SOS/SOS.UnitTests/Scripts/OtherCommands.script +++ b/src/SOS/SOS.UnitTests/Scripts/OtherCommands.script @@ -114,9 +114,12 @@ VERIFY:\s*Class Name:\s+SymbolTestApp.Program\s+ VERIFY:\s*File:\s+.*SymbolTestApp\.(dll|exe)\s+ # Verify DumpMT +!IFDEF:MAJOR_RUNTIME_VERSION_GE_7 +# https://github.com/dotnet/diagnostics/issues/3516 SOSCOMMAND:DumpMT \s*Method Table:\s+()\s+ VERIFY:\s*Name:\s+SymbolTestApp.Program\s+ VERIFY:\s*File:\s+.*SymbolTestApp\.(dll|exe)\s+ +ENDIF:MAJOR_RUNTIME_VERSION_GE_7 SOSCOMMAND:FinalizeQueue VERIFY:\s*SyncBlocks to be cleaned up:\s+\s+ diff --git a/src/SOS/Strike/strike.cpp b/src/SOS/Strike/strike.cpp index 268e5508d5..0b97c1559f 100644 --- a/src/SOS/Strike/strike.cpp +++ b/src/SOS/Strike/strike.cpp @@ -1276,7 +1276,7 @@ DECLARE_API(DumpMT) } EnableDMLHolder dmlHolder(dml); - TableOutput table(2, 16, AlignLeft, false); + TableOutput table(2, 20, AlignLeft, false); if (nArg == 0) { @@ -1326,6 +1326,24 @@ DECLARE_API(DumpMT) } } + ReleaseHolder sos8; + if (SUCCEEDED(g_sos->QueryInterface(__uuidof(ISOSDacInterface8), &sos8))) + { + CLRDATA_ADDRESS assemblyLoadContext = 0; + if (SUCCEEDED(sos8->GetAssemblyLoadContext(TO_CDADDR(dwStartAddr), &assemblyLoadContext))) + { + const char* title = "AssemblyLoadContext:"; + if (assemblyLoadContext != 0) + { + table.WriteRow(title, ObjectPtr(assemblyLoadContext)); + } + else + { + table.WriteRow(title, "Default ALC - The managed instance of this context doesn't exist yet."); + } + } + } + table.WriteRow("BaseSize:", PrefixHex(vMethTable.BaseSize)); table.WriteRow("ComponentSize:", PrefixHex(vMethTable.ComponentSize)); table.WriteRow("DynamicStatics:", vMethTable.bIsDynamic ? "true" : "false"); @@ -10338,7 +10356,7 @@ DECLARE_API(EEVersion) else ExtOut("Workstation mode\n"); - if (!GetGcStructuresValid()) + if (!GetGcStructuresValid()) { ExtOut("In plan phase of garbage collection\n"); } @@ -15797,7 +15815,7 @@ class EnumMemoryCallback : public ICLRDataEnumMemoryRegionsCallback, ICLRDataLog } } if (IsInterrupt()) - { + { return COR_E_OPERATIONCANCELED; } return S_OK; @@ -15808,7 +15826,7 @@ class EnumMemoryCallback : public ICLRDataEnumMemoryRegionsCallback, ICLRDataLog { ExtOut("%s", message); if (IsInterrupt()) - { + { return COR_E_OPERATIONCANCELED; } return S_OK; @@ -15824,7 +15842,7 @@ DECLARE_API(enummem) if (SUCCEEDED(Status)) { ToRelease callback = new EnumMemoryCallback(false, true); - ULONG32 minidumpType = + ULONG32 minidumpType = (MiniDumpWithPrivateReadWriteMemory | MiniDumpWithDataSegs | MiniDumpWithHandleData | diff --git a/src/SOS/Strike/util.cpp b/src/SOS/Strike/util.cpp index 3c55c64420..7135d1ed9a 100644 --- a/src/SOS/Strike/util.cpp +++ b/src/SOS/Strike/util.cpp @@ -3488,7 +3488,7 @@ size_t FunctionType (size_t EIP) // // Return true if major runtime version (logical product version like 2.1, -// 3.0 or 5.x). Currently only major versions of 3 or 5 are supported. +// 3.0 or 5.x). // bool IsRuntimeVersion(DWORD major) { @@ -3504,13 +3504,10 @@ bool IsRuntimeVersion(VS_FIXEDFILEINFO& fileInfo, DWORD major) { switch (major) { - case 5: - return HIWORD(fileInfo.dwFileVersionMS) == 5; case 3: return HIWORD(fileInfo.dwFileVersionMS) == 4 && LOWORD(fileInfo.dwFileVersionMS) == 700; default: - _ASSERTE(FALSE); - break; + return HIWORD(fileInfo.dwFileVersionMS) == major; } return false; } @@ -3536,18 +3533,14 @@ bool IsRuntimeVersionAtLeast(VS_FIXEDFILEINFO& fileInfo, DWORD major) } // fall through - case 5: - if (HIWORD(fileInfo.dwFileVersionMS) >= 5) + default: + if (HIWORD(fileInfo.dwFileVersionMS) >= major) { return true; } // fall through break; - - default: - _ASSERTE(FALSE); - break; } return false; }