systemc: Fix a "problem" with kill/reset exceptions.
authorGabe Black <gabeblack@google.com>
Sat, 21 Jul 2018 05:13:14 +0000 (22:13 -0700)
committerGabe Black <gabeblack@google.com>
Tue, 11 Sep 2018 21:46:22 +0000 (21:46 +0000)
Despite what it says in the spec, the proc_ctrl compliance test throws
a copy of the reset exception it catches, not the original. Because of
that, the code in the kernel which catches the exception gets the base
class, not the derived class with overridden virtual methods, etc.
This happens to work for the Accellera implementation because they
manipulate members of the base class itself which are preserved despite
this bug. To make the test work, we imitate their implementation, even
though it exposes more implementation details through the header files.

Change-Id: I7ed9818c0552869ec790cb7f7bfbe365ade5e49c
Reviewed-on: https://gem5-review.googlesource.com/12045
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>

src/systemc/core/sc_process_handle.cc
src/systemc/ext/core/sc_process_handle.hh

index e0f6a8186dea347ad801b6cc9bd9a8851565b44b..256d64989ce8e55f40423893aa31152fb1af8258 100644 (file)
@@ -39,17 +39,19 @@ namespace sc_core
 const char *
 sc_unwind_exception::what() const throw()
 {
-    panic("%s for base class called.\n", __PRETTY_FUNCTION__);
+    return _isReset ? "RESET" : "KILL";
 }
 
 bool
 sc_unwind_exception::is_reset() const
 {
-    panic("%s for base class called.\n", __PRETTY_FUNCTION__);
+    return _isReset;
 }
 
-sc_unwind_exception::sc_unwind_exception() {}
-sc_unwind_exception::sc_unwind_exception(const sc_unwind_exception &) {}
+sc_unwind_exception::sc_unwind_exception() : _isReset(false) {}
+sc_unwind_exception::sc_unwind_exception(const sc_unwind_exception &e) :
+    _isReset(e._isReset)
+{}
 sc_unwind_exception::~sc_unwind_exception() throw() {}
 
 
index 2db553b7a1d121b611cdc89c42adfcef1e00b6de..8186903182c57d6e8fdbe01c1d870744f63e5d3d 100644 (file)
@@ -108,6 +108,7 @@ class sc_unwind_exception : public std::exception
     virtual ~sc_unwind_exception() throw();
 
   protected:
+    bool _isReset;
     sc_unwind_exception();
 };