diff --git a/src/CLR/Diagnostics/Diagnostics_stub.cpp b/src/CLR/Diagnostics/Diagnostics_stub.cpp index 45a0212725..d543cd753d 100644 --- a/src/CLR/Diagnostics/Diagnostics_stub.cpp +++ b/src/CLR/Diagnostics/Diagnostics_stub.cpp @@ -1,4 +1,4 @@ -// +// // Copyright (c) .NET Foundation and Contributors // Portions Copyright (c) Microsoft Corporation. All rights reserved. // See LICENSE file in the project root for full license information. @@ -112,7 +112,7 @@ __nfweak const CLR_UINT8 *CLR_SkipBodyOfOpcodeCompressed(const CLR_UINT8 *ip, CL #if defined(NANOCLR_TRACE_INSTRUCTIONS) -__nfweak void CLR_RT_Assembly::DumpToken(CLR_UINT32 tk) +__nfweak void CLR_RT_Assembly::DumpToken(CLR_UINT32 tk, const CLR_RT_TypeSpec_Index *genericType) { NATIVE_PROFILE_CLR_DIAGNOSTICS(); } diff --git a/src/CLR/Diagnostics/Info.cpp b/src/CLR/Diagnostics/Info.cpp index e2b5f59f3c..f2fc408997 100644 --- a/src/CLR/Diagnostics/Info.cpp +++ b/src/CLR/Diagnostics/Info.cpp @@ -413,7 +413,7 @@ const CLR_UINT8 *CLR_SkipBodyOfOpcodeCompressed(const CLR_UINT8 *ip, CLR_OPCODE #if defined(NANOCLR_TRACE_INSTRUCTIONS) -void CLR_RT_Assembly::DumpToken(CLR_UINT32 token) +void CLR_RT_Assembly::DumpToken(CLR_UINT32 token, const CLR_RT_TypeSpec_Index *genericType) { NATIVE_PROFILE_CLR_DIAGNOSTICS(); CLR_UINT32 index = CLR_DataFromTk(token); @@ -443,14 +443,27 @@ void CLR_RT_Assembly::DumpToken(CLR_UINT32 token) } case TBL_FieldRef: { - LOOKUP_ELEMENT_REF(index, FieldRef, FIELDREF, FieldDef); - if (s) + const CLR_RECORD_FIELDREF *fr = GetFieldRef(index); + const auto &xref = crossReferenceFieldRef[index]; + + // If the caller passed in a closed‐generic TypeSpec, use that … + if (genericType->data != CLR_EmptyToken) { - CLR_RT_DUMP::FIELD(*s); + // Build the closed‐generic owner name + char rgType[256], *sz = rgType; + size_t cb = sizeof(rgType); + g_CLR_RT_TypeSystem.BuildTypeName(*genericType, sz, cb); + + // Append the field name + CLR_SafeSprintf(sz, cb, "::%s", GetString(fr->name)); + CLR_Debug::Printf("%s", rgType); } else { - CLR_Debug::Printf("%s", GetString(p->name)); + // Otherwise fall back to the old FieldDef path + CLR_RT_FieldDef_Index fd; + fd.Set(assemblyIndex, xref.target.data); + CLR_RT_DUMP::FIELD(fd); } break; } @@ -662,7 +675,7 @@ void CLR_RT_Assembly::DumpOpcodeDirect( if (IsOpParamToken(opParam)) { - DumpToken(CLR_ReadTokenCompressed(ip, op)); + DumpToken(CLR_ReadTokenCompressed(ip, op), call.genericType); } else { diff --git a/src/CLR/Include/nanoCLR_Runtime.h b/src/CLR/Include/nanoCLR_Runtime.h index 89a84c01d5..1c8c7f961f 100644 --- a/src/CLR/Include/nanoCLR_Runtime.h +++ b/src/CLR/Include/nanoCLR_Runtime.h @@ -1558,7 +1558,7 @@ struct CLR_RT_Assembly : public CLR_RT_HeapBlock_Node // EVENT HEAP - NO RELOCAT DECL_POSTFIX; private: - void DumpToken(CLR_UINT32 tk) DECL_POSTFIX; + void DumpToken(CLR_UINT32 tk, const CLR_RT_TypeSpec_Index *genericType) DECL_POSTFIX; void DumpSignature(CLR_SIG sig) DECL_POSTFIX; void DumpSignature(CLR_PMETADATA &p) DECL_POSTFIX; void DumpSignatureToken(CLR_PMETADATA &p) DECL_POSTFIX;