From 7d6461d74e28fae3aed3507846607256b38aa87a Mon Sep 17 00:00:00 2001 From: Evgeny Pavlov Date: Wed, 9 Nov 2016 20:08:49 +0300 Subject: [PATCH] [Linux][GDBJIT] Fix crashes related with locals debug info generation (dotnet/coreclr#7874) * [GDBJIT] Fix several issues related with generation debug info for locals: * Fix crash on generics static * Add support of pointer type * Fix incorrect processing of classes when we have several locals with the same class type * Move gdbjit.cpp from VM_SOURCES_DAC_AND_WKS_COMMON to VM_SOURCES_WKS Commit migrated from https://github.com/dotnet/coreclr/commit/09d6822d7b99bfaa7bb27d0c7c560fdad36f8fd4 --- src/coreclr/src/vm/CMakeLists.txt | 2 +- src/coreclr/src/vm/gdbjit.cpp | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/coreclr/src/vm/CMakeLists.txt b/src/coreclr/src/vm/CMakeLists.txt index e15d08d..821c3b4 100644 --- a/src/coreclr/src/vm/CMakeLists.txt +++ b/src/coreclr/src/vm/CMakeLists.txt @@ -117,7 +117,6 @@ set(VM_SOURCES_DAC_AND_WKS_COMMON virtualcallstub.cpp win32threadpool.cpp zapsig.cpp - ${VM_SOURCES_GDBJIT} ) if(FEATURE_READYTORUN) @@ -241,6 +240,7 @@ set(VM_SOURCES_WKS typeparse.cpp verifier.cpp weakreferencenative.cpp + ${VM_SOURCES_GDBJIT} ) if(FEATURE_EVENT_TRACE) diff --git a/src/coreclr/src/vm/gdbjit.cpp b/src/coreclr/src/vm/gdbjit.cpp index 1b1b20e..0b0949b 100644 --- a/src/coreclr/src/vm/gdbjit.cpp +++ b/src/coreclr/src/vm/gdbjit.cpp @@ -66,9 +66,6 @@ GetTypeInfoFromTypeHandle(TypeHandle typeHandle, NotifyGdb::PTK_TypeInfoMap pTyp typeInfo->m_type_size = typeHandle.AsMethodTable()->GetClass()->GetSize(); - pTypeMap->Add(typeInfo->GetTypeKey(), typeInfo); - typeInfo->CalculateName(); - RefTypeInfo* refTypeInfo = nullptr; if (!typeHandle.IsValueType()) { @@ -84,6 +81,10 @@ GetTypeInfoFromTypeHandle(TypeHandle typeHandle, NotifyGdb::PTK_TypeInfoMap pTyp pTypeMap->Add(refTypeInfo->GetTypeKey(), refTypeInfo); } + + pTypeMap->Add(typeInfo->GetTypeKey(), typeInfo); + typeInfo->CalculateName(); + // // Now fill in the array // @@ -106,13 +107,15 @@ GetTypeInfoFromTypeHandle(TypeHandle typeHandle, NotifyGdb::PTK_TypeInfoMap pTyp else { PTR_BYTE base = 0; - if (!pField->IsRVA()) + MethodTable* pMT = pField->GetEnclosingMethodTable(); + base = pField->GetBase(); + + // TODO: add support of generics with static fields + if (pField->IsRVA() || !pMT->IsDynamicStatics()) { - MethodTable* pMT = pField->GetEnclosingMethodTable(); - base = pField->GetBaseInDomainLocalModule(pMT->GetDomainLocalModule(NULL)); + PTR_VOID pAddress = pField->GetStaticAddressHandle((PTR_VOID)dac_cast(base)); + info->members[i].m_static_member_address = dac_cast(pAddress); } - PTR_VOID pAddress = pField->GetStaticAddressHandle((PTR_VOID)dac_cast(base)); - info->members[i].m_static_member_address = dac_cast(pAddress); } info->members[i].m_member_type = @@ -134,6 +137,7 @@ GetTypeInfoFromTypeHandle(TypeHandle typeHandle, NotifyGdb::PTK_TypeInfoMap pTyp else return typeInfo; } + case ELEMENT_TYPE_PTR: case ELEMENT_TYPE_BYREF: { TypeInfoBase* valTypeInfo = GetTypeInfoFromTypeHandle(typeHandle.GetTypeParam(), pTypeMap); -- 2.7.4