Allow CMake user to disable Symbolize functionality
Currently the user has to rely on the HAVE_SYMBOLIZE detection inside CMakeLists.txt without having any control over whether it should be used. Add support for disabling HAVE_SYMBOLIZE at configure time so user can specify `cmake -DHAVE_SYMBOLIZE=0`. Signed-off-by: Ed Baunton <ebaunton1@bloomberg.net>
This commit is contained in:
parent
195d416e3b
commit
eb13e4f67c
@ -25,6 +25,7 @@ option (PRINT_UNSYMBOLIZED_STACK_TRACES
|
|||||||
"Print file offsets in traces instead of symbolizing" OFF)
|
"Print file offsets in traces instead of symbolizing" OFF)
|
||||||
option (WITH_PKGCONFIG "Enable pkg-config support" ON)
|
option (WITH_PKGCONFIG "Enable pkg-config support" ON)
|
||||||
option (WITH_UNWIND "Enable libunwind support" ON)
|
option (WITH_UNWIND "Enable libunwind support" ON)
|
||||||
|
option (WITH_SYMBOLIZE "Enable symbolize module" ON)
|
||||||
|
|
||||||
if (NOT WITH_UNWIND)
|
if (NOT WITH_UNWIND)
|
||||||
set (CMAKE_DISABLE_FIND_PACKAGE_Unwind ON)
|
set (CMAKE_DISABLE_FIND_PACKAGE_Unwind ON)
|
||||||
@ -365,44 +366,46 @@ if (HAVE_EXECINFO_H)
|
|||||||
set (HAVE_STACKTRACE 1)
|
set (HAVE_STACKTRACE 1)
|
||||||
endif (HAVE_EXECINFO_H)
|
endif (HAVE_EXECINFO_H)
|
||||||
|
|
||||||
if (WIN32 OR CYGWIN)
|
if (WITH_SYMBOLIZE)
|
||||||
cmake_push_check_state (RESET)
|
if (WIN32 OR CYGWIN)
|
||||||
set (CMAKE_REQUIRED_LIBRARIES DbgHelp)
|
cmake_push_check_state (RESET)
|
||||||
|
set (CMAKE_REQUIRED_LIBRARIES DbgHelp)
|
||||||
|
|
||||||
check_cxx_source_runs ([=[
|
check_cxx_source_runs ([=[
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <dbghelp.h>
|
#include <dbghelp.h>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
void foobar() { }
|
void foobar() { }
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
HANDLE process = GetCurrentProcess();
|
HANDLE process = GetCurrentProcess();
|
||||||
|
|
||||||
if (!SymInitialize(process, NULL, TRUE))
|
if (!SymInitialize(process, NULL, TRUE))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
char buf[sizeof(SYMBOL_INFO) + MAX_SYM_NAME];
|
char buf[sizeof(SYMBOL_INFO) + MAX_SYM_NAME];
|
||||||
SYMBOL_INFO *symbol = reinterpret_cast<SYMBOL_INFO *>(buf);
|
SYMBOL_INFO *symbol = reinterpret_cast<SYMBOL_INFO *>(buf);
|
||||||
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
|
symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
|
||||||
symbol->MaxNameLen = MAX_SYM_NAME;
|
symbol->MaxNameLen = MAX_SYM_NAME;
|
||||||
|
|
||||||
void* const pc = reinterpret_cast<void*>(&foobar);
|
void* const pc = reinterpret_cast<void*>(&foobar);
|
||||||
BOOL ret = SymFromAddr(process, reinterpret_cast<DWORD64>(pc), 0, symbol);
|
BOOL ret = SymFromAddr(process, reinterpret_cast<DWORD64>(pc), 0, symbol);
|
||||||
|
|
||||||
return ret ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
]=] HAVE_SYMBOLIZE)
|
]=] HAVE_SYMBOLIZE)
|
||||||
|
|
||||||
cmake_pop_check_state ()
|
cmake_pop_check_state ()
|
||||||
|
|
||||||
if (HAVE_SYMBOLIZE)
|
if (HAVE_SYMBOLIZE)
|
||||||
set (HAVE_STACKTRACE 1)
|
set (HAVE_STACKTRACE 1)
|
||||||
endif (HAVE_SYMBOLIZE)
|
endif (HAVE_SYMBOLIZE)
|
||||||
elseif (UNIX OR (APPLE AND HAVE_DLADDR))
|
elseif (UNIX OR (APPLE AND HAVE_DLADDR))
|
||||||
set (HAVE_SYMBOLIZE 1)
|
set (HAVE_SYMBOLIZE 1)
|
||||||
endif (WIN32 OR CYGWIN)
|
endif (WIN32 OR CYGWIN)
|
||||||
|
endif (WITH_SYMBOLIZE)
|
||||||
|
|
||||||
check_cxx_source_compiles ("
|
check_cxx_source_compiles ("
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user