Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 72 additions & 4 deletions compiler/ras/CallStack.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* (c) Copyright IBM Corp. 2000, 2016
* (c) Copyright IBM Corp. 2000, 2017
*
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0 and
Expand Down Expand Up @@ -169,6 +169,75 @@ const char *TR_PPCCallStackIterator::getProcedureName()
}

#elif defined(LINUX)
#if defined(ALPINE)
#include <libunwind.h>
#include <cxxabi.h> // for abi::__cxa_demangle
void TR_LinuxCallStackIterator::printStackBacktrace(TR::Compilation *comp)
{
unw_cursor_t cursor;
unw_context_t context;

unw_getcontext(&context);
unw_init_local(&cursor, &context);
uint32_t frame = 0;
int n=0;
while ( unw_step(&cursor) )
{
char func[256];
intptr_t offset;
intptr_t address;

unw_word_t ip, sp, off;

unw_get_reg(&cursor, UNW_REG_IP, &ip);
unw_get_reg(&cursor, UNW_REG_SP, &sp);

char symbol[256] = {"<unknown>"};
char *name = symbol;

if ( !unw_get_proc_name(&cursor, symbol, sizeof(symbol), &off) )
{
char *ms;
ms = strstr(name, ":");
if (ms!= NULL)
int r = sscanf(name, "%*[^::]::%255[^<>()]",func);
else
int r = sscanf(name, "%255[^<>()]",func);

address = ip;
offset = off;

char *funcToPrint = func;
size_t length = 256;
char *buffer = (char*) malloc(length);
int32_t status = -1;
char *demangled = abi::__cxa_demangle(func, buffer, &length, &status);
if (status == 0) funcToPrint = demangled;
if (comp)
traceMsg(comp, "#%d: function %s+%#x [%#p]\n",
frame,
funcToPrint,
offset,
address);
else
fprintf(stderr, "#%d: function %s+%#x [%#p]\n",
frame,
funcToPrint,
offset,
address);
if (demangled) free(demangled);
}
else
{
if (comp)
traceMsg(comp, "#%d %#p: \n", frame, address);
else
fprintf(stderr, "#%d %#p: \n", frame, address);
}
frame++;
}
}
#else
#include <execinfo.h>
#include <cxxabi.h> // for abi::__cxa_demangle

Expand Down Expand Up @@ -226,13 +295,12 @@ void TR_LinuxCallStackIterator::printStackBacktrace(TR::Compilation *comp)
}
free(symbols);
}

#endif /* if defined(ALPINE) */
#elif defined(J9ZOS390)

#include <unistd.h> // for __e2a_l
#include <ceeedcct.h>

extern "builtin" void *__gdsa();
extern "builtin" void *__gdsa();

TR_MvsCallStackIterator::TR_MvsCallStackIterator ()
: TR_CallStackIterator()
Expand Down
2 changes: 1 addition & 1 deletion fvtest/compilertest/build/toolcfg/host/linux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
################################################################################


HOST_DEFINES+=LINUX
HOST_DEFINES+=LINUX ALPINE
6 changes: 5 additions & 1 deletion include_core/omrsig.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@
extern "C" {
#endif /* __cplusplus */

#if defined(OSX)
#if defined(OSX) || defined(ALPINE)
#define __THROW
#endif /* defined(OSX) */

#if defined(ALPINE)
typedef sighandler_t __sighandler_t;
#endif

#if defined(LINUXPPC)
typedef __sighandler_t sighandler_t;
#elif defined(LINUX) || defined(OSX)
Expand Down
2 changes: 1 addition & 1 deletion jitbuilder/build/toolcfg/host/linux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
## Multiple authors (IBM Corp.) - initial implementation and documentation
################################################################################

HOST_DEFINES+=LINUX
HOST_DEFINES+=LINUX ALPINE
2 changes: 1 addition & 1 deletion omrmakefiles/rules.linux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ endif
### Global Flags
###

GLOBAL_CPPFLAGS += -DLINUX -D_REENTRANT -D_FILE_OFFSET_BITS=64
GLOBAL_CPPFLAGS += -DLINUX -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DALPINE

ifeq (s390,$(OMR_HOST_ARCH))
GLOBAL_CXXFLAGS+=$(J9M31)
Expand Down
7 changes: 7 additions & 0 deletions port/linux/omrosbacktrace_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@
#include "omrsignal_context.h"

#include <dlfcn.h>
#if defined(ALPINE)
#include <unwind.h>
int backtrace (void **__array, int __size) {
return 1;
}
#else
#include <execinfo.h>
#endif
#include <stdlib.h>
#include <string.h>

Expand Down
2 changes: 2 additions & 0 deletions port/linux/omrosdump_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
#include <sys/stat.h>
#if defined(LINUX)
#include <sys/prctl.h>
#if !defined(ALPINE)
#include <linux/prctl.h>
#endif
#include <sys/resource.h>
#endif
#include <elf.h>
Expand Down
7 changes: 7 additions & 0 deletions port/unix/omrintrospect.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define _GNU_SOURCE
#endif /* defined(LINUX) */


#include <pthread.h>
#include <ucontext.h>
#include <sched.h>
Expand All @@ -53,6 +54,10 @@
#include <stdlib.h>
#endif

#if defined(ALPINE)
typedef union sigval sigval_t;
#endif

#include "omrintrospect.h"
#include "omrport.h"
#include "omrportpriv.h"
Expand Down Expand Up @@ -1393,7 +1398,9 @@ setup_native_thread(J9ThreadWalkState *state, thread_context *sigContext, int he
memcpy(state->current_thread->context, ((J9UnixSignalInfo *)sigContext)->platformSignalInfo.context, size);
} else if (state->current_thread->thread_id == omrthread_get_ras_tid()) {
/* return context for current thread */
#if !defined(ALPINE)
getcontext((ucontext_t *)state->current_thread->context);
#endif
} else {
memcpy(state->current_thread->context, (void *)data->thread->context, size);
}
Expand Down
3 changes: 3 additions & 0 deletions port/unix/omrsysinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
#include <nl_types.h>
#include <langinfo.h>
#ifndef USER_HZ
#if !defined(HZ) && defined(ALPINE)
#define HZ 100
#endif
#define USER_HZ HZ
#endif

Expand Down
3 changes: 3 additions & 0 deletions thread/common/omrthreadinspect.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
* once for out-of-process uses (e.g. debug extensions).
* The APIs in this file are only used for inspecting threads -- not for modifying them
*/
#if defined(ALPINE)
#define _POSIX_C_SOURCE 200809L
#endif

#if defined(LINUX)
/* Allowing the use of pthread_attr_getstack in omrthread_get_stack_range */
Expand Down
4 changes: 4 additions & 0 deletions thread/unix/rasthrsup.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
/* this #include defines the buildspec flags */
#include "omrthread.h"

#if defined(ALPINE)
#define __GLIBC_PREREQ(maj, min) 1
#endif

#if defined(LINUX)
#if __GLIBC_PREREQ(2,4)
#include <sys/syscall.h>
Expand Down
2 changes: 2 additions & 0 deletions thread/unix/thrdsup.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

#if defined(LINUX)
#include <sys/prctl.h>
#if !defined(ALPINE)
#include <linux/prctl.h>
#endif
#endif /* defined(LINUX) */

#if (defined(LINUX) || defined(OSX)) && defined(J9X86)
Expand Down