Browse Source

logging: Add proper backtrace support detection

The Q_OS_UNIX macro is inappropriate because many UNIX-like platforms may
lack backtrace support in the libc. E.g.: Darwin / Mac OS X, Musl libc,
OpenBSD, OpenIndiana.
pull/7082/head 1.4.0rc1-709-g628ff6582
Ismael Luceno 9 months ago
committed by John Maguire
parent
commit
628ff65828
  1. 3
      ext/libclementine-common/CMakeLists.txt
  2. 4
      ext/libclementine-common/core/conf_backtrace.h.in
  3. 6
      ext/libclementine-common/core/logging.cpp

3
ext/libclementine-common/CMakeLists.txt

@ -39,3 +39,6 @@ target_link_libraries(libclementine-common
${TAGLIB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
find_package(Backtrace)
configure_file(core/conf_backtrace.h.in conf_backtrace.h)

4
ext/libclementine-common/core/conf_backtrace.h.in

@ -0,0 +1,4 @@
#cmakedefine Backtrace_FOUND
#ifdef Backtrace_FOUND
#include <@Backtrace_HEADER@>
#endif

6
ext/libclementine-common/core/logging.cpp

@ -21,9 +21,7 @@
#include <cxxabi.h>
#include <QtGlobal>
#ifdef Q_OS_UNIX
#include <execinfo.h>
#endif
#include "conf_backtrace.h"
#include <glib.h>
@ -325,7 +323,7 @@ QString DemangleSymbol(const QString& symbol) {
}
void DumpStackTrace() {
#ifdef Q_OS_UNIX
#ifdef Backtrace_FOUND
void* callstack[128];
int callstack_size =
backtrace(reinterpret_cast<void**>(&callstack), sizeof(callstack));

Loading…
Cancel
Save