Skip to content

Commit

Permalink
The changes reflect the feature request eclipse-openj9#16416 - part 2…
Browse files Browse the repository at this point in the history
… of eclipse-openj9#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=<invalid input>
"

There will be subsequent PRs for tests (part 3).

Signed-off-by: Nick Kamal <[email protected]>
  • Loading branch information
h3110n3rv3 committed Nov 21, 2024
1 parent b860ff4 commit 619a8b7
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions runtime/rastrace/method_trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,36 +557,36 @@ omr_error_t
setMethodStrArgLength(J9JavaVM *vm, const char *str, BOOLEAN atRuntime)
{
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, takes an unsigned integer value from 1 to %d", MAX_STRING_LENGTH);
return OMR_ERROR_INTERNAL;
vaReportJ9VMCommandLineError(PORTLIB, "methodstrarglen takes an unsigned integer value from 0 to %d", MAX_STRING_LENGTH);
return OMR_ERROR_INTERNAL;
}

/**************************************************************************
Expand Down Expand Up @@ -696,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);
}
Expand Down

0 comments on commit 619a8b7

Please sign in to comment.