Gabe Black has submitted this change and it was merged. (
https://gem5-review.googlesource.com/c/public/gem5/+/12251 )
Change subject: systemc: If no sc_module_name was used, throw an error.
......................................................................
systemc: If no sc_module_name was used, throw an error.
This is tested by the regression tests. Also make sure the handshake
which sets up instances of sc_module is cleaned up if we bail partway
through for some reason, for instance if an intermediate class throws
an exception as part of its constructor.
Change-Id: I89afe5f76832cc132aa2bb8f19916dea64546784
Reviewed-on: https://gem5-review.googlesource.com/12251
Reviewed-by: Gabe Black <gabebl...@google.com>
Maintainer: Gabe Black <gabebl...@google.com>
---
M src/systemc/core/module.cc
M src/systemc/core/module.hh
M src/systemc/core/sc_module.cc
3 files changed, 22 insertions(+), 2 deletions(-)
Approvals:
Gabe Black: Looks good to me, approved; Looks good to me, approved
diff --git a/src/systemc/core/module.cc b/src/systemc/core/module.cc
index b13b50d..0c118e0 100644
--- a/src/systemc/core/module.cc
+++ b/src/systemc/core/module.cc
@@ -32,6 +32,7 @@
#include <cassert>
#include "base/logging.hh"
+#include "systemc/ext/utils/sc_report_handler.hh"
namespace sc_gem5
{
@@ -52,7 +53,14 @@
_new_module = this;
}
-Module::~Module() { allModules.remove(this); }
+Module::~Module()
+{
+ if (_new_module == this) {
+ // Aborted module construction?
+ _new_module = nullptr;
+ }
+ allModules.remove(this);
+}
void
Module::finish(Object *this_obj)
@@ -86,6 +94,17 @@
}
Module *
+newModuleChecked()
+{
+ if (!_new_module) {
+ SC_REPORT_ERROR("(E533) module name stack is empty: "
+ "did you forget to add a sc_module_name parameter to "
+ "your module constructor?", nullptr);
+ }
+ return _new_module;
+}
+
+Module *
newModule()
{
return _new_module;
diff --git a/src/systemc/core/module.hh b/src/systemc/core/module.hh
index e988b96..e276dad 100644
--- a/src/systemc/core/module.hh
+++ b/src/systemc/core/module.hh
@@ -116,6 +116,7 @@
};
Module *currentModule();
+Module *newModuleChecked();
Module *newModule();
void callbackModule(Module *m);
diff --git a/src/systemc/core/sc_module.cc b/src/systemc/core/sc_module.cc
index 016b9ed..c515aaf 100644
--- a/src/systemc/core/sc_module.cc
+++ b/src/systemc/core/sc_module.cc
@@ -168,7 +168,7 @@
}
sc_module::sc_module() :
- sc_object(sc_gem5::newModule()->name()),
+ sc_object(sc_gem5::newModuleChecked()->name()),
_gem5_module(sc_gem5::currentModule())
{}
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12251
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I89afe5f76832cc132aa2bb8f19916dea64546784
Gerrit-Change-Number: 12251
Gerrit-PatchSet: 8
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: Matthias Jung <jun...@eit.uni-kl.de>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev