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 <gabe.bl...@gmail.com>
Maintainer: Gabe Black <gabe.bl...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
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 =
     &sc_core::sc_report_handler::default_handler;

+namespace
+{
+
+std::list<sc_core::sc_report_handler_proc> extraReportHandlerProcs;
+
+} // anonymous namespace
+
+const std::list<sc_core::sc_report_handler_proc> &
+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<sc_core::sc_report> 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 <initializer_list>
+#include <list>
 #include <map>
 #include <memory>
 #include <string>
@@ -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<sc_core::sc_report_handler_proc>
+    &getExtraSystemCReportHandlers();
+void addExtraSystemCReportHandler(sc_core::sc_report_handler_proc proc);
+void removeExtraSystemCReportHandler(sc_core::sc_report_handler_proc proc);
+
 extern std::unique_ptr<sc_core::sc_report> 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 <drink...@google.com>
Gerrit-Reviewer: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: Nicolas Boichat <drink...@google.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org

Reply via email to