Browse Source

Allow to disable Stacktrace support

Enable backtrace stuff only if GNU C library used, because current
backtrace implementation based  on  <execinfo.h> , which is not a
part of standard C library, it is a GNU extension.

This will be usefull when building  with  custom POSIX-compilant C
library (like musl) and no <execinfo.h> available.

Note: configure script will detect presence of  <execinfo.h>  and
enable/disable feature depending on it.

Feature is enabled by default.
adaptive-webui-19844
Nick Korotysh 7 years ago
parent
commit
7712d0ada0
No known key found for this signature in database
GPG Key ID: 7D0D4117C97CCC46
  1. 8
      CMakeLists.txt
  2. 44
      configure
  3. 23
      configure.ac
  4. 6
      src/CMakeLists.txt
  5. 8
      src/app/CMakeLists.txt
  6. 8
      src/app/app.pri
  7. 30
      src/app/main.cpp
  8. 8
      src/src.pro
  9. 2
      winconf.pri

8
CMakeLists.txt

@ -43,13 +43,13 @@ option(GUI "Allows to disable GUI for headless running. Disables QtDBus and the @@ -43,13 +43,13 @@ option(GUI "Allows to disable GUI for headless running. Disables QtDBus and the
option(WEBUI "Allows to disable the WebUI." ON)
if (WIN32)
option(STACKTRACE_WIN "")
else (WIN32)
option(STACKTRACE "Enable stacktrace feature" ON)
if (UNIX)
cmake_dependent_option(SYSTEMD "Install the systemd service file (headless only)" OFF
"NOT GUI" OFF)
cmake_dependent_option(DBUS "Enable use of QtDBus (GUI only)" ON "GUI" OFF)
endif(WIN32)
endif(UNIX)
add_subdirectory(src)

44
configure vendored

@ -717,6 +717,7 @@ enable_dependency_tracking @@ -717,6 +717,7 @@ enable_dependency_tracking
enable_silent_rules
with_qtsingleapplication
enable_debug
enable_stacktrace
enable_gui
enable_systemd
enable_webui
@ -1382,6 +1383,7 @@ Optional Features: @@ -1382,6 +1383,7 @@ Optional Features:
--enable-silent-rules less verbose build output (undo: "make V=1")
--disable-silent-rules verbose build output (undo: "make V=0")
--enable-debug Enable debug build
--enable-stacktrace Enable stacktrace feature (default=auto)
--disable-gui Disable the GUI for headless running. Disables
QtDBus and the GeoIP Database.
--enable-systemd Install the systemd service file (headless only).
@ -4189,6 +4191,14 @@ else @@ -4189,6 +4191,14 @@ else
fi
# Check whether --enable-stacktrace was given.
if test "${enable_stacktrace+set}" = set; then :
enableval=$enable_stacktrace;
else
enable_stacktrace=auto
fi
# Check whether --enable-gui was given.
if test "${enable_gui+set}" = set; then :
enableval=$enable_gui;
@ -4389,6 +4399,39 @@ $as_echo "$enable_debug" >&6; } @@ -4389,6 +4399,39 @@ $as_echo "$enable_debug" >&6; }
as_fn_error $? "Unknown option \"$enable_debug\". Use either \"yes\" or \"no\"." "$LINENO" 5 ;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable the stacktrace feature" >&5
$as_echo_n "checking whether to enable the stacktrace feature... " >&6; }
case "x$enable_stacktrace" in #(
"xno") :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG stacktrace" ;; #(
"xyes") :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
QBT_ADD_CONFIG="$QBT_ADD_CONFIG stacktrace" ;; #(
"xauto") :
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <execinfo.h>
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
QBT_ADD_CONFIG="$QBT_ADD_CONFIG stacktrace"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG stacktrace"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; #(
*) :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_stacktrace" >&5
$as_echo "$enable_stacktrace" >&6; }
as_fn_error $? "Unknown option \"$enable_stacktrace\". Use either \"yes\" or \"no\"." "$LINENO" 5 ;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable the GUI" >&5
$as_echo_n "checking whether to enable the GUI... " >&6; }
case "x$enable_gui" in #(
@ -4636,7 +4679,6 @@ esac @@ -4636,7 +4679,6 @@ esac
# Check whether --with-boost was given.
if test "${with_boost+set}" = set; then :
withval=$with_boost;

23
configure.ac

