Skip to content

Commit

Permalink
Merge pull request #3381 from babsingh/osx_rasdump_support
Browse files Browse the repository at this point in the history
Enable RAS Dump support on OSX
  • Loading branch information
keithc-ca authored Oct 24, 2018
2 parents 7b34bfd + 8bcc324 commit 050cd9e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
36 changes: 19 additions & 17 deletions runtime/rasdump/dmpagent.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
#include <stdlib.h>
#include <errno.h>
#endif
#ifdef LINUX
#if defined(LINUX) || defined(OSX)
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#endif
#endif /* defined(LINUX) || defined(OSX) */

#include "ut_j9dmp.h"

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

Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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';
Expand Down
12 changes: 6 additions & 6 deletions runtime/rasdump/dmpsup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1206,9 +1206,9 @@ 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
* those can hold a lock required for the initialisation to complete. This causes
* 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 initialization to complete. This causes
* a hang. Therefore we do one redundant call to backtrace at startup to prevent
* java dumps hanging the VM.
*
Expand All @@ -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];
Expand All @@ -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) */
}

/**
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion runtime/rasdump/javadump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
6 changes: 3 additions & 3 deletions runtime/rasdump/trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 | \
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 050cd9e

Please sign in to comment.