From 854931a5c526591ed8cbb429779b129cd2b3849a Mon Sep 17 00:00:00 2001 From: tajila Date: Fri, 15 Nov 2024 10:58:17 -0500 Subject: [PATCH] Add frametype info to iterateStackTrace callback Signed-off-by: tajila --- runtime/j9vm/j7vmi.c | 28 ++--- runtime/j9vm/javanextvmi.cpp | 2 +- runtime/jcl/common/jclexception.cpp | 8 +- runtime/oti/j9consts.h | 6 + runtime/oti/j9nonbuilder.h | 2 +- runtime/oti/vm_api.h | 4 +- runtime/rasdump/javadump.cpp | 6 +- runtime/rasdump/trigger.c | 170 ++++++++++++++-------------- runtime/vm/JFRConstantPoolTypes.hpp | 10 +- runtime/vm/exceptiondescribe.c | 12 +- 10 files changed, 130 insertions(+), 118 deletions(-) diff --git a/runtime/j9vm/j7vmi.c b/runtime/j9vm/j7vmi.c index b63a6a9e71c..61badcb38d1 100644 --- a/runtime/j9vm/j7vmi.c +++ b/runtime/j9vm/j7vmi.c @@ -500,16 +500,16 @@ JVM_FillInStackTrace(JNIEnv* env, jobject throwable) } /** - * Find the specified class in given class loader + * Find the specified class in given class loader * * @param env * @param className null-terminated class name string. * @param init initialize the class when set - * @param classLoader classloader of the class + * @param classLoader classloader of the class * @param throwError set to true in order to throw errors * @return Assumed to be a jclass. * - * Note: this call is implemented from info provided via CMVC 154874. + * Note: this call is implemented from info provided via CMVC 154874. */ jobject JNICALL JVM_FindClassFromClassLoader(JNIEnv* env, char* className, jboolean init, jobject classLoader, jboolean throwError) @@ -1425,7 +1425,7 @@ typedef struct GetStackTraceElementUserData { /* Return TRUE to keep iterating, FALSE to halt the walk. */ static UDATA -getStackTraceElementIterator(J9VMThread * vmThread, void * voidUserData, UDATA bytecodeOffset, J9ROMClass * romClass, J9ROMMethod * romMethod, J9UTF8 * fileName, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass) +getStackTraceElementIterator(J9VMThread * vmThread, void * voidUserData, UDATA bytecodeOffset, J9ROMClass * romClass, J9ROMMethod * romMethod, J9UTF8 * fileName, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass, UDATA frameType) { GetStackTraceElementUserData * userData = voidUserData; @@ -1784,7 +1784,7 @@ JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim) vmFuncs->setCurrentException(currentThread, J9VMCONSTANTPOOL_JAVALANGILLEGALARGUMENTEXCEPTION, NULL); } else { j9object_t componentTypeClassObject = J9_JNI_UNWRAP_REFERENCE(eltClass); - + if (NULL != componentTypeClassObject) { J9Class *componentTypeClass = J9VM_J9CLASS_FROM_HEAPCLASS(currentThread, componentTypeClassObject); @@ -1792,25 +1792,25 @@ JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim) UDATA count = dimensions; J9Class *componentArrayClass = componentTypeClass; BOOLEAN exceptionIsPending = FALSE; - + while ((count > 0) && (!exceptionIsPending)) { componentArrayClass = fetchArrayClass(currentThread, componentArrayClass); exceptionIsPending = (NULL != currentThread->currentException); count -= 1; } - + if (!exceptionIsPending) { /* make a copy of the dimensions array in non-object memory */ I_32 onStackDimensions[MAX_DIMENSIONS]; j9object_t directObject = NULL; UDATA i = 0; - + memset(onStackDimensions, 0, sizeof(onStackDimensions)); dimensionsArrayObject = J9_JNI_UNWRAP_REFERENCE(dim); for (i = 0; i < dimensions; i++) { onStackDimensions[i] = J9JAVAARRAYOFINT_LOAD(currentThread, dimensionsArrayObject, i); } - + directObject = vmFuncs->helperMultiANewArray(currentThread, (J9ArrayClass *)componentArrayClass, (UDATA)dimensions, onStackDimensions, J9_GC_ALLOCATE_OBJECT_NON_INSTRUMENTABLE); if (NULL != directObject) { result = vmFuncs->j9jni_createLocalRef(env, directObject); @@ -2435,11 +2435,11 @@ JVM_GetHostName(char* name, int namelen) * sun.jvm.args = */ /* - * Notes: - * Redirector has an implementation of JVM_InitAgentProperties. - * This method is still kept within the actual jvm dll in case that a launcher uses this jvm dll directly without going through the redirector. - * If this method need to be modified, the changes have to be synchronized for both versions. - */ + * Notes: + * Redirector has an implementation of JVM_InitAgentProperties. + * This method is still kept within the actual jvm dll in case that a launcher uses this jvm dll directly without going through the redirector. + * If this method need to be modified, the changes have to be synchronized for both versions. + */ jobject JNICALL JVM_InitAgentProperties(JNIEnv *env, jobject agent_props) { diff --git a/runtime/j9vm/javanextvmi.cpp b/runtime/j9vm/javanextvmi.cpp index 92491ed655d..d9028733e00 100644 --- a/runtime/j9vm/javanextvmi.cpp +++ b/runtime/j9vm/javanextvmi.cpp @@ -78,7 +78,7 @@ typedef struct GetStackTraceElementUserData { } GetStackTraceElementUserData; static UDATA -getStackTraceElementIterator(J9VMThread *vmThread, void *voidUserData, UDATA bytecodeOffset, J9ROMClass *romClass, J9ROMMethod *romMethod, J9UTF8 *fileName, UDATA lineNumber, J9ClassLoader *classLoader, J9Class* ramClass) +getStackTraceElementIterator(J9VMThread *vmThread, void *voidUserData, UDATA bytecodeOffset, J9ROMClass *romClass, J9ROMMethod *romMethod, J9UTF8 *fileName, UDATA lineNumber, J9ClassLoader *classLoader, J9Class* ramClass, UDATA frameType) { UDATA result = J9_STACKWALK_STOP_ITERATING; diff --git a/runtime/jcl/common/jclexception.cpp b/runtime/jcl/common/jclexception.cpp index eec34144aca..57958a737eb 100644 --- a/runtime/jcl/common/jclexception.cpp +++ b/runtime/jcl/common/jclexception.cpp @@ -39,7 +39,7 @@ extern "C" { static void setStackTraceElementFields(J9VMThread *vmThread, j9object_t element, J9ClassLoader *classLoader); #endif /* JAVA_SPEC_VERSION >= 11 */ -static UDATA getStackTraceIterator(J9VMThread * vmThread, void * voidUserData, UDATA bytecodeOffset, J9ROMClass * romClass, J9ROMMethod * romMethod, J9UTF8 * fileName, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass); +static UDATA getStackTraceIterator(J9VMThread * vmThread, void * voidUserData, UDATA bytecodeOffset, J9ROMClass * romClass, J9ROMMethod * romMethod, J9UTF8 * fileName, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass, UDATA frameType); /** * Saves enough context into the StackTraceElement to allow printing later. For @@ -91,7 +91,7 @@ setStackTraceElementSource(J9VMThread* vmThread, j9object_t stackTraceElement, J static UDATA -getStackTraceIterator(J9VMThread * vmThread, void * voidUserData, UDATA bytecodeOffset, J9ROMClass * romClass, J9ROMMethod * romMethod, J9UTF8 * fileName, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass) +getStackTraceIterator(J9VMThread * vmThread, void * voidUserData, UDATA bytecodeOffset, J9ROMClass * romClass, J9ROMMethod * romMethod, J9UTF8 * fileName, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass, UDATA frameType) { J9GetStackTraceUserData *userData = (J9GetStackTraceUserData*)voidUserData; J9JavaVM * vm = vmThread->javaVM; @@ -301,7 +301,7 @@ getStackTraceIterator(J9VMThread * vmThread, void * voidUserData, UDATA bytecode return rc; } -J9IndexableObject * +J9IndexableObject * getStackTrace(J9VMThread * vmThread, j9object_t * exceptionAddr, UDATA pruneConstructors) { J9JavaVM * vm = vmThread->javaVM; @@ -332,7 +332,7 @@ getStackTrace(J9VMThread * vmThread, j9object_t * exceptionAddr, UDATA pruneCons if (arrayClass == NULL) { /* the first class in vm->arrayROMClasses is the array class for Objects */ arrayClass = vmFuncs->internalCreateArrayClass(vmThread, - (J9ROMArrayClass *) J9ROMIMAGEHEADER_FIRSTCLASS(vm->arrayROMClasses), + (J9ROMArrayClass *) J9ROMIMAGEHEADER_FIRSTCLASS(vm->arrayROMClasses), elementClass); if (arrayClass == NULL) { /* exception is pending from the call */ diff --git a/runtime/oti/j9consts.h b/runtime/oti/j9consts.h index 01dc286b14d..9715affa6b9 100644 --- a/runtime/oti/j9consts.h +++ b/runtime/oti/j9consts.h @@ -927,6 +927,12 @@ extern "C" { #define J9_JAVA_NATIVE 0x100 #define J9_JAVA_STATIC 0x8 +/* Stack walker frame Types */ +#define J9VM_STACK_FRAME_INTERPRETER 0 +#define J9VM_STACK_FRAME_JIT 1 +#define J9VM_STACK_FRAME_JIT_INLINE 2 +#define J9VM_STACK_FRAME_NATIVE 3 + /* JFR event types */ #define J9JFR_EVENT_TYPE_EXECUTION_SAMPLE 0 diff --git a/runtime/oti/j9nonbuilder.h b/runtime/oti/j9nonbuilder.h index c0b461cf56c..17b1017f190 100644 --- a/runtime/oti/j9nonbuilder.h +++ b/runtime/oti/j9nonbuilder.h @@ -4981,7 +4981,7 @@ typedef struct J9InternalVMFunctions { #if defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING) void ( *cleanUpClassLoader)(struct J9VMThread *vmThread, struct J9ClassLoader* classLoader) ; #endif /* defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING) */ - UDATA ( *iterateStackTrace)(struct J9VMThread * vmThread, j9object_t* exception, UDATA (*callback) (struct J9VMThread * vmThread, void * userData, UDATA bytecodeOffset, struct J9ROMClass * romClass, struct J9ROMMethod * romMethod, J9UTF8 * fileName, UDATA lineNumber, struct J9ClassLoader* classLoader, struct J9Class* ramClass), void * userData, UDATA pruneConstructors, UDATA skipHiddenFrames) ; + UDATA ( *iterateStackTrace)(struct J9VMThread * vmThread, j9object_t* exception, UDATA (*callback) (struct J9VMThread * vmThread, void * userData, UDATA bytecodeOffset, struct J9ROMClass * romClass, struct J9ROMMethod * romMethod, J9UTF8 * fileName, UDATA lineNumber, struct J9ClassLoader* classLoader, struct J9Class* ramClass, UDATA frameType), void * userData, UDATA pruneConstructors, UDATA skipHiddenFrames) ; char* ( *getNPEMessage)(struct J9NPEMessageData *npeMsgData); void ( *internalReleaseVMAccessNoMutex)(struct J9VMThread * vmThread) ; struct J9HookInterface** ( *getVMHookInterface)(struct J9JavaVM* vm) ; diff --git a/runtime/oti/vm_api.h b/runtime/oti/vm_api.h index 735c46cb990..509008e9c3a 100644 --- a/runtime/oti/vm_api.h +++ b/runtime/oti/vm_api.h @@ -858,7 +858,7 @@ internalExceptionDescribe(J9VMThread *vmThread); * @return UDATA */ UDATA -iterateStackTrace(J9VMThread * vmThread, j9object_t* exception, UDATA (*callback) (J9VMThread * vmThread, void * userData, UDATA bytecodeOffset, J9ROMClass * romClass, J9ROMMethod * romMethod, J9UTF8 * fileName, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass), void * userData, UDATA pruneConstructors, UDATA skipHiddenFrames); +iterateStackTrace(J9VMThread * vmThread, j9object_t* exception, UDATA (*callback) (J9VMThread * vmThread, void * userData, UDATA bytecodeOffset, J9ROMClass * romClass, J9ROMMethod * romMethod, J9UTF8 * fileName, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass, UDATA frameType), void * userData, UDATA pruneConstructors, UDATA skipHiddenFrames); /** * @brief @@ -881,7 +881,7 @@ iterateStackTrace(J9VMThread * vmThread, j9object_t* exception, UDATA (*callba * @return UDATA */ UDATA -iterateStackTraceImpl(J9VMThread * vmThread, j9object_t* exception, UDATA (*callback) (J9VMThread * vmThread, void * userData, UDATA bytecodeOffset, J9ROMClass * romClass, J9ROMMethod * romMethod, J9UTF8 * fileName, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass), void * userData, UDATA pruneConstructors, UDATA skipHiddenFrames, UDATA sizeOfWalkstateCache, BOOLEAN exceptionIsJavaObject); +iterateStackTraceImpl(J9VMThread * vmThread, j9object_t* exception, UDATA (*callback) (J9VMThread * vmThread, void * userData, UDATA bytecodeOffset, J9ROMClass * romClass, J9ROMMethod * romMethod, J9UTF8 * fileName, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass, UDATA frameType), void * userData, UDATA pruneConstructors, UDATA skipHiddenFrames, UDATA sizeOfWalkstateCache, BOOLEAN exceptionIsJavaObject); /* ---------------- exceptionsupport.c ---------------- */ diff --git a/runtime/rasdump/javadump.cpp b/runtime/rasdump/javadump.cpp index 6843a903469..655de871553 100644 --- a/runtime/rasdump/javadump.cpp +++ b/runtime/rasdump/javadump.cpp @@ -86,7 +86,7 @@ /* Callback Function prototypes */ UDATA writeFrameCallBack (J9VMThread* vmThread, J9StackWalkState* state); -UDATA writeExceptionFrameCallBack (J9VMThread* vmThread, void* userData, UDATA bytecodeOffset, J9ROMClass* romClass, J9ROMMethod* romMethod, J9UTF8* sourceFile, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass); +UDATA writeExceptionFrameCallBack (J9VMThread* vmThread, void* userData, UDATA bytecodeOffset, J9ROMClass* romClass, J9ROMMethod* romMethod, J9UTF8* sourceFile, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass, UDATA frameType); void writeLoaderCallBack (void* classLoader, void* userData); void writeLibrariesCallBack (void* classLoader, void* userData); void writeClassesCallBack (void* classLoader, void* userData); @@ -240,7 +240,7 @@ private : /* Allow the callback functions access */ friend UDATA writeFrameCallBack (J9VMThread* vmThread, J9StackWalkState* state); - friend UDATA writeExceptionFrameCallBack (J9VMThread* vmThread, void* userData, UDATA bytecodeOffset, J9ROMClass* romClass, J9ROMMethod* romMethod, J9UTF8* sourceFile, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass); + friend UDATA writeExceptionFrameCallBack (J9VMThread* vmThread, void* userData, UDATA bytecodeOffset, J9ROMClass* romClass, J9ROMMethod* romMethod, J9UTF8* sourceFile, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass, UDATA frameType); friend void writeLoaderCallBack (void* classLoader, void* userData); friend void writeLibrariesCallBack (void* classLoader, void* userData); friend void writeClassesCallBack (void* classLoader, void* userData); @@ -5757,7 +5757,7 @@ writeFrameCallBack(J9VMThread* vmThread, J9StackWalkState* state) } UDATA -writeExceptionFrameCallBack(J9VMThread* vmThread, void* userData, UDATA bytecodeOffset, J9ROMClass* romClass, J9ROMMethod* romMethod, J9UTF8* sourceFile, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass) +writeExceptionFrameCallBack(J9VMThread* vmThread, void* userData, UDATA bytecodeOffset, J9ROMClass* romClass, J9ROMMethod* romMethod, J9UTF8* sourceFile, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass, UDATA frameType) { JavaCoreDumpWriter *jcdw = (JavaCoreDumpWriter *)((J9StackWalkState*)userData)->userData1; return jcdw->writeExceptionFrame(userData, romClass, romMethod, sourceFile, lineNumber); diff --git a/runtime/rasdump/trigger.c b/runtime/rasdump/trigger.c index 29f40d22a21..302afa02c76 100644 --- a/runtime/rasdump/trigger.c +++ b/runtime/rasdump/trigger.c @@ -92,7 +92,7 @@ static void rasDumpHookAllocationThreshold(J9HookInterface** hookInterface, UDAT static void rasDumpHookSlowExclusive (J9HookInterface** hookInterface, UDATA eventNum, void* eventData, void* userData); static void rasDumpHookThreadStart (J9HookInterface** hookInterface, UDATA eventNum, void* eventData, void* userData); static void rasDumpHookExceptionDescribe (J9HookInterface** hookInterface, UDATA eventNum, void* eventData, void* userData); -#if (defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)) +#if (defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)) static void rasDumpHookClassesUnload (J9HookInterface** hookInterface, UDATA eventNum, void* eventData, void* userData); #endif /* J9VM_GC_DYNAMIC_CLASS_UNLOADING */ static void rasDumpHookVmShutdown (J9HookInterface** hookInterface, UDATA eventNum, void* eventData, void* userData); @@ -126,7 +126,7 @@ struct ExceptionStackFrame }; static UDATA -countExceptionStackFrame(J9VMThread *vmThread, void *userData, UDATA bytecodeOffset, J9ROMClass *romClass, J9ROMMethod *romMethod, J9UTF8 *fileName, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass) +countExceptionStackFrame(J9VMThread *vmThread, void *userData, UDATA bytecodeOffset, J9ROMClass *romClass, J9ROMMethod *romMethod, J9UTF8 *fileName, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass, UDATA frameType) { struct ExceptionStackFrame *frame = (struct ExceptionStackFrame *) userData; @@ -142,10 +142,10 @@ countExceptionStackFrame(J9VMThread *vmThread, void *userData, UDATA bytecodeOff /** * Multiply the given 'val' by a suffix character. Supports 'k' and 'm'. - * + * * @param[in/out] val - value to update * @param[in] suffix - suffix character to process - * + * * @return one on success, zero on failure */ static UDATA multiplyBySuffix(UDATA *val, char suffix) @@ -160,17 +160,17 @@ static UDATA multiplyBySuffix(UDATA *val, char suffix) *val *= 1024 * 1024; return 1; } - + return 0; } /** * Parse an allocation range of the form "#5m" or "#5m..6m". - * + * * @param[in] range - string containing the range * @param[out] min - lower bound of the range * @param[out] max - upper bound of the range (optional). - * + * * @return zero on failure, one on success. */ UDATA @@ -180,7 +180,7 @@ parseAllocationRange(char *range, UDATA *min, UDATA *max) return 0; } range++; - + if (scan_udata(&range, min) != 0) { /* No matching numeric value */ return 0; @@ -188,7 +188,7 @@ parseAllocationRange(char *range, UDATA *min, UDATA *max) if (multiplyBySuffix(min, *range)) { range++; } - + if (try_scan(&range, "..")) { if (scan_udata(&range, max) != 0) { /* No matching numeric value */ @@ -198,11 +198,11 @@ parseAllocationRange(char *range, UDATA *min, UDATA *max) } else { *max = UDATA_MAX; } - + if (*min > *max) { return 0; } - + return 1; } @@ -234,13 +234,13 @@ matchesObjectAllocationFilter(J9RASdumpEventData *eventData, char *filter) /* No matching numeric value */ return J9RAS_DUMP_NO_MATCH; } - + /* Convert the filter range to two numbers */ fltPtr = fltText; if (!parseAllocationRange(fltPtr, &fltValueMin, &fltValueMax)) { return J9RAS_DUMP_NO_MATCH; } - + /* Do the range check */ if (msgValue >= fltValueMin && msgValue <= fltValueMax) { return J9RAS_DUMP_MATCH; @@ -275,10 +275,10 @@ matchesSlowExclusiveEnterFilter(J9RASdumpEventData *eventData, char *filter) /* convert the filter value to a number */ fltPtr = fltText; if (*fltPtr == '#') { - /* Skip over the leading #, if any. See defect 196215, as well as allowing a leading # (as documented) we are + /* Skip over the leading #, if any. See defect 196215, as well as allowing a leading # (as documented) we are * deliberately preserving the previous behaviour, which allowed the user to specify filter=ms, without the # */ - fltPtr++; + fltPtr++; } if (scan_idata(&fltPtr, &fltValue) != 0) { /* No matching numeric value */ @@ -303,7 +303,7 @@ matchesVMShutdownFilter(J9RASdumpEventData *eventData, char *filter) { char *message = eventData->detailData; IDATA value; - + /* Numeric range comparison? */ if (*message != '#') { return J9RAS_DUMP_NO_MATCH; @@ -322,7 +322,7 @@ matchesVMShutdownFilter(J9RASdumpEventData *eventData, char *filter) /* Match to number ranges encoded in filter string */ while (try_scan(&filter, "#")) { IDATA lhs, rhs; - + scan_idata(&filter, &lhs); if (try_scan(&filter, "..")) { @@ -358,7 +358,7 @@ matchesExceptionFilter(J9VMThread *vmThread, J9RASdumpEventData *eventData, UDAT char *hashSignInFilter = NULL; char *stackOffsetFilter = NULL; struct ExceptionStackFrame throwSite; - + throwSite.romClass = NULL; throwSite.romMethod = NULL; throwSite.callStackOffset = 0; @@ -396,7 +396,7 @@ matchesExceptionFilter(J9VMThread *vmThread, J9RASdumpEventData *eventData, UDAT J9UTF8 *exceptionClassName = J9ROMCLASS_CLASSNAME(J9OBJECT_CLAZZ(vmThread, exception)->romClass); J9UTF8 *throwClassName = J9ROMCLASS_CLASSNAME(throwSite.romClass); J9UTF8 *throwMethodName = J9ROMMETHOD_NAME(throwSite.romMethod); - + if (throwClassName && throwMethodName) { if (stackOffsetFilter) { buflen = J9UTF8_LENGTH(exceptionClassName) + J9UTF8_LENGTH(throwClassName) + J9UTF8_LENGTH(throwMethodName) + strlen(stackOffsetFilter) + 3; @@ -437,15 +437,15 @@ matchesExceptionFilter(J9VMThread *vmThread, J9RASdumpEventData *eventData, UDAT if (buf != NULL) { j9mem_free_memory(buf); } - return retCode; + return retCode; } } - + if (buf != NULL) { j9mem_free_memory(buf); buf = NULL; buflen = 0; - } + } if (subFilter && parseWildcard(subFilter, strlen(subFilter), &needleString, &needleLength, &matchFlag) == 0) { if (eventData->exceptionRef && *eventData->exceptionRef) { @@ -480,16 +480,16 @@ matchesFilter(J9VMThread *vmThread, J9RASdumpEventData *eventData, UDATA eventFl /* This comes before the default filter because object allocation MUST have a filter */ return matchesObjectAllocationFilter(eventData, filter); } - - /* For exception specific events the filter and subfilter default(null) matches to all + + /* For exception specific events the filter and subfilter default(null) matches to all * For non exception specific events the filter default(null) matches to all - */ + */ if (((0 != (eventFlags & J9RAS_DUMP_EXCEPTION_EVENT_GROUP)) && NULL == filter && NULL == subFilter) || ((0 == (eventFlags & J9RAS_DUMP_EXCEPTION_EVENT_GROUP)) && NULL == filter)) { return J9RAS_DUMP_MATCH; } - + if (eventFlags & J9RAS_DUMP_ON_SLOW_EXCLUSIVE_ENTER) { return matchesSlowExclusiveEnterFilter(eventData, filter); } else if (eventFlags & J9RAS_DUMP_ON_VM_SHUTDOWN) { @@ -497,7 +497,7 @@ matchesFilter(J9VMThread *vmThread, J9RASdumpEventData *eventData, UDATA eventFl } else if (0 != (eventFlags & (J9RAS_DUMP_EXCEPTION_EVENT_GROUP | J9RAS_DUMP_ON_CLASS_LOAD))) { return matchesExceptionFilter(vmThread, eventData, eventFlags, filter, subFilter); } - + return J9RAS_DUMP_NO_MATCH; } @@ -766,7 +766,7 @@ unwindAfterDump(struct J9JavaVM *vm, struct J9RASdumpContext *context, UDATA sta * len [in] - length of supplied buffer * reqLen [out] - length of buffer required, if expansion would have overflowed buf * now [in] - current time - * + * * Returns: OMR_ERROR_NONE, OMR_ERROR_INTERNAL, OMR_ERROR_OUT_OF_NATIVE_MEMORY */ omr_error_t @@ -783,14 +783,14 @@ dumpLabel(struct J9JavaVM *vm, J9RASdumpAgent *agent, J9RASdumpContext *context, if (NULL == dump_storage) { return OMR_ERROR_INTERNAL; } - + /* lock access to the tokens */ omrthread_monitor_enter(dump_storage->dumpLabelTokensMutex); stringTokens = dump_storage->dumpLabelTokens; j9str_set_time_tokens(stringTokens, now); - + seqNum += 1; /* Atomicity guaranteed as we are inside the dumpLabelTokensMutex */ if (j9str_set_token(PORTLIB, stringTokens, "seq", "%04u", seqNum)) { @@ -861,7 +861,7 @@ triggerOneOffDump(struct J9JavaVM *vm, char *optionString, char *caller, char *f if ( kind >= 0 ) { J9RASdumpContext context; J9RASdumpEventData eventData; - + /* we lock the dump configuration here so that the agent and setting queues can't be * changed underneath us while we're producing the dumps */ @@ -875,7 +875,7 @@ triggerOneOffDump(struct J9JavaVM *vm, char *optionString, char *caller, char *f context.dumpList = fileName; context.dumpListSize = fileNameLength; context.dumpListIndex = 0; - + eventData.detailData = caller; if (caller != NULL) { eventData.detailLength = strlen(caller); @@ -883,7 +883,7 @@ triggerOneOffDump(struct J9JavaVM *vm, char *optionString, char *caller, char *f eventData.detailLength = 0; } eventData.exceptionRef = NULL; - + retVal = createAndRunOneOffDumpAgent(vm,&context,kind,optionString); /* Remove the trailing tab added to the filename as a separator, it's only @@ -948,7 +948,7 @@ triggerDumpAgents(struct J9JavaVM *vm, struct J9VMThread *self, UDATA eventFlags if (detailLength > J9_MAX_DUMP_DETAIL_LENGTH) { detailLength = J9_MAX_DUMP_DETAIL_LENGTH; } - + strncpy(detailBuf, detailData, detailLength); detailBuf[detailLength] = '\0'; @@ -1178,15 +1178,15 @@ rasDumpEnableHooks(J9JavaVM *vm, UDATA eventFlags) /** - * rasDumpFlushHooks() - enable hooks for events that were postponed from the initial dump agent + * rasDumpFlushHooks() - enable hooks for events that were postponed from the initial dump agent * initialization. There are now two phases: GC event hooks are enabled at TRACE_ENGINE_INITIALIZED, * and thread event hooks are enabled at VM_INITIALIZATION_COMPLETE. See CMVC 199853 and CMVC 200360. - * + * * @param[in] vm - pointer to J9JavaVM structure * @param[in] stage - VM initialization stage * @return void */ -void +void rasDumpFlushHooks(J9JavaVM *vm, IDATA stage) { UDATA* postponeHooks = GLOBAL_DATA(rasDumpPostponeHooks); @@ -1216,9 +1216,9 @@ rasDumpHookVmInit(J9HookInterface** hookInterface, UDATA eventNum, void* eventDa J9VMThread* vmThread = data->vmThread; vmThread->javaVM->j9rasDumpFunctions->triggerDumpAgents( - vmThread->javaVM, - vmThread, - J9RAS_DUMP_ON_VM_STARTUP, + vmThread->javaVM, + vmThread, + J9RAS_DUMP_ON_VM_STARTUP, NULL); } @@ -1240,9 +1240,9 @@ rasDumpHookVmShutdown(J9HookInterface** hookInterface, UDATA eventNum, void* eve dumpData.exceptionRef = NULL; vmThread->javaVM->j9rasDumpFunctions->triggerDumpAgents( - vmThread->javaVM, - vmThread, - J9RAS_DUMP_ON_VM_SHUTDOWN, + vmThread->javaVM, + vmThread, + J9RAS_DUMP_ON_VM_SHUTDOWN, &dumpData); } @@ -1261,9 +1261,9 @@ rasDumpHookClassLoad(J9HookInterface** hookInterface, UDATA eventNum, void* even dumpData.exceptionRef = NULL; vmThread->javaVM->j9rasDumpFunctions->triggerDumpAgents( - vmThread->javaVM, - vmThread, - J9RAS_DUMP_ON_CLASS_LOAD, + vmThread->javaVM, + vmThread, + J9RAS_DUMP_ON_CLASS_LOAD, &dumpData); } @@ -1288,9 +1288,9 @@ rasDumpHookExceptionThrow(J9HookInterface** hookInterface, UDATA eventNum, void* dumpData.exceptionRef = (j9object_t*) globalRef; vm->j9rasDumpFunctions->triggerDumpAgents( - vm, - vmThread, - J9RAS_DUMP_ON_EXCEPTION_THROW, + vm, + vmThread, + J9RAS_DUMP_ON_EXCEPTION_THROW, &dumpData); data->exception = *((j9object_t*) globalRef); @@ -1318,9 +1318,9 @@ rasDumpHookExceptionCatch(J9HookInterface** hookInterface, UDATA eventNum, void* dumpData.exceptionRef = (j9object_t*) globalRef; vm->j9rasDumpFunctions->triggerDumpAgents( - vm, - vmThread, - J9RAS_DUMP_ON_EXCEPTION_CATCH, + vm, + vmThread, + J9RAS_DUMP_ON_EXCEPTION_CATCH, &dumpData); data->exception = *((j9object_t*) globalRef); @@ -1336,9 +1336,9 @@ rasDumpHookThreadStart(J9HookInterface** hookInterface, UDATA eventNum, void* ev J9VMThread* vmThread = data->currentThread; vmThread->javaVM->j9rasDumpFunctions->triggerDumpAgents( - vmThread->javaVM, - vmThread, - J9RAS_DUMP_ON_THREAD_START, + vmThread->javaVM, + vmThread, + J9RAS_DUMP_ON_THREAD_START, NULL); } @@ -1350,9 +1350,9 @@ rasDumpHookThreadEnd(J9HookInterface** hookInterface, UDATA eventNum, void* even J9VMThread* vmThread = data->currentThread; vmThread->javaVM->j9rasDumpFunctions->triggerDumpAgents( - vmThread->javaVM, - vmThread, - J9RAS_DUMP_ON_THREAD_END, + vmThread->javaVM, + vmThread, + J9RAS_DUMP_ON_THREAD_END, NULL); } @@ -1364,9 +1364,9 @@ rasDumpHookMonitorContendedEnter(J9HookInterface** hookInterface, UDATA eventNum J9VMThread* vmThread = data->currentThread; vmThread->javaVM->j9rasDumpFunctions->triggerDumpAgents( - vmThread->javaVM, - vmThread, - J9RAS_DUMP_ON_THREAD_BLOCKED, + vmThread->javaVM, + vmThread, + J9RAS_DUMP_ON_THREAD_BLOCKED, NULL); } @@ -1391,8 +1391,8 @@ rasDumpHookExceptionDescribe(J9HookInterface** hookInterface, UDATA eventNum, vo vm->j9rasDumpFunctions->triggerDumpAgents( vm, - vmThread, - J9RAS_DUMP_ON_EXCEPTION_DESCRIBE, + vmThread, + J9RAS_DUMP_ON_EXCEPTION_DESCRIBE, &dumpData); data->exception = *((j9object_t*) globalRef); @@ -1408,7 +1408,7 @@ rasDumpHookGCInitialized(J9HookInterface** hookInterface, UDATA eventNum, void* J9VMThread* vmThread = (J9VMThread*) data->currentThread->_language_vmthread; J9JavaVM *vm = vmThread->javaVM; RasDumpGlobalStorage *dumpGlobal = vm->j9rasdumpGlobalStorage; - + setAllocationThreshold(vmThread, dumpGlobal->allocationRangeMin, dumpGlobal->allocationRangeMax); } @@ -1466,9 +1466,9 @@ rasDumpHookAllocationThreshold(J9HookInterface** hookInterface, UDATA eventNum, dumpData.exceptionRef = NULL; vmThread->javaVM->j9rasDumpFunctions->triggerDumpAgents( - vmThread->javaVM, - vmThread, - J9RAS_DUMP_ON_OBJECT_ALLOCATION, + vmThread->javaVM, + vmThread, + J9RAS_DUMP_ON_OBJECT_ALLOCATION, &dumpData); data->object = POP_OBJECT_IN_SPECIAL_FRAME(vmThread); @@ -1493,9 +1493,9 @@ rasDumpHookSlowExclusive(J9HookInterface** hookInterface, UDATA eventNum, void* dumpData.exceptionRef = NULL; vmThread->javaVM->j9rasDumpFunctions->triggerDumpAgents( - vmThread->javaVM, - vmThread, - J9RAS_DUMP_ON_SLOW_EXCLUSIVE_ENTER, + vmThread->javaVM, + vmThread, + J9RAS_DUMP_ON_SLOW_EXCLUSIVE_ENTER, &dumpData); } @@ -1507,14 +1507,14 @@ rasDumpHookGlobalGcStart(J9HookInterface** hookInterface, UDATA eventNum, void* J9VMThread* vmThread = (J9VMThread *)data->currentThread->_language_vmthread; vmThread->javaVM->j9rasDumpFunctions->triggerDumpAgents( - vmThread->javaVM, - vmThread, - J9RAS_DUMP_ON_GLOBAL_GC, + vmThread->javaVM, + vmThread, + J9RAS_DUMP_ON_GLOBAL_GC, NULL); } -#if (defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)) +#if (defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)) static void rasDumpHookClassesUnload(J9HookInterface** hookInterface, UDATA eventNum, void* eventData, void* userData) { @@ -1522,9 +1522,9 @@ rasDumpHookClassesUnload(J9HookInterface** hookInterface, UDATA eventNum, void* J9VMThread* vmThread = data->currentThread; vmThread->javaVM->j9rasDumpFunctions->triggerDumpAgents( - vmThread->javaVM, - vmThread, - J9RAS_DUMP_ON_CLASS_UNLOAD, + vmThread->javaVM, + vmThread, + J9RAS_DUMP_ON_CLASS_UNLOAD, NULL); } #endif /* J9VM_GC_DYNAMIC_CLASS_UNLOADING */ @@ -1539,26 +1539,26 @@ rasDumpHookExceptionSysthrow(J9HookInterface** hookInterface, UDATA eventNum, vo J9JavaVM * vm = vmThread->javaVM; J9Object* exception = data->exception; jobject globalRef; - + globalRef = vm->internalVMFunctions->j9jni_createGlobalRef((JNIEnv *) vmThread, exception, JNI_FALSE); if (globalRef != NULL) { J9UTF8* className = J9ROMCLASS_CLASSNAME(J9OBJECT_CLAZZ(vmThread, exception)->romClass); - + dumpData.detailLength = J9UTF8_LENGTH(className); dumpData.detailData = (char *)J9UTF8_DATA(className); dumpData.exceptionRef = (J9Object **) globalRef; - + vm->j9rasDumpFunctions->triggerDumpAgents( - vm, - vmThread, - J9RAS_DUMP_ON_EXCEPTION_SYSTHROW, + vm, + vmThread, + J9RAS_DUMP_ON_EXCEPTION_SYSTHROW, &dumpData); - + data->exception = *((J9Object **) globalRef); vm->internalVMFunctions->j9jni_deleteGlobalRef((JNIEnv *) vmThread, globalRef, JNI_FALSE); } } - + #undef CDEV_CURRENT_FUNCTION static void diff --git a/runtime/vm/JFRConstantPoolTypes.hpp b/runtime/vm/JFRConstantPoolTypes.hpp index 9ad79dc89a6..c65993e4745 100644 --- a/runtime/vm/JFRConstantPoolTypes.hpp +++ b/runtime/vm/JFRConstantPoolTypes.hpp @@ -54,10 +54,10 @@ enum JFRStringConstants { }; enum FrameType { - Interpreted = 0, - JIT, - JIT_Inline, - Native, + Interpreted = J9VM_STACK_FRAME_INTERPRETER, + JIT = J9VM_STACK_FRAME_JIT, + JIT_Inline = J9VM_STACK_FRAME_JIT_INLINE, + Native = J9VM_STACK_FRAME_NATIVE, FrameTypeCount, }; @@ -471,7 +471,7 @@ class VM_JFRConstantPoolTypes { return false; } - static UDATA stackTraceCallback(J9VMThread *vmThread, void *userData, UDATA bytecodeOffset, J9ROMClass *romClass, J9ROMMethod *romMethod, J9UTF8 *fileName, UDATA lineNumber, J9ClassLoader *classLoader, J9Class *ramClass) + static UDATA stackTraceCallback(J9VMThread *vmThread, void *userData, UDATA bytecodeOffset, J9ROMClass *romClass, J9ROMMethod *romMethod, J9UTF8 *fileName, UDATA lineNumber, J9ClassLoader *classLoader, J9Class *ramClass, UDATA frameType) { VM_JFRConstantPoolTypes *cp = (VM_JFRConstantPoolTypes*) userData; StackFrame *frame = &cp->_currentStackFrameBuffer[cp->_currentFrameCount]; diff --git a/runtime/vm/exceptiondescribe.c b/runtime/vm/exceptiondescribe.c index c13978e54f2..33882528afa 100644 --- a/runtime/vm/exceptiondescribe.c +++ b/runtime/vm/exceptiondescribe.c @@ -35,7 +35,7 @@ #include "jvminit.h" #include "SCQueryFunctions.h" -typedef UDATA (*callback_func_t) (J9VMThread * vmThread, void * userData, UDATA bytecodeOffset, J9ROMClass * romClass, J9ROMMethod * romMethod, J9UTF8 * fileName, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass); +typedef UDATA (*callback_func_t) (J9VMThread * vmThread, void * userData, UDATA bytecodeOffset, J9ROMClass * romClass, J9ROMMethod * romMethod, J9UTF8 * fileName, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass, UDATA frameType); static void printExceptionInThread (J9VMThread* vmThread); static UDATA isSubclassOfThreadDeath (J9VMThread *vmThread, j9object_t exception); @@ -102,7 +102,7 @@ printExceptionMessage(J9VMThread* vmThread, j9object_t exception) { /* assumes VM access */ static UDATA -printStackTraceEntry(J9VMThread * vmThread, void * voidUserData, UDATA bytecodeOffset, J9ROMClass *romClass, J9ROMMethod * romMethod, J9UTF8 * sourceFile, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass) { +printStackTraceEntry(J9VMThread * vmThread, void * voidUserData, UDATA bytecodeOffset, J9ROMClass *romClass, J9ROMMethod * romMethod, J9UTF8 * sourceFile, UDATA lineNumber, J9ClassLoader* classLoader, J9Class* ramClass, UDATA frameType) { const char* format = NULL; J9JavaVM *vm = vmThread->javaVM; J9InternalVMFunctions * vmFuncs = vm->internalVMFunctions; @@ -407,6 +407,7 @@ iterateStackTraceImpl(J9VMThread * vmThread, j9object_t* exception, callback_fun J9UTF8 * fileName = NULL; J9ClassLoader *classLoader = NULL; J9Class *ramClass = NULL; + UDATA frameType = J9VM_STACK_FRAME_INTERPRETER; #ifdef J9VM_INTERP_NATIVE_SUPPORT J9JITExceptionTable * metaData = NULL; UDATA inlineDepth = 0; @@ -456,9 +457,11 @@ iterateStackTraceImpl(J9VMThread * vmThread, j9object_t* exception, callback_fun methodPC = jitConfig->getCurrentByteCodeIndexAndIsSameReceiver(metaData, inlineMap, NULL, &isSameReceiver); } ramMethod = metaData->ramMethod; + frameType = J9VM_STACK_FRAME_JIT; } else { methodPC = jitConfig->getCurrentByteCodeIndexAndIsSameReceiver(metaData, inlineMap , inlinedCallSite, &isSameReceiver); ramMethod = jitConfig->getInlinedMethod(inlinedCallSite); + frameType = J9VM_STACK_FRAME_JIT_INLINE; } if (pruneConstructors) { if (isSameReceiver) { @@ -522,6 +525,9 @@ foundROMMethod: ; } #ifdef J9VM_OPT_DEBUG_INFO_SERVER if (romMethod != NULL) { + if (J9_ARE_ALL_BITS_SET(romMethod->modifiers, J9AccNative)) { + frameType = J9VM_STACK_FRAME_NATIVE; + } lineNumber = getLineNumberForROMClassFromROMMethod(vm, romMethod, romClass, classLoader, methodPC); fileName = getSourceFileNameForROMClass(vm, classLoader, romClass); } @@ -531,7 +537,7 @@ foundROMMethod: ; if (callback != NULL) { /* The methodPC is the bytecode offset within the romMethod. */ - callbackResult = callback(vmThread, userData, methodPC, romClass, romMethod, fileName, lineNumber, classLoader, ramClass); + callbackResult = callback(vmThread, userData, methodPC, romClass, romMethod, fileName, lineNumber, classLoader, ramClass, frameType); } #ifdef J9VM_OPT_DEBUG_INFO_SERVER