Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/12965
Change subject: systemc: Add some error checks to sc_export.
......................................................................
systemc: Add some error checks to sc_export.
Change-Id: Ib0c14a5c7dad37b33d61c9b406f6b84121d94e46
---
M src/systemc/ext/core/sc_export.hh
A
src/systemc/tests/systemc/communication/sc_export/test02/expected_returncode
A
src/systemc/tests/systemc/communication/sc_export/test04/expected_returncode
3 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/src/systemc/ext/core/sc_export.hh
b/src/systemc/ext/core/sc_export.hh
index e8bf0d9..e36e34a 100644
--- a/src/systemc/ext/core/sc_export.hh
+++ b/src/systemc/ext/core/sc_export.hh
@@ -30,6 +30,7 @@
#ifndef __SYSTEMC_EXT_CORE_SC_EXPORT_HH__
#define __SYSTEMC_EXT_CORE_SC_EXPORT_HH__
+#include "../utils/sc_report_handler.hh"
#include "sc_module.hh" // for sc_gen_unique_name
#include "sc_object.hh"
@@ -71,19 +72,58 @@
virtual const char *kind() const { return "sc_export"; }
void operator () (IF &i) { bind(i); }
- virtual void bind(IF &i) { interface = &i; }
- operator IF & () { return *interface; }
+ virtual void
+ bind(IF &i)
+ {
+ if (interface) {
+ SC_REPORT_ERROR("(E126) sc_export instance already bound",
name());
+ return;
+ }
+ interface = &i;
+ }
+ operator IF & ()
+ {
+ if (!interface) {
+ SC_REPORT_ERROR("(E120) sc_export instance has no interface",
+ name());
+ }
+ return *interface;
+ }
operator const IF & () const { return *interface; }
- IF *operator -> () { return interface; }
- const IF *operator -> () const { return interface; }
+ IF *
+ operator -> ()
+ {
+ if (!interface) {
+ SC_REPORT_ERROR("(E120) sc_export instance has no interface",
+ name());
+ }
+ return interface;
+ }
+ const IF *
+ operator -> () const
+ {
+ if (!interface) {
+ SC_REPORT_ERROR("(E120) sc_export instance has no interface",
+ name());
+ }
+ return interface;
+ }
sc_interface *get_iterface() override { return interface; }
const sc_interface *get_interface() const override { return interface;
}
protected:
void before_end_of_elaboration() {}
- void end_of_elaboration() {}
+ void
+ end_of_elaboration()
+ {
+ if (!interface) {
+ std::string msg = "export not bound: export '";
+ msg = msg + name() + "' (" + kind() + ")";
+ SC_REPORT_ERROR("(E109) complete binding failed", msg.c_str());
+ }
+ }
void start_of_simulation() {}
void end_of_simulation() {}
diff --git
a/src/systemc/tests/systemc/communication/sc_export/test02/expected_returncode
b/src/systemc/tests/systemc/communication/sc_export/test02/expected_returncode
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++
b/src/systemc/tests/systemc/communication/sc_export/test02/expected_returncode
@@ -0,0 +1 @@
+1
diff --git
a/src/systemc/tests/systemc/communication/sc_export/test04/expected_returncode
b/src/systemc/tests/systemc/communication/sc_export/test04/expected_returncode
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++
b/src/systemc/tests/systemc/communication/sc_export/test04/expected_returncode
@@ -0,0 +1 @@
+1
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12965
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: Ib0c14a5c7dad37b33d61c9b406f6b84121d94e46
Gerrit-Change-Number: 12965
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev