Skip to content

Commit

Permalink
Update to print String arguments with Xtrace
Browse files Browse the repository at this point in the history
The changes reflect the feature request eclipse-openj9#16416.

Instead of printing the memory address for string arguments, print the actual string at max of 255 characters.

Closes: eclipse-openj9#16416
Signed-off-by: Nick Kamal<[email protected]>
  • Loading branch information
h3110n3rv3 committed Nov 18, 2024
1 parent efaa4f6 commit 6553cac
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion runtime/rastrace/method_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,19 @@ traceMethodArgObject(J9VMThread *thr, UDATA* arg0EA, char* cursor, UDATA length)
J9Class* clazz = J9OBJECT_CLAZZ(thr, object);
J9ROMClass * romClass = clazz->romClass;
J9UTF8* className = J9ROMCLASS_CLASSNAME(romClass);
J9JavaVM *vm = thr->javaVM;

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

J9InternalVMFunctions const * const vmFuncs = thr->javaVM->internalVMFunctions;
char *stringArgUTF8 = vmFuncs->copyStringToUTF8WithMemAlloc(thr, object, J9_STR_NULL_TERMINATE_RESULT, " ", 2, stringArgBuffer, J9_ARRAY_DIMENSION_LIMIT, NULL);
j9str_printf(PORTLIB, cursor, length, "%.*s@%.*s", (U_32)J9UTF8_LENGTH(className), J9UTF8_DATA(className), J9UTF8_LENGTH(stringArgUTF8), J9UTF8_DATA(stringArgUTF8));
}
/* TODO: handle arrays */

j9str_printf(PORTLIB, cursor, length, "%.*s@%p", (U_32)J9UTF8_LENGTH(className), J9UTF8_DATA(className), object);
//j9str_printf(PORTLIB, cursor, length, "%.*s@%p", (U_32)J9UTF8_LENGTH(className), J9UTF8_DATA(className), object);
}
}

Expand Down

0 comments on commit 6553cac

Please sign in to comment.