From 22f3fd2fd0973e99574bf0625797ca53a0553970 Mon Sep 17 00:00:00 2001 From: Max Charlamb <44248479+max-charlamb@users.noreply.github.com> Date: Thu, 24 Jul 2025 14:54:54 -0400 Subject: [PATCH 1/2] modify EnumMethodInstancesByAddress to only return the single MethodDesc at the ip --- src/coreclr/debug/daccess/daccess.cpp | 7 +++++- src/coreclr/debug/daccess/dacimpl.h | 3 +-- src/coreclr/debug/daccess/task.cpp | 36 +++++---------------------- 3 files changed, 13 insertions(+), 33 deletions(-) diff --git a/src/coreclr/debug/daccess/daccess.cpp b/src/coreclr/debug/daccess/daccess.cpp index e800a6eed33fe1..9a67f00f60cb77 100644 --- a/src/coreclr/debug/daccess/daccess.cpp +++ b/src/coreclr/debug/daccess/daccess.cpp @@ -4186,6 +4186,11 @@ ClrDataAccess::StartEnumMethodInstancesByAddress( goto Exit; } + if (!methodDesc->HasNativeCodeAnyVersion()) + { + goto Exit; + } + status = EnumMethodInstances::CdStart(methodDesc, appDomain, handle); @@ -5990,7 +5995,7 @@ ClrDataAccess::GetMethodVarInfo(MethodDesc* methodDesc, BOOL success = DebugInfoManager::GetBoundariesAndVars( request, DebugInfoStoreNew, NULL, // allocator - BoundsType::Instrumented, + BoundsType::Instrumented, NULL, NULL, &countNativeVarInfo, &nativeVars); diff --git a/src/coreclr/debug/daccess/dacimpl.h b/src/coreclr/debug/daccess/dacimpl.h index 027efee6d3bb67..51483280466fbd 100644 --- a/src/coreclr/debug/daccess/dacimpl.h +++ b/src/coreclr/debug/daccess/dacimpl.h @@ -3798,9 +3798,8 @@ class EnumMethodInstances static HRESULT CdEnd(CLRDATA_ENUM handle); MethodDesc* m_methodDesc; - bool m_appDomainUsed; AppDomain* m_appDomain; - LoadedMethodDescIterator m_methodIter; + bool m_completed; }; //---------------------------------------------------------------------------- diff --git a/src/coreclr/debug/daccess/task.cpp b/src/coreclr/debug/daccess/task.cpp index b55626e2d33185..e4f3b3f98d4412 100644 --- a/src/coreclr/debug/daccess/task.cpp +++ b/src/coreclr/debug/daccess/task.cpp @@ -5163,41 +5163,24 @@ EnumMethodInstances::EnumMethodInstances(MethodDesc* methodDesc, { m_appDomain = AppDomain::GetCurrentDomain(); } - m_appDomainUsed = false; + + m_completed = false; } HRESULT EnumMethodInstances::Next(ClrDataAccess* dac, IXCLRDataMethodInstance **instance) { - if (!m_appDomainUsed) - { - m_appDomainUsed = true; - m_methodIter.Start(m_appDomain, - m_methodDesc->GetModule(), // module - m_methodDesc->GetMemberDef(), // token - m_methodDesc); // initial method desc - } - - NextMethod: - { - // Note: DAC doesn't need to keep the assembly alive - see code:CollectibleAssemblyHolder#CAH_DAC - CollectibleAssemblyHolder pAssembly; - if (!m_methodIter.Next(pAssembly.This())) - { - return S_FALSE; - } - } - - if (!m_methodIter.Current()->HasNativeCodeAnyVersion()) + if (m_completed) { - goto NextMethod; + return S_FALSE; } + m_completed = true; *instance = new (nothrow) ClrDataMethodInstance(dac, m_appDomain, - m_methodIter.Current()); + m_methodDesc); return *instance ? S_OK : E_OUTOFMEMORY; } @@ -5206,13 +5189,6 @@ EnumMethodInstances::CdStart(MethodDesc* methodDesc, IXCLRDataAppDomain* appDomain, CLRDATA_ENUM* handle) { - if (!methodDesc->HasClassOrMethodInstantiation() && - !(methodDesc->HasNativeCodeAnyVersion())) - { - *handle = 0; - return S_FALSE; - } - EnumMethodInstances* iter = new (nothrow) EnumMethodInstances(methodDesc, appDomain); if (iter) From e7c668a6ae5bd06aa4af7a5967637cdbbd9cddaf Mon Sep 17 00:00:00 2001 From: Max Charlamb <44248479+max-charlamb@users.noreply.github.com> Date: Thu, 24 Jul 2025 15:22:42 -0400 Subject: [PATCH 2/2] use member initializer list --- src/coreclr/debug/daccess/task.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/coreclr/debug/daccess/task.cpp b/src/coreclr/debug/daccess/task.cpp index e4f3b3f98d4412..746337b5733486 100644 --- a/src/coreclr/debug/daccess/task.cpp +++ b/src/coreclr/debug/daccess/task.cpp @@ -5152,19 +5152,12 @@ EnumMethodDefinitions::CdEnd(CLRDATA_ENUM handle) EnumMethodInstances::EnumMethodInstances(MethodDesc* methodDesc, IXCLRDataAppDomain* givenAppDomain) + : m_methodDesc(methodDesc), + m_appDomain(givenAppDomain ? + ((ClrDataAppDomain*)givenAppDomain)->GetAppDomain() : + AppDomain::GetCurrentDomain()), + m_completed(false) { - m_methodDesc = methodDesc; - if (givenAppDomain) - { - m_appDomain = - ((ClrDataAppDomain*)givenAppDomain)->GetAppDomain(); - } - else - { - m_appDomain = AppDomain::GetCurrentDomain(); - } - - m_completed = false; } HRESULT