From 6d6c9a254102374d3fdbc4c39eac0b67e07168b7 Mon Sep 17 00:00:00 2001
From: Paul Wicks <pwicks86@gmail.com>
Date: Tue, 10 Jul 2018 13:38:27 -0700
Subject: 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>
---
 gnuradio-runtime/lib/terminate_handler.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 gnuradio-runtime/lib/terminate_handler.h

(limited to 'gnuradio-runtime/lib/terminate_handler.h')

diff --git a/gnuradio-runtime/lib/terminate_handler.h b/gnuradio-runtime/lib/terminate_handler.h
new file mode 100644
index 0000000000..a7a671b06a
--- /dev/null
+++ b/gnuradio-runtime/lib/terminate_handler.h
@@ -0,0 +1,19 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2018 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#ifndef INCLUDED_GR_TERMINATE_HANDLER_H
+#define INCLUDED_GR_TERMINATE_HANDLER_H
+
+#include <gnuradio/api.h>
+
+namespace gr {
+void install_terminate_handler() GR_RUNTIME_API;
+}
+
+#endif /* INCLUDED_TERMINATE_HANDLER_H */
-- 
cgit v1.2.3