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
5 changes: 4 additions & 1 deletion src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2377,7 +2377,10 @@ class ICorStaticInfo
CORINFO_RESOLVED_TOKEN * pResolvedToken /* IN */) = 0;

// Returns (sub)string length and content (can be null for dynamic context)
// for given metaTOK and module, length `-1` means input is incorrect
// for given metaTOK and module, length `-1` means input is incorrect.
//
// Return value: The actual length of the (sub)string. Note that this may be larger
// than bufferSize, in which case only bufferSize characters are copied to buffer.
virtual int getStringLiteral (
CORINFO_MODULE_HANDLE module, /* IN */
unsigned metaTOK, /* IN */
Expand Down
10 changes: 6 additions & 4 deletions src/coreclr/jit/eeinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ void Compiler::eePrintObjectDescription(const char* prefix, CORINFO_OBJECT_HANDL
//
void Compiler::eePrintStringLiteral(CORINFO_MODULE_HANDLE module, unsigned token)
{
const int MAX_LITERAL_LENGTH = 256;
const int MAX_LITERAL_LENGTH = 50;
char16_t str[MAX_LITERAL_LENGTH] = {};
int length = -1;
eeRunFunctorWithSPMIErrorTrap([&]() {
Expand All @@ -718,9 +718,11 @@ void Compiler::eePrintStringLiteral(CORINFO_MODULE_HANDLE module, unsigned token
}
else
{
char dst[MAX_LITERAL_LENGTH];
convertUtf16ToUtf8ForPrinting(str, length, dst, MAX_LITERAL_LENGTH);
printf("\"%.50s%s\"", dst, length > 50 ? "..." : "");
char dst[MAX_LITERAL_LENGTH * 3 + 1];
// Truncate length to MAX_LITERAL_LENGTH since that's the maximum we copied into str
int truncatedLength = min(length, MAX_LITERAL_LENGTH);
convertUtf16ToUtf8ForPrinting(str, truncatedLength, dst, sizeof(dst));
printf("\"%s%s\"", dst, length > MAX_LITERAL_LENGTH ? "..." : "");
}
}
#endif // DEBUG
Loading