From e5972b832a89add188fce3bc9b67e0ec2c73c6c8 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" Date: Mon, 15 Aug 2022 12:21:21 +0000 Subject: [PATCH 1/7] Update dependencies from https://github.com/dotnet/installer build 20220814.7 Microsoft.Dotnet.Sdk.Internal From Version 7.0.100-rc.1.22407.1 -> To Version 7.0.100-rc.1.22414.7 --- eng/Version.Details.xml | 4 ++-- eng/Versions.props | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 5b42068c72..451c64a6e9 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -28,9 +28,9 @@ https://github.com/dotnet/arcade ccfe6da198c5f05534863bbb1bff66e830e0c6ab - + https://github.com/dotnet/installer - 8f639696e6d57fb09e03e89c6397d913de1231ed + 1dc3340838d6a59dd1c83e7064358e3a42fb150c https://github.com/dotnet/aspnetcore diff --git a/eng/Versions.props b/eng/Versions.props index 990044f2a0..43e05c5cca 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -24,7 +24,7 @@ 7.0.0-rc.2.22424.4 7.0.0-rc.2.22424.4 - 7.0.100-rc.1.22407.1 + 7.0.100-rc.1.22414.7 From 8793826eef21c8b869f78cc00d476c53913e7df7 Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Mon, 15 Aug 2022 09:21:57 -0700 Subject: [PATCH 2/7] Update single-file 7.0 runtime version --- eng/Versions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index 43e05c5cca..17ededa3f5 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -34,7 +34,7 @@ $(MicrosoftNETCoreApp60Version) 6.0.8 - 7.0.0-rc.1.22403.8 + 7.0.0-rc.1.22411.12 From 75bcef37cc7595a1ae00cf9ccccca2a4564f2160 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" Date: Mon, 22 Aug 2022 12:17:01 +0000 Subject: [PATCH 3/7] Update dependencies from https://github.com/dotnet/installer build 20220819.24 Microsoft.Dotnet.Sdk.Internal From Version 7.0.100-rc.1.22407.1 -> To Version 7.0.100-rc.2.22419.24 --- eng/Version.Details.xml | 4 ++-- eng/Versions.props | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 451c64a6e9..8fb6bcdb96 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -28,9 +28,9 @@ https://github.com/dotnet/arcade ccfe6da198c5f05534863bbb1bff66e830e0c6ab - + https://github.com/dotnet/installer - 1dc3340838d6a59dd1c83e7064358e3a42fb150c + 84d26a070704dc4eb7870f15d44880228bb82cb8 https://github.com/dotnet/aspnetcore diff --git a/eng/Versions.props b/eng/Versions.props index 17ededa3f5..74e1950cae 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -24,7 +24,7 @@ 7.0.0-rc.2.22424.4 7.0.0-rc.2.22424.4 - 7.0.100-rc.1.22414.7 + 7.0.100-rc.2.22419.24 From e3ec69395b0adf9e9bd55112c29c311a3d006457 Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Wed, 24 Aug 2022 17:13:46 -0700 Subject: [PATCH 4/7] Fixed lldb's ReadVirtual to support partial reads Fixed the DumpRuntimeTypes command to build the GC heap info. It was looking up segments uninitialized. --- src/SOS/Strike/strike.cpp | 6 +++ src/SOS/lldbplugin/services.cpp | 67 +++++++++++++++++++++++++++------ 2 files changed, 61 insertions(+), 12 deletions(-) diff --git a/src/SOS/Strike/strike.cpp b/src/SOS/Strike/strike.cpp index f5156d38a9..efd0124967 100644 --- a/src/SOS/Strike/strike.cpp +++ b/src/SOS/Strike/strike.cpp @@ -3956,6 +3956,12 @@ DECLARE_API(DumpRuntimeTypes) "Address", "Domain", "MT"); ExtOut("------------------------------------------------------------------------------\n"); + if (!g_snapshot.Build()) + { + ExtOut("Unable to build snapshot of the garbage collector state\n"); + return E_FAIL; + } + PrintRuntimeTypeArgs pargs; ZeroMemory(&pargs, sizeof(PrintRuntimeTypeArgs)); diff --git a/src/SOS/lldbplugin/services.cpp b/src/SOS/lldbplugin/services.cpp index fde35e73f8..deaeb4ee11 100644 --- a/src/SOS/lldbplugin/services.cpp +++ b/src/SOS/lldbplugin/services.cpp @@ -757,15 +757,28 @@ LLDBServices::GetContextStackTrace( // IDebugDataSpaces //---------------------------------------------------------------------------- +#define PAGE_SIZE 0x1000 +#define PAGE_MASK (~(PAGE_SIZE-1)) + HRESULT LLDBServices::ReadVirtual( ULONG64 offset, PVOID buffer, ULONG bufferSize, - PULONG bytesRead) + PULONG pbytesRead) { lldb::SBError error; - size_t read = 0; + size_t bytesRead = 0; + ULONG64 page; + + if (bufferSize == 0) + { + if (pbytesRead) + { + *pbytesRead = 0; + } + return S_OK; + } // lldb doesn't expect sign-extended address offset = CONVERT_FROM_SIGN_EXTENDED(offset); @@ -776,9 +789,41 @@ LLDBServices::ReadVirtual( goto exit; } - read = process.ReadMemory(offset, buffer, bufferSize, error); + // Try the full read and return if successful + bytesRead = process.ReadMemory(offset, buffer, bufferSize, error); + if (error.Success()) + { + goto exit; + } + + // As it turns out the lldb ReadMemory API doesn't do partial reads and the SOS + // caching depends on that behavior. Round up to the next page boundry and attempt + // to read up to the page boundries. + page = (offset + PAGE_SIZE - 1) & PAGE_MASK; - if (!error.Success()) + while (bufferSize > 0) + { + size_t size = page - offset; + if (size > bufferSize) + { + size = bufferSize; + } + size_t read = process.ReadMemory(offset, buffer, size, error); + + bytesRead += read; + offset += read; + buffer = (BYTE*)buffer + read; + bufferSize -= read; + page += PAGE_SIZE; + + if (!error.Success()) + { + break; + } + } + + // If the read isn't complete, try reading directly from native modules in the address range. + if (bufferSize > 0) { lldb::SBTarget target = process.GetTarget(); if (!target.IsValid()) @@ -787,8 +832,7 @@ LLDBServices::ReadVirtual( } int numModules = target.GetNumModules(); - bool found = false; - for (int i = 0; !found && i < numModules; i++) + for (int i = 0; i < numModules; i++) { lldb::SBModule module = target.GetModuleAtIndex(i); int numSections = module.GetNumSections(); @@ -803,9 +847,8 @@ LLDBServices::ReadVirtual( lldb::SBData sectionData = section.GetSectionData(offset - loadAddr, bufferSize); if (sectionData.IsValid()) { - read = sectionData.ReadRawData(error, 0, buffer, bufferSize); - found = true; - break; + bytesRead += sectionData.ReadRawData(error, 0, buffer, bufferSize); + goto exit; } } } @@ -813,11 +856,11 @@ LLDBServices::ReadVirtual( } exit: - if (bytesRead) + if (pbytesRead) { - *bytesRead = read; + *pbytesRead = bytesRead; } - return error.Success() || (read != 0) ? S_OK : E_FAIL; + return bytesRead > 0 ? S_OK : E_FAIL; } HRESULT From 94b223410b41502116fe1cbda0f9b9385832be87 Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Thu, 25 Aug 2022 13:39:07 -0700 Subject: [PATCH 5/7] Fix alpine build break --- src/SOS/lldbplugin/services.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SOS/lldbplugin/services.cpp b/src/SOS/lldbplugin/services.cpp index deaeb4ee11..6534057221 100644 --- a/src/SOS/lldbplugin/services.cpp +++ b/src/SOS/lldbplugin/services.cpp @@ -757,8 +757,10 @@ LLDBServices::GetContextStackTrace( // IDebugDataSpaces //---------------------------------------------------------------------------- +#ifndef PAGE_SIZE #define PAGE_SIZE 0x1000 -#define PAGE_MASK (~(PAGE_SIZE-1)) +#endif +#define PAGE_MASK (~(PAGE_SIZE-1)) HRESULT LLDBServices::ReadVirtual( From 421e44dba1fa166a85e3ee1c9338edcd2340a998 Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Fri, 26 Aug 2022 11:30:38 -0700 Subject: [PATCH 6/7] Code review feedback. Use syscall to get page size on arm platforms --- src/SOS/lldbplugin/services.cpp | 36 ++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/SOS/lldbplugin/services.cpp b/src/SOS/lldbplugin/services.cpp index 6534057221..845ac5d78e 100644 --- a/src/SOS/lldbplugin/services.cpp +++ b/src/SOS/lldbplugin/services.cpp @@ -19,6 +19,21 @@ #define InvalidTimeStamp 0xFFFFFFFE; #define InvalidChecksum 0xFFFFFFFF; +#ifndef PAGE_SIZE +#if (defined(__arm__) || defined(__aarch64__) || defined(__loongarch64)) +#define PAGE_SIZE g_pageSize +#else +#define PAGE_SIZE 0x1000 +#endif +#endif + +#undef PAGE_MASK +#define PAGE_MASK (~(PAGE_SIZE-1)) + +#if defined(__arm__) || defined(__aarch64__) || defined(__loongarch64) +long g_pageSize = 0; +#endif + char *g_coreclrDirectory = nullptr; char *g_pluginModuleDirectory = nullptr; @@ -32,6 +47,11 @@ LLDBServices::LLDBServices(lldb::SBDebugger debugger) : m_processId(0), m_threadInfoInitialized(false) { + // Initialize PAGE_SIZE +#if defined(__arm__) || defined(__aarch64__) || defined(__loongarch64) + g_pageSize = sysconf(_SC_PAGESIZE); +#endif + ClearCache(); lldb::SBProcess process = GetCurrentProcess(); @@ -432,7 +452,7 @@ HRESULT LLDBServices::GetPageSize( PULONG size) { - *size = 4096; + *size = PAGE_SIZE; return S_OK; } @@ -757,11 +777,6 @@ LLDBServices::GetContextStackTrace( // IDebugDataSpaces //---------------------------------------------------------------------------- -#ifndef PAGE_SIZE -#define PAGE_SIZE 0x1000 -#endif -#define PAGE_MASK (~(PAGE_SIZE-1)) - HRESULT LLDBServices::ReadVirtual( ULONG64 offset, @@ -771,8 +786,9 @@ LLDBServices::ReadVirtual( { lldb::SBError error; size_t bytesRead = 0; - ULONG64 page; + ULONG64 nextPageStart; + // Reading 0 bytes must succeed if (bufferSize == 0) { if (pbytesRead) @@ -801,11 +817,11 @@ LLDBServices::ReadVirtual( // As it turns out the lldb ReadMemory API doesn't do partial reads and the SOS // caching depends on that behavior. Round up to the next page boundry and attempt // to read up to the page boundries. - page = (offset + PAGE_SIZE - 1) & PAGE_MASK; + nextPageStart = (offset + PAGE_SIZE - 1) & PAGE_MASK; while (bufferSize > 0) { - size_t size = page - offset; + size_t size = nextPageStart - offset; if (size > bufferSize) { size = bufferSize; @@ -816,7 +832,7 @@ LLDBServices::ReadVirtual( offset += read; buffer = (BYTE*)buffer + read; bufferSize -= read; - page += PAGE_SIZE; + nextPageStart += PAGE_SIZE; if (!error.Success()) { From e8f37e312b43a70edc49e33bb9f635a64b20c6a3 Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Fri, 26 Aug 2022 13:08:15 -0700 Subject: [PATCH 7/7] Revert sysconf page size changes --- src/SOS/SOS.UnitTests/SOS.cs | 2 ++ .../SOS.UnitTests/Scripts/StackAndOtherTests.script | 2 ++ src/SOS/SOS.UnitTests/Scripts/StackTests.script | 2 ++ src/SOS/lldbplugin/services.cpp | 13 ------------- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/SOS/SOS.UnitTests/SOS.cs b/src/SOS/SOS.UnitTests/SOS.cs index df0b0b4b6c..a2ca729366 100644 --- a/src/SOS/SOS.UnitTests/SOS.cs +++ b/src/SOS/SOS.UnitTests/SOS.cs @@ -366,6 +366,8 @@ public async Task DumpGen(TestConfiguration config) [SkippableTheory, MemberData(nameof(Configurations))] public async Task LLDBPluginTests(TestConfiguration config) { + SkipIfArm(config); + if (OS.Kind == OSKind.Windows || config.IsDesktop || config.RuntimeFrameworkVersionMajor == 1 || OS.IsAlpine) { throw new SkipTestException("lldb plugin tests not supported on Windows, Alpine Linux or .NET Core 1.1"); diff --git a/src/SOS/SOS.UnitTests/Scripts/StackAndOtherTests.script b/src/SOS/SOS.UnitTests/Scripts/StackAndOtherTests.script index cbef0dbcbf..bd796f7176 100644 --- a/src/SOS/SOS.UnitTests/Scripts/StackAndOtherTests.script +++ b/src/SOS/SOS.UnitTests/Scripts/StackAndOtherTests.script @@ -198,6 +198,7 @@ ENDIF:NETCORE_OR_DOTNETDUMP # Issue: https://github.com/dotnet/diagnostics/issues/2947 !IFDEF:DOTNETDUMP +!IFDEF:ARM64 !IFDEF:ARM # Verify DumpStack works @@ -218,6 +219,7 @@ VERIFY:.*Child(-SP|EBP|FP)\s+RetAddr\s+Caller, Callee\s+ VERIFY:(.*\s+\s+\s+\(MethodDesc\s+\s+(\+\s*0x\s+)?SymbolTestApp\.Program\.Foo4\(System\.String\)\),\s+calling.*\s+)|(.*\s+\s+\s+\(MethodDesc\s+\s+(\+\s*0x\s+)?SymbolTestApp\.Program\.Foo2\(Int32, System\.String\)\),\s+calling.*\s+) ENDIF:ARM +ENDIF:ARM64 ENDIF:DOTNETDUMP # Verify that IP2MD works (uses IP from ClrStack) diff --git a/src/SOS/SOS.UnitTests/Scripts/StackTests.script b/src/SOS/SOS.UnitTests/Scripts/StackTests.script index d73d25805c..b406e5d338 100644 --- a/src/SOS/SOS.UnitTests/Scripts/StackTests.script +++ b/src/SOS/SOS.UnitTests/Scripts/StackTests.script @@ -152,6 +152,7 @@ VERIFY:.*\s+\s+\s+System\.String.* # Issue: https://github.com/dotnet/diagnostics/issues/2947 !IFDEF:DOTNETDUMP +!IFDEF:ARM64 !IFDEF:ARM # 9) Verify DumpStack works @@ -172,4 +173,5 @@ VERIFY:.*Child(-SP|EBP|FP)\s+RetAddr\s+Caller, Callee\s+ VERIFY:.*\s+\s+\s+\(MethodDesc\s+\s+\+\s*0x\s+NestedExceptionTest\.Program\.Main\(System\.String\[\]\)\),\s+calling.* ENDIF:ARM +ENDIF:ARM64 ENDIF:DOTNETDUMP diff --git a/src/SOS/lldbplugin/services.cpp b/src/SOS/lldbplugin/services.cpp index 845ac5d78e..ffdadb0b61 100644 --- a/src/SOS/lldbplugin/services.cpp +++ b/src/SOS/lldbplugin/services.cpp @@ -20,20 +20,12 @@ #define InvalidChecksum 0xFFFFFFFF; #ifndef PAGE_SIZE -#if (defined(__arm__) || defined(__aarch64__) || defined(__loongarch64)) -#define PAGE_SIZE g_pageSize -#else #define PAGE_SIZE 0x1000 #endif -#endif #undef PAGE_MASK #define PAGE_MASK (~(PAGE_SIZE-1)) -#if defined(__arm__) || defined(__aarch64__) || defined(__loongarch64) -long g_pageSize = 0; -#endif - char *g_coreclrDirectory = nullptr; char *g_pluginModuleDirectory = nullptr; @@ -47,11 +39,6 @@ LLDBServices::LLDBServices(lldb::SBDebugger debugger) : m_processId(0), m_threadInfoInitialized(false) { - // Initialize PAGE_SIZE -#if defined(__arm__) || defined(__aarch64__) || defined(__loongarch64) - g_pageSize = sysconf(_SC_PAGESIZE); -#endif - ClearCache(); lldb::SBProcess process = GetCurrentProcess();