From 6757b972bc08440962989a43440e26a649561454 Mon Sep 17 00:00:00 2001 From: Babneet Singh Date: Fri, 19 Oct 2018 13:05:18 -0400 Subject: [PATCH 1/2] Enable RAS Dump support on OSX More details here: https://github.com/eclipse/openj9/issues/3380. closes: https://github.com/eclipse/openj9/issues/3380. closes: https://github.com/eclipse/openj9/issues/3343. Signed-off-by: Babneet Singh --- runtime/rasdump/dmpagent.c | 36 +++++++++++++++++++----------------- runtime/rasdump/dmpsup.c | 8 ++++---- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/runtime/rasdump/dmpagent.c b/runtime/rasdump/dmpagent.c index 914a8bc30c6..85bce466fe7 100644 --- a/runtime/rasdump/dmpagent.c +++ b/runtime/rasdump/dmpagent.c @@ -37,12 +37,12 @@ #include #include #endif -#ifdef LINUX +#if defined(LINUX) || defined(OSX) #include #include #include #include -#endif +#endif /* defined(LINUX) || defined(OSX) */ #include "ut_j9dmp.h" @@ -287,15 +287,17 @@ static const J9RASdumpSpec rasDumpSpecs[] = 1, 1, #if defined(WIN32) "windbg -p %pid -c \".setdll %vmbin\\j9windbg\"", -#elif defined(LINUX) +#elif defined(LINUX) /* defined(WIN32) */ "gdb -p %pid", -#elif defined(AIXPPC) +#elif defined(AIXPPC) /* defined(WIN32) */ "dbx -a %pid", -#elif defined(J9ZOS390) +#elif defined(J9ZOS390) /* defined(WIN32) */ "dbx -a %pid", -#else +#elif defined(OSX) /* defined(WIN32) */ + "lldb -p %pid", +#else /* defined(WIN32) */ NULL, -#endif +#endif /* defined(WIN32) */ NULL, 0, J9RAS_DUMP_DO_SUSPEND_OTHER_DUMPS, @@ -677,7 +679,7 @@ doSystemDump(J9RASdumpAgent *agent, char *label, J9RASdumpContext *context) const char* cacheDir = NULL; J9RAS* rasStruct = vm->j9ras; -#if defined(J9VM_OPT_SHARED_CLASSES) && defined(LINUX) +#if defined(J9VM_OPT_SHARED_CLASSES) && (defined(LINUX) || defined(OSX)) J9SharedClassJavacoreDataDescriptor sharedClassData; /* set up cacheDir with the Shared Classes Cache file if it is in use. */ @@ -689,7 +691,7 @@ doSystemDump(J9RASdumpAgent *agent, char *label, J9RASdumpContext *context) } } } -#endif +#endif /* defined(J9VM_OPT_SHARED_CLASSES) && (defined(LINUX) || defined(OSX)) */ reportDumpRequest(privatePortLibrary,context,"System",label); @@ -821,7 +823,7 @@ doToolDump(J9RASdumpAgent *agent, char *label, J9RASdumpContext *context) j9mem_free_memory(unicodePath); } } -#elif (defined(LINUX) && !defined(J9ZTPF)) || defined(AIXPPC) +#elif (defined(LINUX) && !defined(J9ZTPF)) || defined(AIXPPC) || defined(OSX) /* defined(WIN32) */ { IDATA retVal; @@ -842,7 +844,7 @@ doToolDump(J9RASdumpAgent *agent, char *label, J9RASdumpContext *context) omrthread_sleep(msec); } } -#elif defined(J9ZOS390) +#elif defined(J9ZOS390) /* defined(WIN32) */ { const char *argv[] = {"/bin/sh", "-c", NULL, NULL}; extern const char **environ; @@ -869,9 +871,9 @@ doToolDump(J9RASdumpAgent *agent, char *label, J9RASdumpContext *context) omrthread_sleep(msec); } } -#else +#else /* defined(WIN32) */ j9nls_printf(PORTLIB, J9NLS_INFO | J9NLS_STDERR, J9NLS_DMP_DUMP_NOT_AVAILABLE_STR, "Tool"); -#endif +#endif /* defined(WIN32) */ } else { j9nls_printf(PORTLIB, J9NLS_ERROR | J9NLS_STDERR, J9NLS_DMP_MISSING_EXECUTABLE_STR); } @@ -1339,16 +1341,16 @@ fixDumpLabel(J9JavaVM *vm, const J9RASdumpSpec *spec, char **labelPtr, IDATA new int ok = 0; /* Get absolute name */ -#if defined (WIN32) +#if defined(WIN32) ok = (GetCurrentDirectoryW(J9_MAX_DUMP_PATH, unicodeTemp) != 0); if (ok) { WideCharToMultiByte(OS_ENCODING_CODE_PAGE, OS_ENCODING_WC_FLAGS, unicodeTemp, -1, prefix, J9_MAX_DUMP_PATH, NULL, NULL); } -#elif defined(LINUX) || defined(AIXPPC) +#elif defined(LINUX) || defined(AIXPPC) || defined(OSX) /* defined(WIN32) */ ok = (getcwd(prefix, J9_MAX_DUMP_PATH) != 0); -#elif defined(J9ZOS390) +#elif defined(J9ZOS390) /* defined(WIN32) */ ok = (atoe_getcwd(prefix, J9_MAX_DUMP_PATH) != 0); -#endif +#endif /* defined(WIN32) */ if (ok) { prefix[J9_MAX_DUMP_PATH-1] = '\0'; diff --git a/runtime/rasdump/dmpsup.c b/runtime/rasdump/dmpsup.c index 8e97d47c6a0..565075f509f 100644 --- a/runtime/rasdump/dmpsup.c +++ b/runtime/rasdump/dmpsup.c @@ -1206,8 +1206,8 @@ JVM_OnUnload(JavaVM *vm, void *reserved) } /** - * On Linux the first call to get a backtrace can cause some initialisation work. - * If this is called in a signal handler with other threads paused then one of + * On Linux and OSX the first call to get a backtrace can cause some initialisation + * work. If this is called in a signal handler with other threads paused then one of * those can hold a lock required for the initialisation to complete. This causes * a hang. Therefore we do one redundant call to backtrace at startup to prevent * java dumps hanging the VM. @@ -1217,7 +1217,7 @@ JVM_OnUnload(JavaVM *vm, void *reserved) static void initBackTrace(J9JavaVM *vm) { -#ifdef LINUX +#if defined(LINUX) || defined(OSX) J9PlatformThread threadInfo; J9Heap *heap; char backingStore[8096]; @@ -1229,7 +1229,7 @@ initBackTrace(J9JavaVM *vm) if( j9introspect_backtrace_thread(&threadInfo, heap, NULL) != 0 ) { j9introspect_backtrace_symbols(&threadInfo, heap); } -#endif +#endif /* defined(LINUX) || defined(OSX) */ } /** From 8bcc3246bf57f32b190812a0b543a0ab6861cd29 Mon Sep 17 00:00:00 2001 From: Babneet Singh Date: Wed, 24 Oct 2018 11:45:04 -0400 Subject: [PATCH 2/2] Make spelling of "initialize" consistent in runtime/rasdump This will make searching easier as one does not have to check for alternate spellings. Signed-off-by: Babneet Singh --- runtime/rasdump/dmpsup.c | 6 +++--- runtime/rasdump/javadump.cpp | 2 +- runtime/rasdump/trigger.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/runtime/rasdump/dmpsup.c b/runtime/rasdump/dmpsup.c index 565075f509f..86653884562 100644 --- a/runtime/rasdump/dmpsup.c +++ b/runtime/rasdump/dmpsup.c @@ -1206,9 +1206,9 @@ JVM_OnUnload(JavaVM *vm, void *reserved) } /** - * On Linux and OSX the first call to get a backtrace can cause some initialisation + * On Linux and OSX the first call to get a backtrace can cause some initialization * work. If this is called in a signal handler with other threads paused then one of - * those can hold a lock required for the initialisation to complete. This causes + * those can hold a lock required for the initialization to complete. This causes * a hang. Therefore we do one redundant call to backtrace at startup to prevent * java dumps hanging the VM. * @@ -1291,7 +1291,7 @@ initSystemInfo(J9JavaVM *vm) } /** - * We need to read the -Xdump:directory option before we start initialising the + * We need to read the -Xdump:directory option before we start initializing the * default dump agents. */ static omr_error_t diff --git a/runtime/rasdump/javadump.cpp b/runtime/rasdump/javadump.cpp index ae2e97ad55e..a63b197eae5 100644 --- a/runtime/rasdump/javadump.cpp +++ b/runtime/rasdump/javadump.cpp @@ -1732,7 +1732,7 @@ JavaCoreDumpWriter::writeMonitorSection(void) UDATA stateFault = stateClean; if (i == 0) { - // The walk may have started or restarted which is why initialisation is in the loop. + // The walk may have started or restarted which is why initialization is in the loop. memset(threadStore, 0, (_AllocatedVMThreadCount+1) * sizeof(blocked_thread_record)); } diff --git a/runtime/rasdump/trigger.c b/runtime/rasdump/trigger.c index 8429862e6f5..24a53c8bdec 100644 --- a/runtime/rasdump/trigger.c +++ b/runtime/rasdump/trigger.c @@ -69,7 +69,7 @@ typedef enum J9RASdumpMatchResult static UDATA rasDumpSuspendKey = 0; static UDATA rasDumpFirstThread = 0; -/* Postpone GC and thread event hooks until later phases of VM initialisation */ +/* Postpone GC and thread event hooks until later phases of VM initialization. */ UDATA rasDumpPostponeHooks = \ J9RAS_DUMP_ON_CLASS_UNLOAD | \ J9RAS_DUMP_ON_GLOBAL_GC | \ @@ -1160,11 +1160,11 @@ rasDumpEnableHooks(J9JavaVM *vm, UDATA eventFlags) /** * rasDumpFlushHooks() - enable hooks for events that were postponed from the initial dump agent - * initialisation. There are now two phases: GC event hooks are enabled at TRACE_ENGINE_INITIALIZED, + * 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 initialisation stage + * @param[in] stage - VM initialization stage * @return void */ void