From adfaf8c33ccc3976aa2a0109b7d54b87efdbbfe1 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 18 Jan 2017 16:05:18 +0100 Subject: gdb mode that can be used to attach a debugger --- synchronizer/main.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/synchronizer/main.cpp b/synchronizer/main.cpp index 7b9165e..b228248 100644 --- a/synchronizer/main.cpp +++ b/synchronizer/main.cpp @@ -136,10 +136,16 @@ void terminateHandler() int main(int argc, char *argv[]) { - // For crashes - std::signal(SIGSEGV, crashHandler); - std::signal(SIGABRT, crashHandler); - std::set_terminate(terminateHandler); + const bool gdbDebugMode = qEnvironmentVariableIsSet("SINK_GDB_DEBUG"); + if (gdbDebugMode) { + SinkWarning() << "Running resource in debug mode and waiting for gdb to attach: gdb attach " << getpid(); + raise(SIGSTOP); + } else { + // For crashes + std::signal(SIGSEGV, crashHandler); + std::signal(SIGABRT, crashHandler); + std::set_terminate(terminateHandler); + } QCoreApplication app(argc, argv); app.setQuitLockEnabled(false); -- cgit v1.2.3