@ -24,6 +24,12 @@ AC_ARG_ENABLE(debug, @@ -24,6 +24,12 @@ AC_ARG_ENABLE(debug,
[],
[enable_debug=no])
AC_ARG_ENABLE(stacktrace,
[AS_HELP_STRING([--enable-stacktrace],
[Enable stacktrace feature (default=auto)])],
[],
[enable_stacktrace=auto])
AC_ARG_ENABLE(gui,
[AS_HELP_STRING([--disable-gui],
[Disable the GUI for headless running. Disables QtDBus and the GeoIP Database.])],
@ -80,6 +86,23 @@ AS_CASE(["x$enable_debug"], @@ -80,6 +86,23 @@ AS_CASE(["x$enable_debug"],
[AC_MSG_RESULT([$enable_debug])
AC_MSG_ERROR([Unknown option "$enable_debug". Use either "yes" or "no".])])
AC_MSG_CHECKING([whether to enable the stacktrace feature])
AS_CASE(["x$enable_stacktrace"],
["xno"],
[AC_MSG_RESULT([no])
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG stacktrace"],
["xyes"],
[AC_MSG_RESULT([yes])
QBT_ADD_CONFIG="$QBT_ADD_CONFIG stacktrace"],
["xauto"],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <execinfo.h>]])],
[AC_MSG_RESULT([yes])
QBT_ADD_CONFIG="$QBT_ADD_CONFIG stacktrace"],
[AC_MSG_RESULT([no])
QBT_REMOVE_CONFIG="$QBT_REMOVE_CONFIG stacktrace"])],
[AC_MSG_RESULT([$enable_stacktrace])
AC_MSG_ERROR([Unknown option "$enable_stacktrace". Use either "yes" or "no".])])
AC_MSG_CHECKING([whether to enable the GUI])
AS_CASE(["x$enable_gui"],
["xyes"],

6
src/CMakeLists.txt

@ -51,9 +51,9 @@ if (NOT WEBUI) @@ -51,9 +51,9 @@ if (NOT WEBUI)
add_definitions(-DDISABLE_WEBUI)
endif (NOT WEBUI)
if (STACKTRACE_WIN)
add_definitions(-DSTACKTRACE_WIN)
endif(STACKTRACE_WIN)
if (STACKTRACE)
add_definitions(-DSTACKTRACE)
endif(STACKTRACE)
# nogui {
# TARGET = qbittorrent-nox
# } else {

8
src/app/CMakeLists.txt

@ -53,16 +53,16 @@ if (WIN32) @@ -53,16 +53,16 @@ if (WIN32)
list(APPEND QBT_APP_SOURCES ../qbittorrent.exe.manifest)
endif (WIN32)
if (STACKTRACE)
if (UNIX)
list(APPEND QBT_APP_HEADERS stacktrace.h)
endif (UNIX)
if (STACKTRACE_WIN)
else (UNIX)
list(APPEND QBT_APP_HEADERS stacktrace_win.h)
if (GUI)
list(APPEND QBT_APP_HEADERS stacktrace_win_dlg.h)
endif (GUI)
endif (STACKTRACE_WIN)
endif (UNIX)
endif (STACKTRACE)
# usesystemqtsingleapplication {
# nogui {

8
src/app/app.pri

@ -25,14 +25,18 @@ SOURCES += \ @@ -25,14 +25,18 @@ SOURCES += \
$$PWD/filelogger.cpp \
$$PWD/main.cpp
unix: HEADERS += $$PWD/stacktrace.h
strace_win {
stacktrace {
unix {
HEADERS += $$PWD/stacktrace.h
}
else {
HEADERS += $$PWD/stacktrace_win.h
!nogui {
HEADERS += $$PWD/stacktrace_win_dlg.h
FORMS += $$PWD/stacktrace_win_dlg.ui
}
}
}
# upgrade code
HEADERS += $$PWD/upgrade.h

30
src/app/main.cpp

@ -57,17 +57,15 @@ Q_IMPORT_PLUGIN(QICOPlugin) @@ -57,17 +57,15 @@ Q_IMPORT_PLUGIN(QICOPlugin)
#endif
#endif // DISABLE_GUI
#ifdef Q_OS_UNIX
#include <signal.h>
#include <execinfo.h>
#ifdef STACKTRACE
#ifdef Q_OS_UNIX
#include "stacktrace.h"
#endif // Q_OS_UNIX
#ifdef STACKTRACE_WIN
#include <signal.h>
#else
#include "stacktrace_win.h"
#include "stacktrace_win_dlg.h"
#endif //STACKTRACE_WIN
#endif // Q_OS_UNIX
#endif //STACKTRACE
#include "application.h"
#include "base/profile.h"
@ -77,9 +75,10 @@ Q_IMPORT_PLUGIN(QICOPlugin) @@ -77,9 +75,10 @@ Q_IMPORT_PLUGIN(QICOPlugin)
#include "upgrade.h"
// Signal handlers
#if defined(Q_OS_UNIX) || defined(STACKTRACE_WIN)
void sigNormalHandler(int signum);
#ifdef STACKTRACE
void sigAbnormalHandler(int signum);
#endif
// sys_signame[] is only defined in BSD
const char *sysSigName[] = {
#if defined(Q_OS_WIN)
@ -94,7 +93,6 @@ const char *sysSigName[] = { @@ -94,7 +93,6 @@ const char *sysSigName[] = {
"SIGPWR", "SIGUNUSED"
#endif
};
#endif
#if !defined Q_OS_WIN && !defined Q_OS_HAIKU
void reportToUser(const char* str);
@ -255,9 +253,9 @@ int main(int argc, char *argv[]) @@ -255,9 +253,9 @@ int main(int argc, char *argv[])
showSplashScreen();
#endif
#if defined(Q_OS_UNIX) || defined(STACKTRACE_WIN)
signal(SIGINT, sigNormalHandler);
signal(SIGTERM, sigNormalHandler);
#ifdef STACKTRACE
signal(SIGABRT, sigAbnormalHandler);
signal(SIGSEGV, sigAbnormalHandler);
#endif
@ -281,7 +279,6 @@ void reportToUser(const char* str) @@ -281,7 +279,6 @@ void reportToUser(const char* str)
}
#endif
#if defined(Q_OS_UNIX) || defined(STACKTRACE_WIN)
void sigNormalHandler(int signum)
{
#if !defined Q_OS_WIN && !defined Q_OS_HAIKU
@ -295,6 +292,7 @@ void sigNormalHandler(int signum) @@ -295,6 +292,7 @@ void sigNormalHandler(int signum)
qApp->exit(); // unsafe, but exit anyway
}
#ifdef STACKTRACE
void sigAbnormalHandler(int signum)
{
const char *sigName = sysSigName[signum];
@ -307,16 +305,18 @@ void sigAbnormalHandler(int signum) @@ -307,16 +305,18 @@ void sigAbnormalHandler(int signum)
reportToUser(sigName);
reportToUser("\n");
print_stacktrace(); // unsafe
#endif // !defined Q_OS_WIN && !defined Q_OS_HAIKU
#ifdef STACKTRACE_WIN
#endif
#if defined Q_OS_WIN
StraceDlg dlg; // unsafe
dlg.setStacktraceString(QLatin1String(sigName), straceWin::getBacktrace());
dlg.exec();
#endif // STACKTRACE_WIN
#endif
signal(signum, SIG_DFL);
raise(signum);
}
#endif // defined(Q_OS_UNIX) || defined(STACKTRACE_WIN)
#endif // STACKTRACE
#if !defined(DISABLE_GUI)
void showSplashScreen()

8
src/src.pro

@ -33,14 +33,18 @@ nogui { @@ -33,14 +33,18 @@ nogui {
LIBS += -lobjc
}
}
nowebui {
DEFINES += DISABLE_WEBUI
}
strace_win {
DEFINES += STACKTRACE_WIN
stacktrace {
DEFINES += STACKTRACE
win32 {
DEFINES += STACKTRACE_WIN_PROJECT_PATH=$$PWD
DEFINES += STACKTRACE_WIN_MAKEFILE_PATH=$$OUT_PWD
}
}
CONFIG(debug, debug|release): message(Project is built in DEBUG mode.)
CONFIG(release, debug|release): message(Project is built in RELEASE mode.)

2
winconf.pri

@ -55,7 +55,7 @@ else { @@ -55,7 +55,7 @@ else {
}
# Stack trace support can be enabled in 'conf.pri'
strace_win {
stacktrace {
win32-g++* {
contains(QMAKE_HOST.arch, x86) {
# i686 arch requires frame pointer preservation

Loading…
Cancel
Save