+
+ // Parse error are handled differently, as the call stack does not matter, only the file location
+ catch (simgrid::ParseError& e) {
+ XBT_ERROR("%s", e.what());
+ XBT_ERROR("Exiting now.");
+ std::abort();
+ }
+
+ // We manage C++ exception ourselves
+ catch (std::exception& e) {
+ log_exception(xbt_log_priority_critical, "Uncaught exception", e);
+ show_backtrace(bt);
+ std::abort();
+ }
+
+ catch (const simgrid::ForcefulKillException&) {
+ XBT_ERROR("Received a ForcefulKillException at the top-level exception handler. Maybe a Java->C++ call that is not "
+ "protected in a try/catch?");
+ show_backtrace(bt);
+ }
+
+ // We don't know how to manage other exceptions
+ catch (...) {
+ // If there was another handler let's delegate to it
+ if (previous_terminate_handler)
+ previous_terminate_handler();
+ else {
+ XBT_ERROR("Unknown uncaught exception");
+ show_backtrace(bt);
+ std::abort();
+ }
+ }
+ XBT_INFO("BAM");
+}
+
+void install_exception_handler()
+{
+ static std::once_flag handler_flag;
+ std::call_once(handler_flag, [] {
+ previous_terminate_handler = std::set_terminate(handler);
+ });