Electroneum
stack_trace.cpp File Reference
#include "easylogging++/easylogging++.h"
#include <stdexcept>
#include <libunwind.h>
#include <cxxabi.h>
#include <dlfcn.h>
#include <boost/algorithm/string.hpp>
#include "common/stack_trace.h"
#include "misc_log_ex.h"
Include dependency graph for stack_trace.cpp:

Go to the source code of this file.

Namespaces

 tools
 Various Tools.
 

Macros

#define USE_UNWIND
 
#define UNW_LOCAL_ONLY
 
#define ELECTRONEUM_DEFAULT_LOG_CATEGORY   "stacktrace"
 
#define ST_LOG(x)
 
#define CXA_THROW_INFO_T   void
 
#define CXA_THROW   __cxa_throw
 

Typedefs

typedef void() cxa_throw_t(void *ex, CXA_THROW_INFO_T *info, void(*dest) (void *))
 

Functions

 __attribute__ ((noreturn)) void CXA_THROW(void *ex
 
void tools::set_stack_trace_log (const std::string &log)
 
void tools::log_stack_trace (const char *msg)
 

Variables

CXA_THROW_INFO_Tinfo
 
CXA_THROW_INFO_T void(* dest )(void *))
 

Macro Definition Documentation

◆ CXA_THROW

#define CXA_THROW   __cxa_throw

Definition at line 80 of file stack_trace.cpp.

◆ CXA_THROW_INFO_T

#define CXA_THROW_INFO_T   void

Definition at line 71 of file stack_trace.cpp.

◆ ELECTRONEUM_DEFAULT_LOG_CATEGORY

#define ELECTRONEUM_DEFAULT_LOG_CATEGORY   "stacktrace"

Definition at line 51 of file stack_trace.cpp.

◆ ST_LOG

#define ST_LOG (   x)
Value:
do { \
auto elpp = ELPP; \
if (elpp) { \
} \
else { \
std::cout << x << std::endl; \
} \
} while(0)
#define ELPP
Main entry point of each logging.
#define ELECTRONEUM_DEFAULT_LOG_CATEGORY
Definition: stack_trace.cpp:51

Definition at line 53 of file stack_trace.cpp.

◆ UNW_LOCAL_ONLY

#define UNW_LOCAL_ONLY

Definition at line 39 of file stack_trace.cpp.

◆ USE_UNWIND

#define USE_UNWIND

Definition at line 31 of file stack_trace.cpp.

Typedef Documentation

◆ cxa_throw_t

typedef void() cxa_throw_t(void *ex, CXA_THROW_INFO_T *info, void(*dest)(void *))

Definition at line 86 of file stack_trace.cpp.

Function Documentation

◆ __attribute__()

__attribute__ ( (noreturn)  )
Here is the caller graph for this function:

Variable Documentation

◆ dest

CXA_THROW_INFO_T void(* dest) (void *))

Definition at line 91 of file stack_trace.cpp.

92 {
93 
94  int status;
95  char *dsym = abi::__cxa_demangle(((const std::type_info*)info)->name(), NULL, NULL, &status);
96  tools::log_stack_trace((std::string("Exception: ")+((!status && dsym) ? dsym : (const char*)info)).c_str());
97  free(dsym);
98 
99 #ifndef STATICLIB
100 #ifndef __clang__ // for GCC the attr can't be applied in typedef like for clang
101  __attribute__((noreturn))
102 #endif // !__clang__
103  cxa_throw_t *__real___cxa_throw = (cxa_throw_t*)dlsym(RTLD_NEXT, "__cxa_throw");
104 #endif // !STATICLIB
105  __real___cxa_throw(ex, info, dest);
106 }
::std::string string
Definition: gtest-port.h:1097
CXA_THROW_INFO_T void(* dest)(void *))
Definition: stack_trace.cpp:91
void() cxa_throw_t(void *ex, CXA_THROW_INFO_T *info, void(*dest)(void *))
Definition: stack_trace.cpp:86
const char * name
CXA_THROW_INFO_T * info
Definition: stack_trace.cpp:91
__attribute__((noreturn)) void CXA_THROW(void *ex
void log_stack_trace(const char *msg)

◆ info

Definition at line 91 of file stack_trace.cpp.