summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorPaul Wicks <pwicks86@gmail.com>2018-07-10 13:38:27 -0700
committerMarcus Müller <marcus@hostalia.de>2020-12-19 12:59:25 +0100
commit6d6c9a254102374d3fdbc4c39eac0b67e07168b7 (patch)
tree62028d8c95483062382c334bb4cdb8ef98fa5967 /cmake
parenta5e49d9120e8d0d7adf4de792cc3c4bc1a6defbc (diff)
runtime: Add terminate handling
This consists of the following changes: 1. Add a top_block parameter to control exception handling This restores past behavior where the scheduler catches exceptions raised in block threads, allowing flowgraphs to continue running after the failure of an individual block. It also adds optional new behavior, selected by setting catch_exceptions=False to the top block, which causes exceptions to not be caught. In this mode of operation, a std::terminate handler can be installed to print a stack trace before the flowgraph exits. 2. Add terminate_handler to top_block_impl This adds a terminate_handler function that prints information about any uncaught exceptions and also attempts to print a backtrace for said exception after which it calls std::abort. The backtrace is printed via libunwind, which is a new optional dependency. If libunwind is not found/installed, then the terminate handler will still print information about the exception and then exit. Co-Authored-By: Scott Torborg <storborg@gmail.com>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Modules/Findlibunwind.cmake29
1 files changed, 29 insertions, 0 deletions
diff --git a/cmake/Modules/Findlibunwind.cmake b/cmake/Modules/Findlibunwind.cmake
new file mode 100644
index 0000000000..1985a9fd4b
--- /dev/null
+++ b/cmake/Modules/Findlibunwind.cmake
@@ -0,0 +1,29 @@
+# - Try to find libunwind
+# Once done, this will define
+#
+# libunwind_FOUND - system has libunwind
+# libunwind_INCLUDE_DIRS - the libunwind include directories
+# libunwind_LIBRARIES - link these to use libunwind
+
+include(LibFindMacros)
+
+# Use pkg-config to get hints about paths
+libfind_pkg_check_modules(libunwind_PKGCONF libunwind)
+
+# Include dir
+find_path(libunwind_INCLUDE_DIR
+ NAMES libunwind.h
+ PATHS ${libunwind_PKGCONF_INCLUDE_DIRS}
+)
+
+# Finally the library itself
+find_library(libunwind_LIBRARY
+ NAMES unwind
+ PATHS ${libunwind_PKGCONF_LIBRARY_DIRS}
+)
+
+# Set the include dir variables and the libraries and let libfind_process do the rest.
+# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
+set(libunwind_PROCESS_INCLUDES ${libunwind_INCLUDE_DIR})
+set(libunwind_PROCESS_LIBS libunwind_LIBRARY)
+libfind_process(libunwind)