Artyom Beilis 7 years ago
parent
commit
4a8a6336bb
3 changed files with 33 additions and 3 deletions
  1. +24
    -0
      booster/CMakeLists.txt
  2. +8
    -3
      booster/lib/backtrace/src/backtrace.cpp
  3. +1
    -0
      booster/lib/booster_build_config.cmake.h

+ 24
- 0
booster/CMakeLists.txt View File

@@ -339,6 +339,10 @@ check_cxx_source_compiles(
#include <sstream>
#include <typeinfo>
#include <new>
#ifdef __GNUC__
#include <cxxabi.h>
#endif
extern \"C\" {
extern void* _Unwind_GetIP (void *);
extern int _Unwind_Backtrace(int (*)(void *,void *),void *);
@@ -347,6 +351,26 @@ check_cxx_source_compiles(
int main() { _Unwind_Backtrace(0,0); _Unwind_GetIP(0); }"
BOOSTER_HAVE_UNWIND_BACKTRACE)

check_cxx_source_compiles(
"#include <stdexcept>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <typeinfo>
#include <new>
#ifdef __GNUC__
#include <cxxabi.h>
#endif
extern \"C\" {
extern int _Unwind_Backtrace(int (*)(void *,void *),void *);
}

int main() { _Unwind_Backtrace(0,0); _Unwind_GetIP((_Unwind_Context *)0); }"
BOOSTER_HAVE_UNWIND_BACKTRACE_BUILTIN)



Check_cxx_source_compiles(
"#include <atomic.h>


+ 8
- 3
booster/lib/backtrace/src/backtrace.cpp View File

@@ -45,10 +45,11 @@
#include <dbghelp.h>
#endif

#if defined(BOOSTER_HAVE_UNWIND_BACKTRACE)

#if defined(BOOSTER_HAVE_UNWIND_BACKTRACE) || defined(BOOSTER_HAVE_UNWIND_BACKTRACE_BUILTIN)
extern "C" {
#ifndef BOOSTER_HAVE_UNWIND_BACKTRACE_BUILTIN
extern void * _Unwind_GetIP (void *);
#endif
extern int _Unwind_Backtrace(int (*)(void *,void *),void *);
}

@@ -63,7 +64,7 @@ namespace booster {
// so enable it on Apple, Sun and BSD using libgcc's _Unwind_Backtrace
// if present
//
#if defined(BOOSTER_HAVE_UNWIND_BACKTRACE) && ( defined(__FreeBSD__) || defined(__sun) || defined(__APPLE__) )
#if (defined(BOOSTER_HAVE_UNWIND_BACKTRACE) || defined(BOOSTER_HAVE_UNWIND_BACKTRACE_BUILTIN)) && ( defined(__FreeBSD__) || defined(__sun) || defined(__APPLE__) )

namespace {
struct trace_data {
@@ -77,7 +78,11 @@ namespace booster {
trace_data *d = static_cast<trace_data *>(cookie);
if(d->reminder > 0) {
d->reminder --;
#ifdef BOOSTER_HAVE_UNWIND_BACKTRACE_BUILTIN
d->array[d->total++] = reinterpret_cast<void*>(_Unwind_GetIP(static_cast<_Unwind_Context*>(context)));
#else
d->array[d->total++] = _Unwind_GetIP(context);
#endif
}
return 0;
}


+ 1
- 0
booster/lib/booster_build_config.cmake.h View File

@@ -65,6 +65,7 @@

#cmakedefine BOOSTER_HAVE_UNWIND_BACKTRACE

#cmakedefine BOOSTER_HAVE_UNWIND_BACKTRACE_BUILTIN
/* Define to module suffix. */
#cmakedefine BOOSTER_LIBRARY_SUFFIX "${BOOSTER_LIBRARY_SUFFIX}"



Loading…
Cancel
Save