diff --git a/runtime/rastrace/j9rastrace.h b/runtime/rastrace/j9rastrace.h index 9b1c08e47d8..40c41b338c9 100644 --- a/runtime/rastrace/j9rastrace.h +++ b/runtime/rastrace/j9rastrace.h @@ -48,13 +48,13 @@ extern "C" { * Keywords for options added by J9VM layer. * ============================================================================= */ -#define RAS_METHODS_KEYWORD "METHODS" -#define RAS_DEBUG_KEYWORD "DEBUG" -#define RAS_TRIGGER_KEYWORD "TRIGGER" -#define RAS_STACKDEPTH_KEYWORD "STACKDEPTH" -#define RAS_SLEEPTIME_KEYWORD "SLEEPTIME" -#define RAS_COMPRESSION_LEVEL_KEYWORD "STACKCOMPRESSIONLEVEL" -#define RAS_METHOD_STRING_LENGTH_KEYWORD "METHODSTRARGLEN" +#define RAS_METHODS_KEYWORD "METHODS" +#define RAS_DEBUG_KEYWORD "DEBUG" +#define RAS_TRIGGER_KEYWORD "TRIGGER" +#define RAS_STACKDEPTH_KEYWORD "STACKDEPTH" +#define RAS_SLEEPTIME_KEYWORD "SLEEPTIME" +#define RAS_COMPRESSION_LEVEL_KEYWORD "STACKCOMPRESSIONLEVEL" +#define RAS_METHOD_STRING_LENGTH_KEYWORD "METHODSTRARGLEN" /* * ====================================================================== diff --git a/runtime/rastrace/method_trace.c b/runtime/rastrace/method_trace.c index eca88af2ea9..6f605e13415 100644 --- a/runtime/rastrace/method_trace.c +++ b/runtime/rastrace/method_trace.c @@ -481,6 +481,8 @@ traceMethodArgObject(J9VMThread *thr, UDATA* arg0EA, char* cursor, UDATA length) 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 */ @@ -490,7 +492,7 @@ traceMethodArgObject(J9VMThread *thr, UDATA* arg0EA, char* cursor, UDATA length) char *stringArgUTF8 = vmFuncs->copyStringToUTF8WithMemAlloc(thr, object, J9_STR_NULL_TERMINATE_RESULT, " ", 2, stringArgBuffer, DEFAULT_BUFFER_LENGTH, NULL); if(DEFAULT_STRING_LENGTH < strlen(stringArgUTF8)) { - j9str_printf(PORTLIB, cursor, length, "(String)%.*s...", (U_32)DEFAULT_STRING_LENGTH, J9UTF8_DATA(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)); } diff --git a/runtime/rastrace/method_trigger.c b/runtime/rastrace/method_trigger.c index df4046d1e90..4430f05f3fe 100644 --- a/runtime/rastrace/method_trigger.c +++ b/runtime/rastrace/method_trigger.c @@ -59,6 +59,7 @@ static const StackTraceFormattingFunction stackTraceFormattingFunctions[] = { }; #define NUM_STACK_TRACE_FORMATTING_FUNCTIONS (sizeof(stackTraceFormattingFunctions) / sizeof(stackTraceFormattingFunctions[0])) +#define MAX_STRING_LENGTH 128 /************************************************************************** * name - rasSetTriggerTrace @@ -555,41 +556,37 @@ decimalString2Int(J9PortLibrary* portLibrary, const char *decString, I_32 signed omr_error_t setMethodStrArgLength(J9JavaVM *vm, const char *str, BOOLEAN atRuntime) { -#define MAX_STRING_LENGTH 128 - PORT_ACCESS_FROM_JAVAVM(vm); - int value, length; - omr_error_t rc = OMR_ERROR_NONE; - const char *p; + int value, length; + omr_error_t rc = OMR_ERROR_NONE; + const char *p; - if (getParmNumber(str) != 1) { - goto err; - } + if (getParmNumber(str) != 1) { + goto err; + } - p = getPositionalParm(1, str, &length); + p = getPositionalParm(1, str, &length); - if (length > 3) { - goto err; - } + if (length > 3) { + goto err; + } - value = decimalString2Int(PORTLIB, p, FALSE, &rc); - if (OMR_ERROR_NONE != rc) { - goto err; - } + value = decimalString2Int(PORTLIB, p, FALSE, &rc); + if (OMR_ERROR_NONE != rc) { + goto err; + } - if ((0 > value) || - (MAX_STRING_LENGTH < value)) { - goto err; - } + if ((0 > value) || + (MAX_STRING_LENGTH < value)) { + goto err; + } - RAS_GLOBAL_FROM_JAVAVM(methodStrArgLength,vm) = (unsigned int)value; - return OMR_ERROR_NONE; + RAS_GLOBAL_FROM_JAVAVM(methodStrArgLength,vm) = (unsigned int)value; + return OMR_ERROR_NONE; err: - vaReportJ9VMCommandLineError(PORTLIB, "methodstrarglen takes an unsigned integer value from 1 to %d", MAX_STRING_LENGTH); - return OMR_ERROR_INTERNAL; - -#undef MAX_STRING_LENGTH 128 + vaReportJ9VMCommandLineError(PORTLIB, takes an unsigned integer value from 1 to %d", MAX_STRING_LENGTH); + return OMR_ERROR_INTERNAL; } /************************************************************************** @@ -699,12 +696,12 @@ addTriggeredMethodSpec(J9VMThread *thr, const char *ptrMethodSpec, const struct } if (methodRule->entryAction != NULL && methodRule->entryAction->name != NULL - && j9_cmdla_stricmp((char *)methodRule->entryAction->name, "jstacktrace") == 0) { + && j9_cmdla_stricmp((char *)methodRule->entryAction->name, "jstacktrace") == 0) { /* set up the current method spec to be enabled for trace */ setMethod(thr->javaVM, ptrMethodSpec, FALSE); } if (methodRule->exitAction != NULL && methodRule->exitAction->name != NULL - && j9_cmdla_stricmp((char *)methodRule->exitAction->name, "jstacktrace") == 0) { + && j9_cmdla_stricmp((char *)methodRule->exitAction->name, "jstacktrace") == 0) { /* set up the current method spec to be enabled for trace */ setMethod(thr->javaVM, ptrMethodSpec, FALSE); }