Skip to content

Fix output of FieldRef token #3170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/CLR/Diagnostics/Diagnostics_stub.cpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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();
}
Expand Down
25 changes: 19 additions & 6 deletions src/CLR/Diagnostics/Info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/CLR/Include/nanoCLR_Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down