Electroneum
Loading...
Searching...
No Matches
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

namespace  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)
Main entry point of each logging.
#define ELPP
#define ELECTRONEUM_DEFAULT_LOG_CATEGORY
Definition misc_log_ex.h:36

Definition at line 53 of file stack_trace.cpp.

53#define ST_LOG(x) \
54 do { \
55 auto elpp = ELPP; \
56 if (elpp) { \
57 CINFO(el::base::Writer,el::base::DispatchAction::FileOnlyLog,ELECTRONEUM_DEFAULT_LOG_CATEGORY) << x; \
58 } \
59 else { \
60 std::cout << x << std::endl; \
61 } \
62 } while(0)

◆ 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 *)) ( 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}
const char * name
void log_stack_trace(const char *msg)
__attribute__((noreturn)) void CXA_THROW(void *ex
CXA_THROW_INFO_T void(* dest)(void *))
CXA_THROW_INFO_T * info
void cxa_throw_t(void *ex, CXA_THROW_INFO_T *info, void(*dest)(void *))

◆ info

Definition at line 91 of file stack_trace.cpp.