Skip to content

Commit

Permalink
Include indent buffer length in TR_Debug::printByteCodeStack
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Shipton <[email protected]>
  • Loading branch information
pshipton committed Nov 21, 2024
1 parent 708db6e commit dc29b6d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions runtime/compiler/runtime/MetaDataDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ extern "C" void jitBytecodePrintFunction(void *userData, char *format, ...)
}

void
TR_Debug::printByteCodeStack(int32_t parentStackIndex, uint16_t byteCodeIndex, char * indent)
TR_Debug::printByteCodeStack(int32_t parentStackIndex, uint16_t byteCodeIndex, char * indent, size_t bufLen)
{
#if defined(J9VM_OPT_JITSERVER)
if (_comp->isOutOfProcessCompilation() || _comp->isRemoteCompilation())
Expand All @@ -558,14 +558,20 @@ TR_Debug::printByteCodeStack(int32_t parentStackIndex, uint16_t byteCodeIndex, c
void *bcPrintFunc = (void *)jitBytecodePrintFunction;
if (parentStackIndex == -1)
{
sprintf(indent, " \\\\");
static const char indentString[] = " \\\\";
size_t indentSize = sizeof(indentString) - 1;
if (bufLen > indentSize)
{
strncpy(indent, indentString, indentSize + 1);
bufLen -= indentSize;
}
trfprintf(_file, "%s %s\n", indent, _comp->getCurrentMethod()->signature(comp()->trMemory(), heapAlloc));
ramMethod = (J9Method *)_comp->getCurrentMethod()->resolvedMethodAddress();
}
else
{
TR_InlinedCallSite & site = _comp->getInlinedCallSite(parentStackIndex);
printByteCodeStack(site._byteCodeInfo.getCallerIndex(), site._byteCodeInfo.getByteCodeIndex(), indent);
printByteCodeStack(site._byteCodeInfo.getCallerIndex(), site._byteCodeInfo.getByteCodeIndex(), indent, bufLen);
ramMethod = (J9Method *)site._methodInfo;
}

Expand All @@ -579,7 +585,13 @@ TR_Debug::printByteCodeStack(int32_t parentStackIndex, uint16_t byteCodeIndex, c
J9_CLASS_FROM_METHOD(ramMethod)->romClass,
J9_BYTECODE_START_FROM_RAM_METHOD(ramMethod),
byteCodeIndex, byteCodeIndex, flags, bcPrintFunc, this, indent);
sprintf(indent, "%s ", indent);
static const char indentString2[] = " ";
size_t indentSize2 = sizeof(indentString2) - 1;
size_t indentLen = strlen(indent);
if ((bufLen > indentSize2) && (indentLen < (bufLen - indentSize2)))
{
strncpy(indent, indentString2, indentSize2 + 1);
}
}
}

Expand Down

0 comments on commit dc29b6d

Please sign in to comment.