36a37,38
> #include "systemc/ext/utils/sc_report.hh"
> #include "systemc/ext/utils/sc_report_handler.hh"
45c47
< scMain(nullptr),
---
> scMain(nullptr), _throwToScMain(nullptr),
187c189,193
< _current->run();
---
> try {
> _current->run();
> } catch (...) {
> throwToScMain();
> }
339c345,346
< scMain->run();
---
> if (scMain && !scMain->finished())
> scMain->run();
351c358,359
< scMain->run();
---
> if (scMain && !scMain->finished())
> scMain->run();
387a396,401
>
> if (_throwToScMain) {
> const ::sc_core::sc_report *to_throw = _throwToScMain;
> _throwToScMain = nullptr;
> throw *to_throw;
> }
407a422,430
> Scheduler::throwToScMain(const ::sc_core::sc_report *r)
> {
> if (!r)
> r = reportifyException();
> _throwToScMain = r;
> scMain->run();
> }
>
> void
423a447,488
> namespace {
>
> void
> throwingReportHandler(const ::sc_core::sc_report &r,
> const ::sc_core::sc_actions &)
> {
> throw r;
> }
>
> } // anonymous namespace
>
> const ::sc_core::sc_report *
> reportifyException()
> {
> ::sc_core::sc_report_handler_proc old_handler =
> ::sc_core::sc_report_handler::get_handler();
> ::sc_core::sc_report_handler::set_handler(&throwingReportHandler);
>
> try {
> try {
> // Rethrow the current exception so we can catch it and throw an
> // sc_report instead if it's not a type we recognize/can handle.
> throw;
> } catch (const ::sc_core::sc_report &) {
> // It's already a sc_report, so nothing to do.
> throw;
> } catch (const ::sc_core::sc_unwind_exception &) {
> panic("Kill/reset exception escaped a Process::run()");
> } catch (const std::exception &e) {
> SC_REPORT_ERROR("uncaught exception", e.what());
> } catch (const char *msg) {
> SC_REPORT_ERROR("uncaught exception", msg);
> } catch (...) {
> SC_REPORT_ERROR("uncaught exception", "UNKNOWN EXCEPTION");
> }
> } catch (const ::sc_core::sc_report &r) {
> ::sc_core::sc_report_handler::set_handler(old_handler);
> return &r;
> }
> panic("No exception thrown in reportifyException.");
> }
>