Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build with NDK r10e for x86 #30

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
25 changes: 22 additions & 3 deletions coffeecatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
#define USE_LIBUNWIND
#endif

#ifdef __APPLE__
#define USE_UNWIND
#endif

/* #undef NO_USE_SIGALTSTACK */
/* #undef USE_SILENT_SIGALTSTACK */

Expand All @@ -55,6 +59,11 @@
#include <dlfcn.h>
#include "coffeecatch.h"

#ifndef SIGPOLL
// SIGPOLL is SIGIO on some platforms
#define SIGPOLL SIGIO
#endif

/*#define NDK_DEBUG 1*/
#if ( defined(NDK_DEBUG) && ( NDK_DEBUG == 1 ) )
#define DEBUG(A) do { A; } while(0)
Expand Down Expand Up @@ -114,6 +123,9 @@ typedef struct ucontext {

#elif defined(__i386__)

#elif defined(__x86_64__)

#if !defined(__BIONIC_HAVE_UCONTEXT_T)
/* Taken from Google Breakpad. */

/* 80-bit floating-point register */
Expand Down Expand Up @@ -166,7 +178,6 @@ enum {
REG_SS,
};

#if !defined(__BIONIC_HAVE_UCONTEXT_T)
typedef struct ucontext {
uint32_t uc_flags;
struct ucontext* uc_link;
Expand Down Expand Up @@ -1126,8 +1137,12 @@ uintptr_t coffeecatch_get_backtrace(ssize_t index) {
static uintptr_t coffeecatch_get_pc_from_ucontext(const ucontext_t *uc) {
#if (defined(__arm__))
return uc->uc_mcontext.arm_pc;
#elif defined(__aarch64__)
#elif (defined(__APPLE__) && defined(__aarch64__))
return uc->uc_mcontext->__ss.__pc;
#elif (defined(__aarch64__))
return uc->uc_mcontext.pc;
#elif (defined(__APPLE__) && defined(__x86_64__))
return uc->uc_mcontext->__ss.__rip;
#elif (defined(__x86_64__))
return uc->uc_mcontext.gregs[REG_RIP];
#elif (defined(__i386))
Expand Down Expand Up @@ -1352,7 +1367,11 @@ void coffeecatch_get_backtrace_info(void (*fun)(void *arg,
}
#endif
for(i = 0; i < t->frames_size; i++) {
const uintptr_t pc = t->frames[i].absolute_pc;
const uintptr_t pc = t->frames[i]
#if (defined(USE_CORKSCREW))
.absolute_pc
#endif
;
format_pc_address_cb(pc, fun, arg);
}
}
Expand Down
20 changes: 20 additions & 0 deletions coffeecatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,26 @@ extern void coffeecatch_cleanup(void);
/** End of internal functions & definitions. **/

#ifdef __cplusplus
/**
* Sentinel class for cleaning up. Not to be used directly.
*/
namespace CoffeeCatch {
class Sentinel {
public:
Sentinel() {}
~Sentinel() { COFFEE_END(); }
};
}

/**
* Versions of the above macros that are friendlier to C++.
* Uses a sentinel object to clean up after COFFEE_TRY(), so that
* even if the code inside the try block returns or throws a C++
* exception, COFFEE_END() will still be called.
*/
#define COFFEE_CXX_TRY() { volatile CoffeeCatch::Sentinel cc_sentinel; COFFEE_TRY()
#define COFFEE_CXX_CATCH() COFFEE_CATCH()
#define COFFEE_CXX_END() }
}
#endif

Expand Down