[gem5-dev] [M] Change in gem5/gem5[develop]: systemc: Add facilities to add extra SystemC message handlers

2023-01-07 Thread Nicolas Boichat (Gerrit) via gem5-dev
Nicolas Boichat has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67234?usp=email )


Change subject: systemc: Add facilities to add extra SystemC message  
handlers

..

systemc: Add facilities to add extra SystemC message handlers

Some clients (e.g. fastmodel integration) would like to catch specific
warning messages from SystemC. Adding facilities to chain extra report
handler (instead of just replacing the default one), that are run
after the default/set handler.

Change-Id: I8ef140fc897ae5eee0fc78c70caf081f625efbfd
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67234
Reviewed-by: Gabe Black 
Maintainer: Gabe Black 
Tested-by: kokoro 
---
M src/systemc/utils/report.cc
M src/systemc/utils/report.hh
M src/systemc/utils/sc_report_handler.cc
3 files changed, 55 insertions(+), 0 deletions(-)

Approvals:
  Gabe Black: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/systemc/utils/report.cc b/src/systemc/utils/report.cc
index 2b15fce..5f3425f 100644
--- a/src/systemc/utils/report.cc
+++ b/src/systemc/utils/report.cc
@@ -68,6 +68,31 @@
 sc_core::sc_report_handler_proc reportHandlerProc =
 _core::sc_report_handler::default_handler;

+namespace
+{
+
+std::list extraReportHandlerProcs;
+
+} // anonymous namespace
+
+const std::list &
+getExtraSystemCReportHandlers()
+{
+return extraReportHandlerProcs;
+}
+
+void
+addExtraSystemCReportHandler(sc_core::sc_report_handler_proc proc)
+{
+extraReportHandlerProcs.push_back(proc);
+}
+
+void
+removeExtraSystemCReportHandler(sc_core::sc_report_handler_proc proc)
+{
+extraReportHandlerProcs.remove(proc);
+}
+
 std::unique_ptr globalReportCache;

 bool reportWarningsAsErrors = false;
diff --git a/src/systemc/utils/report.hh b/src/systemc/utils/report.hh
index 1f12eef..d7ea340 100644
--- a/src/systemc/utils/report.hh
+++ b/src/systemc/utils/report.hh
@@ -29,6 +29,7 @@
 #define __SYSTEMC_UTILS_REPORT_HH__

 #include 
+#include 
 #include 
 #include 
 #include 
@@ -103,6 +104,13 @@

 extern sc_core::sc_report_handler_proc reportHandlerProc;

+// gem5-specific support for extra SystemC report handlers. Called _after_
+// the default/set handler.
+const std::list
+();
+void addExtraSystemCReportHandler(sc_core::sc_report_handler_proc proc);
+void removeExtraSystemCReportHandler(sc_core::sc_report_handler_proc proc);
+
 extern std::unique_ptr globalReportCache;

 extern bool reportWarningsAsErrors;
diff --git a/src/systemc/utils/sc_report_handler.cc  
b/src/systemc/utils/sc_report_handler.cc

index b893b1d..3421ab9 100644
--- a/src/systemc/utils/sc_report_handler.cc
+++ b/src/systemc/utils/sc_report_handler.cc
@@ -103,6 +103,10 @@
 }

 sc_gem5::reportHandlerProc(report, actions);
+
+for (auto& handler : sc_gem5::getExtraSystemCReportHandlers()) {
+handler(report, actions);
+}
 }

 void

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67234?usp=email
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I8ef140fc897ae5eee0fc78c70caf081f625efbfd
Gerrit-Change-Number: 67234
Gerrit-PatchSet: 2
Gerrit-Owner: Nicolas Boichat 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Nicolas Boichat 
Gerrit-Reviewer: kokoro 
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [M] Change in gem5/gem5[develop]: systemc: Add facilities to add extra SystemC message handlers

2023-01-06 Thread Nicolas Boichat (Gerrit) via gem5-dev
Nicolas Boichat has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67234?usp=email )



Change subject: systemc: Add facilities to add extra SystemC message  
handlers

..

systemc: Add facilities to add extra SystemC message handlers

Some clients (e.g. fastmodel integration) would like to catch specific
warning messages from SystemC. Adding facilities to chain extra report
handler (instead of just replacing the default one), that are run
after the default/set handler.

Change-Id: I8ef140fc897ae5eee0fc78c70caf081f625efbfd
---
M src/systemc/utils/report.cc
M src/systemc/utils/report.hh
M src/systemc/utils/sc_report_handler.cc
3 files changed, 51 insertions(+), 0 deletions(-)



diff --git a/src/systemc/utils/report.cc b/src/systemc/utils/report.cc
index 2b15fce..5f3425f 100644
--- a/src/systemc/utils/report.cc
+++ b/src/systemc/utils/report.cc
@@ -68,6 +68,31 @@
 sc_core::sc_report_handler_proc reportHandlerProc =
 _core::sc_report_handler::default_handler;

+namespace
+{
+
+std::list extraReportHandlerProcs;
+
+} // anonymous namespace
+
+const std::list &
+getExtraSystemCReportHandlers()
+{
+return extraReportHandlerProcs;
+}
+
+void
+addExtraSystemCReportHandler(sc_core::sc_report_handler_proc proc)
+{
+extraReportHandlerProcs.push_back(proc);
+}
+
+void
+removeExtraSystemCReportHandler(sc_core::sc_report_handler_proc proc)
+{
+extraReportHandlerProcs.remove(proc);
+}
+
 std::unique_ptr globalReportCache;

 bool reportWarningsAsErrors = false;
diff --git a/src/systemc/utils/report.hh b/src/systemc/utils/report.hh
index 1f12eef..d7ea340 100644
--- a/src/systemc/utils/report.hh
+++ b/src/systemc/utils/report.hh
@@ -29,6 +29,7 @@
 #define __SYSTEMC_UTILS_REPORT_HH__

 #include 
+#include 
 #include 
 #include 
 #include 
@@ -103,6 +104,13 @@

 extern sc_core::sc_report_handler_proc reportHandlerProc;

+// gem5-specific support for extra SystemC report handlers. Called _after_
+// the default/set handler.
+const std::list
+();
+void addExtraSystemCReportHandler(sc_core::sc_report_handler_proc proc);
+void removeExtraSystemCReportHandler(sc_core::sc_report_handler_proc proc);
+
 extern std::unique_ptr globalReportCache;

 extern bool reportWarningsAsErrors;
diff --git a/src/systemc/utils/sc_report_handler.cc  
b/src/systemc/utils/sc_report_handler.cc

index b893b1d..3421ab9 100644
--- a/src/systemc/utils/sc_report_handler.cc
+++ b/src/systemc/utils/sc_report_handler.cc
@@ -103,6 +103,10 @@
 }

 sc_gem5::reportHandlerProc(report, actions);
+
+for (auto& handler : sc_gem5::getExtraSystemCReportHandlers()) {
+handler(report, actions);
+}
 }

 void

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67234?usp=email
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I8ef140fc897ae5eee0fc78c70caf081f625efbfd
Gerrit-Change-Number: 67234
Gerrit-PatchSet: 1
Gerrit-Owner: Nicolas Boichat 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org