[Linux][GDBJIT] Fix crashes related with locals debug info generation (dotnet/corecl...
authorEvgeny Pavlov <lucenticus@gmail.com>
Wed, 9 Nov 2016 17:08:49 +0000 (20:08 +0300)
committerMike McLaughlin <mikem@microsoft.com>
Wed, 9 Nov 2016 17:08:49 +0000 (09:08 -0800)
* [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
src/coreclr/src/vm/gdbjit.cpp

index e15d08d..821c3b4 100644 (file)
@@ -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)
index 1b1b20e..0b0949b 100644 (file)
@@ -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<TADDR>(base));
+                        info->members[i].m_static_member_address = dac_cast<TADDR>(pAddress);
                     }
-                    PTR_VOID pAddress = pField->GetStaticAddressHandle((PTR_VOID)dac_cast<TADDR>(base));
-                    info->members[i].m_static_member_address = dac_cast<TADDR>(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);