From: Evgeny Pavlov Date: Wed, 9 Nov 2016 17:08:49 +0000 (+0300) Subject: [Linux][GDBJIT] Fix crashes related with locals debug info generation (#7874) X-Git-Tag: accepted/tizen/base/20180629.140029~3107 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=09d6822d7b99bfaa7bb27d0c7c560fdad36f8fd4;p=platform%2Fupstream%2Fcoreclr.git [Linux][GDBJIT] Fix crashes related with locals debug info generation (#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 --- diff --git a/src/vm/CMakeLists.txt b/src/vm/CMakeLists.txt index e15d08d..821c3b4 100644 --- a/src/vm/CMakeLists.txt +++ b/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/vm/gdbjit.cpp b/src/vm/gdbjit.cpp index 1b1b20e..0b0949b 100644 --- a/src/vm/gdbjit.cpp +++ b/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);