From 9f8b981bd4b1333f5c183150d4ad850ebd15c1ab Mon Sep 17 00:00:00 2001 From: Nick Kamal Date: Thu, 21 Nov 2024 07:34:25 -0500 Subject: [PATCH] The changes reflect the feature request #16416. Instead of printing the memory address for string arguments, print the actual string at max of 32 characters. There will be subsequent PRs for cmdline option for string length and tests. Closes: #16416 Signed-off-by: Nick Kamal --- runtime/rastrace/method_trace.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/runtime/rastrace/method_trace.c b/runtime/rastrace/method_trace.c index 6f06712e937..87b50bde8c3 100644 --- a/runtime/rastrace/method_trace.c +++ b/runtime/rastrace/method_trace.c @@ -30,7 +30,8 @@ #undef UT_MODULE_UNLOADED #include "ut_mt.h" -#define DEFAULT_STRING_LENGTH 128 +#define DEFAULT_BUFFER_LENGTH 128 +#define DEFAULT_STRING_LENGTH 32 static void hookRAMClassLoad(J9HookInterface** hook, UDATA eventNum, void* eventData, void* userData); static void traceMethodArgInt (J9VMThread *thr, UDATA* arg0EA, char* cursor, UDATA length, char* type); @@ -483,10 +484,10 @@ traceMethodArgObject(J9VMThread *thr, UDATA* arg0EA, char* cursor, UDATA length) if (clazz == J9VMJAVALANGSTRING_OR_NULL(vm)) { /* string arg */ - char stringArgBuffer[DEFAULT_STRING_LENGTH]; + char stringArgBuffer[DEFAULT_BUFFER_LENGTH]; J9InternalVMFunctions const * const vmFuncs = thr->javaVM->internalVMFunctions; - char *stringArgUTF8 = vmFuncs->copyStringToUTF8WithMemAlloc(thr, object, J9_STR_NULL_TERMINATE_RESULT, "", 0, stringArgBuffer, DEFAULT_STRING_LENGTH, NULL); + char *stringArgUTF8 = vmFuncs->copyStringToUTF8WithMemAlloc(thr, object, J9_STR_NULL_TERMINATE_RESULT, "", 0, stringArgBuffer, DEFAULT_BUFFER_LENGTH, NULL); if(DEFAULT_STRING_LENGTH < strlen(stringArgUTF8)) { j9str_printf(PORTLIB, cursor, length, "%.*s@%.32s...", (U_32)J9UTF8_LENGTH(className), J9UTF8_DATA(className), stringArgUTF8);