Gabe Black has submitted this change and it was merged. (
https://gem5-review.googlesource.com/c/public/gem5/+/12440 )
Change subject: systemc: Improve handling of empty process handles.
......................................................................
systemc: Improve handling of empty process handles.
Most had checks, but didn't print any message. throw_it needed a check
as well.
Change-Id: I916c837112f9b27852583f01b3e16a6f53d5e7ca
Reviewed-on: https://gem5-review.googlesource.com/c/12440
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
---
M src/systemc/core/sc_process_handle.cc
M src/systemc/ext/core/sc_process_handle.hh
M src/systemc/ext/utils/sc_report.hh
3 files changed, 58 insertions(+), 18 deletions(-)
Approvals:
Gabe Black: Looks good to me, approved; Looks good to me, approved
diff --git a/src/systemc/core/sc_process_handle.cc
b/src/systemc/core/sc_process_handle.cc
index 8c756af..c7701a6 100644
--- a/src/systemc/core/sc_process_handle.cc
+++ b/src/systemc/core/sc_process_handle.cc
@@ -32,6 +32,7 @@
#include "systemc/core/scheduler.hh"
#include "systemc/ext/core/sc_main.hh"
#include "systemc/ext/core/sc_process_handle.hh"
+#include "systemc/ext/utils/sc_report_handler.hh"
namespace sc_core
{
@@ -196,56 +197,79 @@
const sc_event &
sc_process_handle::terminated_event() const
{
- static sc_event non_event;
- return _gem5_process ? _gem5_process->terminatedEvent() : non_event;
+ if (!_gem5_process) {
+ SC_REPORT_WARNING("(W570) attempt to use an empty "
+ "process handle ignored", "terminated_event()");
+ static sc_event non_event;
+ return non_event;
+ }
+ return _gem5_process->terminatedEvent();
}
void
sc_process_handle::suspend(sc_descendent_inclusion_info
include_descendants)
{
- if (!_gem5_process)
+ if (!_gem5_process) {
+ SC_REPORT_WARNING("(W570) attempt to use an empty "
+ "process handle ignored", "suspend()");
return;
+ }
_gem5_process->suspend(include_descendants == SC_INCLUDE_DESCENDANTS);
}
void
sc_process_handle::resume(sc_descendent_inclusion_info include_descendants)
{
- if (!_gem5_process)
+ if (!_gem5_process) {
+ SC_REPORT_WARNING("(W570) attempt to use an empty "
+ "process handle ignored", "resume()");
return;
+ }
_gem5_process->resume(include_descendants == SC_INCLUDE_DESCENDANTS);
}
void
sc_process_handle::disable(sc_descendent_inclusion_info
include_descendants)
{
- if (!_gem5_process)
+ if (!_gem5_process) {
+ SC_REPORT_WARNING("(W570) attempt to use an empty "
+ "process handle ignored", "disable()");
return;
+ }
_gem5_process->disable(include_descendants == SC_INCLUDE_DESCENDANTS);
}
void
sc_process_handle::enable(sc_descendent_inclusion_info include_descendants)
{
- if (!_gem5_process)
+ if (!_gem5_process) {
+ SC_REPORT_WARNING("(W570) attempt to use an empty "
+ "process handle ignored", "enable()");
return;
+ }
_gem5_process->enable(include_descendants == SC_INCLUDE_DESCENDANTS);
}
void
sc_process_handle::kill(sc_descendent_inclusion_info include_descendants)
{
- if (!_gem5_process)
+ if (!_gem5_process) {
+ SC_REPORT_WARNING("(W570) attempt to use an empty "
+ "process handle ignored", "kill()");
return;
+ }
_gem5_process->kill(include_descendants == SC_INCLUDE_DESCENDANTS);
}
void
sc_process_handle::reset(sc_descendent_inclusion_info include_descendants)
{
- if (!_gem5_process)
+ if (!_gem5_process) {
+ SC_REPORT_WARNING("(W570) attempt to use an empty "
+ "process handle ignored", "reset()");
return;
+ }
_gem5_process->reset(include_descendants == SC_INCLUDE_DESCENDANTS);
}
@@ -253,19 +277,23 @@
sc_process_handle::is_unwinding()
{
if (!_gem5_process) {
- //TODO This should generate a systemc style warning if the handle
is
- //invalid.
+ SC_REPORT_WARNING("(W570) attempt to use an empty "
+ "process handle ignored", "is_unwinding()");
return false;
- } else {
- return _gem5_process->isUnwinding();
}
+ return _gem5_process->isUnwinding();
}
const sc_event &
sc_process_handle::reset_event() const
{
- static sc_event non_event;
- return _gem5_process ? _gem5_process->resetEvent() : non_event;
+ if (!_gem5_process) {
+ SC_REPORT_WARNING("(W570) attempt to use an empty "
+ "process handle ignored", "reset()");
+ static sc_event non_event;
+ return non_event;
+ }
+ return _gem5_process->resetEvent();
}
@@ -273,8 +301,11 @@
sc_process_handle::sync_reset_on(
sc_descendent_inclusion_info include_descendants)
{
- if (!_gem5_process)
+ if (!_gem5_process) {
+ SC_REPORT_WARNING("(W570) attempt to use an empty "
+ "process handle ignored", "sync_reset_on()");
return;
+ }
_gem5_process->syncResetOn(include_descendants ==
SC_INCLUDE_DESCENDANTS);
}
@@ -282,8 +313,11 @@
sc_process_handle::sync_reset_off(
sc_descendent_inclusion_info include_descendants)
{
- if (!_gem5_process)
+ if (!_gem5_process) {
+ SC_REPORT_WARNING("(W570) attempt to use an empty "
+ "process handle ignored", "sync_reset_off()");
return;
+ }
_gem5_process->syncResetOff(include_descendants ==
SC_INCLUDE_DESCENDANTS);
}
diff --git a/src/systemc/ext/core/sc_process_handle.hh
b/src/systemc/ext/core/sc_process_handle.hh
index 04df472..b9bb9a0 100644
--- a/src/systemc/ext/core/sc_process_handle.hh
+++ b/src/systemc/ext/core/sc_process_handle.hh
@@ -33,7 +33,8 @@
#include <exception>
#include <vector>
-#include "systemc/ext/core/sc_object.hh"
+#include "../utils/sc_report_handler.hh"
+#include "sc_object.hh"
namespace sc_gem5
{
@@ -212,6 +213,11 @@
sc_descendent_inclusion_info include_descendants=
SC_NO_DESCENDANTS)
{
+ if (!_gem5_process) {
+ SC_REPORT_WARNING("(W570) attempt to use an empty "
+ "process handle ignored", "throw_it()");
+ return;
+ }
::sc_gem5::ExceptionWrapper<T> exc(user_defined_exception);
::sc_gem5::throw_it_wrapper(_gem5_process, exc,
include_descendants == SC_INCLUDE_DESCENDANTS);
diff --git a/src/systemc/ext/utils/sc_report.hh
b/src/systemc/ext/utils/sc_report.hh
index 6f652ce..19029ec 100644
--- a/src/systemc/ext/utils/sc_report.hh
+++ b/src/systemc/ext/utils/sc_report.hh
@@ -33,7 +33,7 @@
#include <exception>
#include <string>
-#include "systemc/ext/core/sc_time.hh"
+#include "../core/sc_time.hh"
namespace sc_core
{
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12440
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: I916c837112f9b27852583f01b3e16a6f53d5e7ca
Gerrit-Change-Number: 12440
Gerrit-PatchSet: 7
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Matthias Jung <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev