Skip to content

Commit

Permalink
Revert "Print actual String arguments with Xtrace part 1"
Browse files Browse the repository at this point in the history
This reverts commit c5ca003.
  • Loading branch information
h3110n3rv3 committed Dec 17, 2024
1 parent b81e09b commit 051633f
Showing 1 changed file with 14 additions and 29 deletions.
43 changes: 14 additions & 29 deletions runtime/rastrace/method_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,46 +477,31 @@ traceMethodArgObject(J9VMThread *thr, UDATA* arg0EA, char* cursor, UDATA length)
if (object == NULL) {
j9str_printf(PORTLIB, cursor, length, "null");
} else {
/* string arg */
J9Class *clazz = J9OBJECT_CLAZZ(thr, object);
J9Class* clazz = J9OBJECT_CLAZZ(thr, object);
J9ROMClass * romClass = clazz->romClass;
J9UTF8* className = J9ROMCLASS_CLASSNAME(romClass);
J9JavaVM *vm = thr->javaVM;
const unsigned int methodStrArgLength = ((RasGlobalStorage *)thr->javaVM->j9rasGlobalStorage)->methodStrArgLength;
unsigned int strArgLength = methodStrArgLength == 0 ? DEFAULT_STRING_LENGTH : methodStrArgLength;

if (clazz == J9VMJAVALANGSTRING_OR_NULL(vm)) {
/* string arg */
char stringArgBuffer[DEFAULT_BUFFER_LENGTH];

#define DEFAULT_STRING_LENGTH 32
J9InternalVMFunctions const * const vmFuncs = thr->javaVM->internalVMFunctions;
char *stringArgUTF8 = vmFuncs->copyStringToUTF8WithMemAlloc(thr, object, J9_STR_NULL_TERMINATE_RESULT, " ", 2, stringArgBuffer, DEFAULT_BUFFER_LENGTH, NULL);

char utf8Buffer[128];
UDATA utf8Length = 0;

char *utf8String = vm->internalVMFunctions->copyStringToUTF8WithMemAlloc(
thr,
object,
0,
"",
0,
utf8Buffer,
sizeof(utf8Buffer),
&utf8Length);

if (NULL == utf8String) {
j9str_printf(PORTLIB, cursor, length, "(String)<Memory allocation error>");
} else if (utf8Length > DEFAULT_STRING_LENGTH) {
j9str_printf(PORTLIB, cursor, length, "(String)\"%.*s\"...", (U_32)DEFAULT_STRING_LENGTH, utf8String);
if(strArgLength < strlen(stringArgUTF8)) {
j9str_printf(PORTLIB, cursor, length, "(String)%.*s...", (U_32)strArgLength, J9UTF8_DATA(stringArgUTF8));
} else {
j9str_printf(PORTLIB, cursor, length, "(String)\"%.*s\"", (U_32)utf8Length, utf8String);
j9str_printf(PORTLIB, cursor, length, "(String)%.*s", (U_32)J9UTF8_LENGTH(stringArgUTF8), J9UTF8_DATA(stringArgUTF8));
}

if (utf8Buffer != utf8String) {
j9mem_free_memory(utf8String);
if ((char*)stringArgBuffer != stringArgUTF8) {
j9mem_free_memory(stringArgUTF8);
}

#undef DEFAULT_STRING_LENGTH

} else {
/* TODO: handle arrays */

J9ROMClass *romClass = clazz->romClass;
J9UTF8 *className = J9ROMCLASS_CLASSNAME(romClass);
j9str_printf(PORTLIB, cursor, length, "%.*s@%p", (U_32)J9UTF8_LENGTH(className), J9UTF8_DATA(className), object);
}
}
Expand Down

0 comments on commit 051633f

Please sign in to comment.