Skip to content
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
2 changes: 2 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -8280,6 +8280,8 @@ class Compiler
const char* eeGetClassAssemblyName(CORINFO_CLASS_HANDLE clsHnd);

#if defined(DEBUG)
void eePrintStringLiteral(CORINFO_MODULE_HANDLE module, unsigned token);

unsigned eeTryGetClassSize(CORINFO_CLASS_HANDLE clsHnd);
#endif

Expand Down
32 changes: 32 additions & 0 deletions src/coreclr/jit/eeinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,3 +692,35 @@ void Compiler::eePrintObjectDescription(const char* prefix, CORINFO_OBJECT_HANDL

printf("%s '%s'", prefix, str);
}

#ifdef DEBUG
//------------------------------------------------------------------------
// eePrintStringLiteral:
// Print a string literal. If missing information (in SPMI),
// then print a placeholder string.
//
// Arguments:
// module - The literal's scope handle
// token - The literal's token
//
void Compiler::eePrintStringLiteral(CORINFO_MODULE_HANDLE module, unsigned token)
{
const int MAX_LITERAL_LENGTH = 256;
char16_t str[MAX_LITERAL_LENGTH] = {};
int length = -1;
eeRunFunctorWithSPMIErrorTrap([&]() {
length = info.compCompHnd->getStringLiteral(module, token, str, MAX_LITERAL_LENGTH);
});

if (length < 0)
{
printf("<unknown string literal>");
}
else
{
char dst[MAX_LITERAL_LENGTH];
convertUtf16ToUtf8ForPrinting(str, length, dst, MAX_LITERAL_LENGTH);
printf("\"%.50s%s\"", dst, length > 50 ? "..." : "");
}
}
#endif // DEBUG
14 changes: 1 addition & 13 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12279,19 +12279,7 @@ void Compiler::gtDispConst(GenTree* tree)
break;
}

constexpr int maxLiteralLength = 256;
char16_t str[maxLiteralLength] = {};
int len = info.compCompHnd->getStringLiteral(cnsStr->gtScpHnd, cnsStr->gtSconCPX, str, maxLiteralLength);
if (len < 0)
{
printf("<unknown string literal>");
}
else
{
char dst[maxLiteralLength];
convertUtf16ToUtf8ForPrinting(str, len, dst, maxLiteralLength);
printf("\"%.50s%s\"", dst, len > 50 ? "..." : "");
}
eePrintStringLiteral(cnsStr->gtScpHnd, cnsStr->gtSconCPX);
}
break;

Expand Down
Loading