diff options
author | Carol Eidt <carol.eidt@microsoft.com> | 2019-06-12 09:07:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-12 09:07:32 -0700 |
commit | 1bed4714dcf1ae73100f110ff2ff1642c616bb93 (patch) | |
tree | d08be8a09874e517f19d77d17762f19ee9fe0da0 /src/ToolBox | |
parent | ac1effe215b1f01df31c2c97526c81e3c2211c0e (diff) | |
download | coreclr-1bed4714dcf1ae73100f110ff2ff1642c616bb93.tar.gz coreclr-1bed4714dcf1ae73100f110ff2ff1642c616bb93.tar.bz2 coreclr-1bed4714dcf1ae73100f110ff2ff1642c616bb93.zip |
SuperPMI: Fix `getFieldType` (#25102)
* SuperPMI: Fix `getFieldType`
The `structType` out parameter is optional (i.e. it may be null), but it's not used as a key, so we need to update the map if we've saved a null but encounter a non-null.
Diffstat (limited to 'src/ToolBox')
-rw-r--r-- | src/ToolBox/superpmi/superpmi-shared/lightweightmap.h | 7 | ||||
-rw-r--r-- | src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp | 14 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/ToolBox/superpmi/superpmi-shared/lightweightmap.h b/src/ToolBox/superpmi/superpmi-shared/lightweightmap.h index 069287c1d3..cba843afca 100644 --- a/src/ToolBox/superpmi/superpmi-shared/lightweightmap.h +++ b/src/ToolBox/superpmi/superpmi-shared/lightweightmap.h @@ -299,7 +299,7 @@ public: return size; } - // its worth noting that the acutal order of insert here doesnt meet what you migth expect. Its using memcmp, so + // It's worth noting that the actual order of insertion here doesnt meet what you might expect. It's using memcmp, so // since we are on a little endian machine we'd use the lowest 8 bits as the first part of the key. This is // a side effect of using the same code for large structs and DWORDS etc... bool Add(_Key key, _Item item) @@ -366,6 +366,11 @@ public: return true; } + void Update(int index, _Item item) + { + pItems[index] = item; + } + int GetIndex(_Key key) { AssertCodeMsg(this != nullptr, EXCEPTIONCODE_MC, "There is no such LWM (in GetIndex)"); diff --git a/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp b/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp index 96e95d1ed6..d7d7ab042e 100644 --- a/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp @@ -4353,6 +4353,7 @@ void MethodContext::recGetFieldType(CORINFO_FIELD_HANDLE field, key.A = (DWORDLONG)field; key.B = (DWORDLONG)memberParent; + value.B = (DWORD)result; if (structType == nullptr) { value.A = 0; @@ -4360,9 +4361,18 @@ void MethodContext::recGetFieldType(CORINFO_FIELD_HANDLE field, else { value.A = (DWORDLONG)*structType; - } - value.B = (DWORD)result; + // If we had a previous call with null 'structType', we will not have captured the + // class handle (we use only 'field' and 'memberParent' as keys). + // Update the value in that case. + unsigned index = GetFieldType->GetIndex(key); + if ((index != -1) && (GetFieldType->GetItem(index).A == 0)) + { + GetFieldType->Update(index, value); + DEBUG_REC(dmpGetFieldType(key, value)); + return; + } + } GetFieldType->Add(key, value); DEBUG_REC(dmpGetFieldType(key, value)); } |