Provide bmcweb-specific bmcweb exception handler
Providing our own boost exception handler, this has the benefits of:
1. Not generating the unwind stacks in the binary, which saves about 1%
on the total compressed binary size.
2. Allows us to start burning down all the places where we incorrectly
call boost methods that throw exceptions. Throwing exceptions to
master has caused exceptions in the past.
Tested:
No good way to test exceptional cases. Code inspection and compilation
only.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I0037ff72d09fd538543882dff771c3193a293e9f
diff --git a/meson.build b/meson.build
index 7bc594b..dd8eb81 100644
--- a/meson.build
+++ b/meson.build
@@ -244,9 +244,11 @@
'-DBOOST_ASIO_SEPARATE_COMPILATION',
'-DBOOST_BEAST_SEPARATE_COMPILATION',
'-DBOOST_EXCEPTION_DISABLE',
+ '-DBOOST_NO_EXCEPTIONS',
'-DBOOST_URL_NO_SOURCE_LOCATION',
'-DJSON_NOEXCEPTION',
'-DOPENSSL_NO_FILENAMES',
+ '-DSDBUSPLUS_DISABLE_BOOST_COROUTINES',
]),
language : 'cpp')
diff --git a/src/boost_asio.cpp b/src/boost_asio.cpp
index bf00c8f..53f2fd6 100644
--- a/src/boost_asio.cpp
+++ b/src/boost_asio.cpp
@@ -1 +1,22 @@
+#include "logging.hpp"
+
#include <boost/asio/impl/src.hpp>
+#include <boost/assert/source_location.hpp>
+
+#include <exception>
+
+namespace boost
+{
+void throw_exception(const std::exception& e)
+{
+ BMCWEB_LOG_CRITICAL << "Boost exception thrown " << e.what();
+ std::terminate();
+}
+
+void throw_exception(const std::exception& e, const source_location& loc)
+{
+ BMCWEB_LOG_CRITICAL << "Boost exception thrown " << e.what() << " from "
+ << loc;
+ std::terminate();
+}
+} // namespace boost