systemc: Use the "catch action" and the handler func outside sc_main.

If an exception escapes sc_main, Accellera catches it and feeds it
into the report handler, telling it to run the catch actions. This
seems like it sets up lots of dangerous scenarios, and also makes a
vital error detecting path more complex and error prone.

On the other hand, it makes one of the tests pass.

Change-Id: I7f9d07e01e63c7abeee903febe2e434041ec49a4
Reviewed-on: https://gem5-review.googlesource.com/c/13307
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
This commit is contained in:
Gabe Black
2018-10-05 16:45:55 -07:00
parent 98b74c4e51
commit cb1cd5af89
2 changed files with 7 additions and 3 deletions

View File

@@ -78,10 +78,15 @@ class ScMainFiber : public Fiber
// after sc_main returns.
} catch (const sc_report &r) {
// There was an exception nobody caught.
resultStr = r.what();
resultStr = "uncaught sc_report";
sc_report_handler::get_handler()(
r, sc_report_handler::get_catch_actions());
} catch (...) {
// There was some other type of exception we need to wrap.
resultStr = ::sc_gem5::reportifyException().what();
resultStr = "uncaught exception";
sc_report_handler::get_handler()(
::sc_gem5::reportifyException(),
sc_report_handler::get_catch_actions());
}
::sc_gem5::Kernel::scMainFinished(true);
::sc_gem5::scheduler.clear();

View File

@@ -59,5 +59,4 @@ if result.code != 0:
# generate errors, and as long as their output matches that's still
# considered correct. A "real" systemc config should expect sc_main
# (if present) not to fail.
print('\n' + result.message)
sys.exit(int(result.code))