Skip to content

Commit

Permalink
Enable RAS Dump support on OSX
Browse files Browse the repository at this point in the history
More details here: eclipse-openj9#3380.

closes: eclipse-openj9#3380.
closes: eclipse-openj9#3343.

Signed-off-by: Babneet Singh <[email protected]>
  • Loading branch information
babsingh authored and acrowthe committed Nov 5, 2018
1 parent 0386691 commit e804d8e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 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
8 changes: 4 additions & 4 deletions runtime/rasdump/dmpsup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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

0 comments on commit e804d8e

Please sign in to comment.