From eea476f7650136639799686fb2afe6310df9fb50 Mon Sep 17 00:00:00 2001 From: Nick Kamal Date: Wed, 27 Nov 2024 11:08:59 -0500 Subject: [PATCH] Print actual string arguments with -Xtrace (part 1) The changes reflect the feature request #16416. Print the actual string instead of address at max of 32 characters. Subsequent PRs: cmdline option for length (part 2) and tests (part 3). Signed-off-by: Nick Kamal --- runtime/rastrace/method_trace.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/runtime/rastrace/method_trace.c b/runtime/rastrace/method_trace.c index 679a7c58cbb..251af3c30e4 100644 --- a/runtime/rastrace/method_trace.c +++ b/runtime/rastrace/method_trace.c @@ -474,26 +474,24 @@ 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); J9JavaVM *vm = thr->javaVM; if (clazz == J9VMJAVALANGSTRING_OR_NULL(vm)) { - + /* string argument */ #define DEFAULT_STRING_LENGTH 32 - char utf8Buffer[128]; UDATA utf8Length = 0; char *utf8String = vm->internalVMFunctions->copyStringToUTF8WithMemAlloc( - thr, - object, - 0, - "", - 0, - utf8Buffer, - sizeof(utf8Buffer), - &utf8Length); + thr, + object, + 0, + "", + 0, + utf8Buffer, + sizeof(utf8Buffer), + &utf8Length); if (NULL == utf8String) { j9str_printf(PORTLIB, cursor, length, "(String)"); @@ -506,9 +504,7 @@ traceMethodArgObject(J9VMThread *thr, UDATA* arg0EA, char* cursor, UDATA length) if (utf8Buffer != utf8String) { j9mem_free_memory(utf8String); } - #undef DEFAULT_STRING_LENGTH - } else { /* TODO: handle arrays */