Skip to content

Commit

Permalink
Revert "The changes reflect the feature request eclipse-openj9#16416
Browse files Browse the repository at this point in the history
…- part 2 of eclipse-openj9#20641"

This reverts commit 148a6de.
  • Loading branch information
h3110n3rv3 committed Dec 17, 2024
1 parent cb02324 commit 8986d11
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 35 deletions.
2 changes: 1 addition & 1 deletion runtime/oti/j9trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ typedef struct RasGlobalStorage {
void * traceMethodTable;
int stackdepth;
unsigned int stackCompressionLevel;
unsigned int methodStrArgLength;
unsigned int maxStringLength;
ConfigureTraceFunction configureTraceEngine;
#if defined(J9VM_OPT_CRIU_SUPPORT)
CRIURestoreInitializeTrace criuRestoreInitializeTrace;
Expand Down
8 changes: 4 additions & 4 deletions runtime/rastrace/j9rastrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extern "C" {
#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_MAX_STRING_LENGTH_KEYWORD "MAXSTRINGLENGTH"

/*
* ======================================================================
Expand Down Expand Up @@ -129,9 +129,9 @@ void rasTriggerMethod(J9VMThread *thr, J9Method *mb, I_32 entry, const TriggerPh
BOOLEAN matchMethod (RasMethodTable * methodTable, J9Method *method);
omr_error_t processTriggerMethodClause(OMR_VMThread *, char *, BOOLEAN atRuntime);
void doTriggerActionJstacktrace(OMR_VMThread *thr);
omr_error_t setStackDepth(J9JavaVM *thr, const char * value, BOOLEAN atRuntime);
omr_error_t setStackCompressionLevel(J9JavaVM * vm, const char *str, BOOLEAN atRuntime);
omr_error_t setMethodStrArgLength(J9JavaVM * vm, const char *str, BOOLEAN atRuntime);
omr_error_t setStackDepth(J9JavaVM *thr, const char *value, BOOLEAN atRuntime);
omr_error_t setStackCompressionLevel(J9JavaVM *vm, const char *str, BOOLEAN atRuntime);
omr_error_t setMaxStringLength(J9JavaVM *vm, const char *str, BOOLEAN atRuntime);

/*
* =============================================================================
Expand Down
4 changes: 1 addition & 3 deletions runtime/rastrace/method_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,6 @@ 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 */
Expand All @@ -492,7 +490,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)strArgLength, J9UTF8_DATA(stringArgUTF8));
j9str_printf(PORTLIB, cursor, length, "(String)%.*s...", (U_32)DEFAULT_STRING_LENGTH, J9UTF8_DATA(stringArgUTF8));
} else {
j9str_printf(PORTLIB, cursor, length, "(String)%.*s", (U_32)J9UTF8_LENGTH(stringArgUTF8), J9UTF8_DATA(stringArgUTF8));
}
Expand Down
48 changes: 22 additions & 26 deletions runtime/rastrace/method_trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ static const StackTraceFormattingFunction stackTraceFormattingFunctions[] = {
};

#define NUM_STACK_TRACE_FORMATTING_FUNCTIONS (sizeof(stackTraceFormattingFunctions) / sizeof(stackTraceFormattingFunctions[0]))
#define MAX_STRING_LENGTH 128

/**************************************************************************
* name - rasSetTriggerTrace
Expand Down Expand Up @@ -548,44 +547,37 @@ decimalString2Int(J9PortLibrary* portLibrary, const char *decString, I_32 signed
}

/**************************************************************************
* name - setMethodStrArgLength
* description - Set method string argument length
* parameters - thr, trace options, atRuntime flag
* name - setMaxStringLength
* description - Set max string length for arguments and return values
* parameters - vm, str - trace options, atRuntime flag
* returns - JNI return code
*************************************************************************/
omr_error_t
setMethodStrArgLength(J9JavaVM *vm, const char *str, BOOLEAN atRuntime)
setMaxStringLength(J9JavaVM *vm, const char *str, BOOLEAN atRuntime)
{
PORT_ACCESS_FROM_JAVAVM(vm);
int value, length;
int value = 0;
int length = 0;
omr_error_t rc = OMR_ERROR_NONE;
const char *p;
const char *param = NULL;

if (getParmNumber(str) != 1) {
if (1 != getParmNumber(str)) {
goto err;
}

p = getPositionalParm(1, str, &length);

if (length > 3) {
goto err;
}
param = getPositionalParm(1, str, &length);

value = decimalString2Int(PORTLIB, p, FALSE, &rc);
value = decimalString2Int(PORTLIB, param, FALSE, &rc);
if (OMR_ERROR_NONE != rc) {
goto err;
}

if ((0 > value) ||
(MAX_STRING_LENGTH < value)) {
goto err;
if ((0 <= value) && (value <= RAS_MAX_STRING_LENGTH_LIMIT)) {
RAS_GLOBAL_FROM_JAVAVM(maxStringLength, 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);
vaReportJ9VMCommandLineError(PORTLIB, "maxstringlength takes an integer value from 0 to %d", RAS_MAX_STRING_LENGTH_LIMIT);
return OMR_ERROR_INTERNAL;
}

Expand Down Expand Up @@ -695,13 +687,17 @@ addTriggeredMethodSpec(J9VMThread *thr, const char *ptrMethodSpec, const struct
ptr->next = methodRule;
}

if (methodRule->entryAction != NULL && methodRule->entryAction->name != NULL
&& j9_cmdla_stricmp((char *)methodRule->entryAction->name, "jstacktrace") == 0) {
if ((NULL != methodRule->entryAction)
&& (NULL != methodRule->entryAction->name)
&& (0 == j9_cmdla_stricmp((char *)methodRule->entryAction->name, "jstacktrace"))
) {
/* 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) {
if ((NULL != methodRule->exitAction)
&& (NULL != methodRule->exitAction->name)
&& (0 == j9_cmdla_stricmp((char *)methodRule->exitAction->name, "jstacktrace"))
) {
/* set up the current method spec to be enabled for trace */
setMethod(thr->javaVM, ptrMethodSpec, FALSE);
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/rastrace/trcengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const struct traceOption TRACE_OPTIONS[] =
{RAS_METHODS_KEYWORD, FALSE, setMethod},
{RAS_STACKDEPTH_KEYWORD, TRUE, setStackDepth},
{RAS_COMPRESSION_LEVEL_KEYWORD, TRUE, setStackCompressionLevel},
{RAS_METHOD_STRING_LENGTH_KEYWORD, FALSE, setMethodStrArgLength},
{RAS_MAX_STRING_LENGTH_KEYWORD, FALSE, setMaxStringLength},
};

#define NUMBER_OF_TRACE_OPTIONS (sizeof(TRACE_OPTIONS) / sizeof(struct traceOption))
Expand Down

0 comments on commit 8986d11

Please sign in to comment.