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.black@gmail.com>
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Nicolas Boichat
2023-01-05 03:24:29 +00:00
parent 68cf65e9b5
commit 8aa9f52953
3 changed files with 37 additions and 0 deletions

View File

@@ -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<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;

View File

@@ -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_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<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;

View File

@@ -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