diff --git a/src/systemc/utils/report.cc b/src/systemc/utils/report.cc index 2b15fced8c..5f3425f398 100644 --- a/src/systemc/utils/report.cc +++ b/src/systemc/utils/report.cc @@ -68,6 +68,31 @@ sc_core::sc_actions reportCatchActions = sc_core::SC_DISPLAY; sc_core::sc_report_handler_proc reportHandlerProc = &sc_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 1f12eef6a8..d7ea3401e3 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_actions reportCatchActions; 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 + &getExtraSystemCReportHandlers(); +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 b893b1dff3..3421ab912d 100644 --- a/src/systemc/utils/sc_report_handler.cc +++ b/src/systemc/utils/sc_report_handler.cc @@ -103,6 +103,10 @@ sc_report_handler::report(sc_severity severity, const char *msg_type, } sc_gem5::reportHandlerProc(report, actions); + + for (auto& handler : sc_gem5::getExtraSystemCReportHandlers()) { + handler(report, actions); + } } void