From b860ff454d3c4ef06d263e1003af4c11056b24ac Mon Sep 17 00:00:00 2001 From: Nick Kamal Date: Thu, 21 Nov 2024 10:54:10 -0500 Subject: [PATCH] The changes reflect the feature request #16416 - part 2 of #20641 Adding cmdline option to specify string length to be printed. -Xtrace:methodstrarglen=[1-128] methodStrArgLen takes an unsigned integer value from 1 to 128 If no methodStrArgLen is specified, or is set to 0, the printed length is the default value of 32. Other invalid inputs result in the following: "Error processing trace option, detail: methodstrarglen takes an unsigned integer value from 0 to 128 Trace option unrecognized: -Xtrace:methodStrArgLen Error processing trace option: -Xtrace:methodStrArgLen= " There will be subsequent PRs for tests (part 3). Signed-off-by: Nick Kamal --- runtime/rastrace/method_trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/rastrace/method_trace.c b/runtime/rastrace/method_trace.c index 6f605e13415..39ca374a819 100644 --- a/runtime/rastrace/method_trace.c +++ b/runtime/rastrace/method_trace.c @@ -491,7 +491,7 @@ traceMethodArgObject(J9VMThread *thr, UDATA* arg0EA, char* cursor, UDATA length) J9InternalVMFunctions const * const vmFuncs = thr->javaVM->internalVMFunctions; char *stringArgUTF8 = vmFuncs->copyStringToUTF8WithMemAlloc(thr, object, J9_STR_NULL_TERMINATE_RESULT, " ", 2, stringArgBuffer, DEFAULT_BUFFER_LENGTH, NULL); - if(DEFAULT_STRING_LENGTH < strlen(stringArgUTF8)) { + 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)J9UTF8_LENGTH(stringArgUTF8), J9UTF8_DATA(stringArgUTF8));