mirror of https://gitee.com/bigwinds/arangodb
Stacktraces & asserts for windows too.
This commit is contained in:
parent
23fa0542dc
commit
5e1720132f
|
@ -171,6 +171,30 @@ endif ()
|
|||
## --SECTION-- DIRECTORIES
|
||||
## -----------------------------------------------------------------------------
|
||||
|
||||
################################################################################
|
||||
### @brief Enable Backtrace
|
||||
################################################################################
|
||||
|
||||
option(USE_BACKTRACE "whether we should try to generate c-level stacktraces" OFF)
|
||||
if (USE_BACKTRACE)
|
||||
if (MSVC)
|
||||
set(BT_LIBS "Dbghelp" CACHE path "Debug Helper libraries")
|
||||
else ()
|
||||
set(BT_LIBS "" CACHE path "Debug Helper libraries")
|
||||
endif()
|
||||
add_definitions("-DHAVE_BACKTRACE=1")
|
||||
else()
|
||||
set(BT_LIBS "" CACHE path "Debug Helper libraries")
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
### @brief Enable Backtrace
|
||||
################################################################################
|
||||
|
||||
option(USER_MAINTAINER_MODE "whether we want to have Assertions and other development features" OFF)
|
||||
if (USER_MAINTAINER_MODE)
|
||||
add_definitions("-DTRI_ENABLE_MAINTAINER_MODE=1")
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
### @brief Enable Relative
|
||||
|
|
|
@ -236,7 +236,7 @@ pack-win32-relative:
|
|||
$(MAKE) pack-winXX BITS=32 TARGET="Visual Studio 12" MOREOPTS='-D "USE_RELATIVE=ON"'
|
||||
|
||||
pack-win64-relative:
|
||||
$(MAKE) pack-winXX BITS=64 TARGET="Visual Studio 12 Win64" MOREOPTS='-D "USE_RELATIVE=ON" -D "TRI_ENABLE_MAINTAINER_MODE=1" -D "HAVE_BACKTRACE=1"'
|
||||
$(MAKE) pack-winXX BITS=64 TARGET="Visual Studio 12 Win64" MOREOPTS='-D "USE_RELATIVE=ON" -D "USER_MAINTAINER_MODE=ON" -D "USE_BACKTRACE=ON"'
|
||||
|
||||
pack-winXX:
|
||||
rm -rf Build$(BITS) && mkdir Build$(BITS)
|
||||
|
|
|
@ -171,6 +171,7 @@ target_link_libraries(
|
|||
${LIBEV_LIBS}
|
||||
${V8_LIBS} # need this for rest::Version
|
||||
${ICU_LIBS}
|
||||
${BT_LIBS}
|
||||
${ZLIB_LIBS}
|
||||
${READLINE_LIBS}
|
||||
${OPENSSL_LIBS}
|
||||
|
|
|
@ -32,6 +32,7 @@ target_link_libraries(
|
|||
${LIB_ARANGO_CLIENT}
|
||||
${LIB_ARANGO}
|
||||
${ICU_LIBS}
|
||||
${BT_LIBS}
|
||||
${ZLIB_LIBS}
|
||||
${READLINE_LIBS}
|
||||
${OPENSSL_LIBS}
|
||||
|
@ -67,6 +68,7 @@ target_link_libraries(
|
|||
${LIB_ARANGO_CLIENT}
|
||||
${LIB_ARANGO}
|
||||
${ICU_LIBS}
|
||||
${BT_LIBS}
|
||||
${ZLIB_LIBS}
|
||||
${READLINE_LIBS}
|
||||
${OPENSSL_LIBS}
|
||||
|
@ -106,6 +108,7 @@ target_link_libraries(
|
|||
${LIB_ARANGO}
|
||||
${V8_LIBS}
|
||||
${ICU_LIBS}
|
||||
${BT_LIBS}
|
||||
${ZLIB_LIBS}
|
||||
${READLINE_LIBS}
|
||||
${OPENSSL_LIBS}
|
||||
|
@ -141,6 +144,7 @@ target_link_libraries(
|
|||
${LIB_ARANGO_CLIENT}
|
||||
${LIB_ARANGO}
|
||||
${ICU_LIBS}
|
||||
${BT_LIBS}
|
||||
${ZLIB_LIBS}
|
||||
${READLINE_LIBS}
|
||||
${OPENSSL_LIBS}
|
||||
|
@ -179,6 +183,7 @@ target_link_libraries(
|
|||
${LIB_ARANGO_CLIENT}
|
||||
${LIB_ARANGO}
|
||||
${V8_LIBS}
|
||||
${BT_LIBS}
|
||||
${ICU_LIBS}
|
||||
${ZLIB_LIBS}
|
||||
${READLINE_LIBS}
|
||||
|
|
|
@ -311,6 +311,34 @@ void TRI_ShutdownDebugging () {
|
|||
|
||||
void TRI_GetBacktrace (std::string& btstr) {
|
||||
#if HAVE_BACKTRACE
|
||||
#ifdef _WIN32
|
||||
unsigned int i;
|
||||
void * stack[ 100 ];
|
||||
unsigned short frames;
|
||||
SYMBOL_INFO * symbol;
|
||||
HANDLE process;
|
||||
|
||||
process = GetCurrentProcess();
|
||||
|
||||
SymInitialize( process, NULL, TRUE );
|
||||
|
||||
frames = CaptureStackBackTrace( 0, 100, stack, NULL );
|
||||
symbol = ( SYMBOL_INFO * )calloc( sizeof( SYMBOL_INFO ) + 256 * sizeof( char ), 1 );
|
||||
symbol->MaxNameLen = 255;
|
||||
symbol->SizeOfStruct = sizeof( SYMBOL_INFO );
|
||||
|
||||
for( i = 0; i < frames; i++ )
|
||||
{
|
||||
char address[64];
|
||||
SymFromAddr( process, ( DWORD64 )( stack[ i ] ), 0, symbol );
|
||||
|
||||
snprintf(address, sizeof(address), "0x%0X", symbol->Address );
|
||||
bstr += std::string(frames - i - 1) + std::string(": ") + symbol->Name + std::string(" [") + address + std::string("]\n");
|
||||
}
|
||||
|
||||
free( symbol );
|
||||
|
||||
#else
|
||||
void* stack_frames[50];
|
||||
size_t size, i;
|
||||
char** strings;
|
||||
|
@ -377,6 +405,7 @@ void TRI_GetBacktrace (std::string& btstr) {
|
|||
TRI_SystemFree(strings);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -135,7 +135,7 @@ void TRI_UnlockMutex (TRI_mutex_t* mutex) {
|
|||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#ifndef TRI_FAKE_SPIN_LOCKS
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initialises a new spin
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -171,6 +171,7 @@ void TRI_LockSpin (TRI_spin_t* spin) {
|
|||
void TRI_UnlockSpin (TRI_spin_t* spin) {
|
||||
LeaveCriticalSection(spin);
|
||||
}
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- READ-WRITE LOCK
|
||||
|
|
|
@ -58,8 +58,11 @@ TRI_mutex_t;
|
|||
|
||||
#ifdef TRI_FAKE_SPIN_LOCKS
|
||||
|
||||
#define TRI_spin_t phread_mutex_t
|
||||
|
||||
#define TRI_spin_t TRI_mutex_t
|
||||
#define TRI_InitSpin TRI_InitMutex
|
||||
#define TRI_DestroySpin TRI_DestroyMutex
|
||||
#define TRI_LockSpin TRI_LockMutex
|
||||
#define TRI_UnlockSpin TRI_UnlockMutex
|
||||
#else
|
||||
|
||||
#define TRI_spin_t CRITICAL_SECTION
|
||||
|
|
Loading…
Reference in New Issue