summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/systemc/utils/report.cc3
-rw-r--r--src/systemc/utils/report.hh3
-rw-r--r--src/systemc/utils/sc_report.cc63
-rw-r--r--src/systemc/utils/sc_report_handler.cc14
4 files changed, 66 insertions, 17 deletions
diff --git a/src/systemc/utils/report.cc b/src/systemc/utils/report.cc
index 413726eb7..9c26edea3 100644
--- a/src/systemc/utils/report.cc
+++ b/src/systemc/utils/report.cc
@@ -48,6 +48,7 @@ ReportSevInfo reportSevInfos[sc_core::SC_MAX_SEVERITY] =
};
std::map<std::string, ReportMsgInfo> reportMsgInfoMap;
+std::map<int, std::string> reportIdToMsgMap;
int reportVerbosityLevel = sc_core::SC_MEDIUM;
@@ -60,4 +61,6 @@ sc_core::sc_report_handler_proc reportHandlerProc =
std::unique_ptr<sc_core::sc_report> globalReportCache;
+bool reportWarningsAsErrors = false;
+
} // namespace sc_gem5
diff --git a/src/systemc/utils/report.hh b/src/systemc/utils/report.hh
index ea0201ff8..e0b2e2598 100644
--- a/src/systemc/utils/report.hh
+++ b/src/systemc/utils/report.hh
@@ -92,6 +92,7 @@ struct ReportSevInfo
extern const char *reportSeverityNames[sc_core::SC_MAX_SEVERITY];
extern ReportSevInfo reportSevInfos[sc_core::SC_MAX_SEVERITY];
extern std::map<std::string, ReportMsgInfo> reportMsgInfoMap;
+extern std::map<int, std::string> reportIdToMsgMap;
extern int reportVerbosityLevel;
@@ -103,6 +104,8 @@ extern sc_core::sc_report_handler_proc reportHandlerProc;
extern std::unique_ptr<sc_core::sc_report> globalReportCache;
+extern bool reportWarningsAsErrors;
+
} // namespace sc_gem5
#endif // __SYSTEMC_UTILS_REPORT_HH__
diff --git a/src/systemc/utils/sc_report.cc b/src/systemc/utils/sc_report.cc
index 77da92b57..83e066269 100644
--- a/src/systemc/utils/sc_report.cc
+++ b/src/systemc/utils/sc_report.cc
@@ -32,6 +32,7 @@
#include "base/logging.hh"
#include "systemc/ext/utils/sc_report.hh"
#include "systemc/ext/utils/sc_report_handler.hh"
+#include "systemc/utils/report.hh"
namespace sc_core
{
@@ -87,45 +88,81 @@ sc_report::what() const throw()
const char *
sc_report::get_message(int id)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
- return "";
+ auto it = sc_gem5::reportIdToMsgMap.find(id);
+ if (it == sc_gem5::reportIdToMsgMap.end())
+ return "unknown id";
+ else
+ return it->second.c_str();
}
bool
sc_report::is_suppressed(int id)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
- return false;
+ auto it = sc_gem5::reportIdToMsgMap.find(id);
+ if (it == sc_gem5::reportIdToMsgMap.end())
+ return false;
+
+ return sc_gem5::reportMsgInfoMap[it->second].actions == SC_DO_NOTHING;
}
void
-sc_report::make_warnings_errors(bool)
+sc_report::make_warnings_errors(bool val)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ sc_gem5::reportWarningsAsErrors = val;
}
void
sc_report::register_id(int id, const char *msg)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ if (id < 0) {
+ SC_REPORT_ERROR("(E800) register_id failed", "invalid report id");
+ return;
+ }
+ if (!msg) {
+ SC_REPORT_ERROR("(E800) register_id failed", "invalid report message");
+ return;
+ }
+ auto p = sc_gem5::reportIdToMsgMap.insert(
+ std::pair<int, std::string>(id, msg));
+ if (!p.second) {
+ SC_REPORT_ERROR("(E800) register_id failed",
+ "report id already exists");
+ } else {
+ sc_gem5::reportMsgInfoMap[msg].id = id;
+ }
}
void
-sc_report::suppress_id(int id, bool)
+sc_report::suppress_id(int id, bool suppress)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ auto it = sc_gem5::reportIdToMsgMap.find(id);
+ if (it == sc_gem5::reportIdToMsgMap.end())
+ return;
+
+ if (suppress)
+ sc_gem5::reportMsgInfoMap[it->second].actions = SC_DO_NOTHING;
+ else
+ sc_gem5::reportMsgInfoMap[it->second].actions = SC_UNSPECIFIED;
}
void
-sc_report::suppress_infos(bool)
+sc_report::suppress_infos(bool suppress)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ if (suppress)
+ sc_gem5::reportSevInfos[SC_INFO].actions = SC_DO_NOTHING;
+ else
+ sc_gem5::reportSevInfos[SC_INFO].actions = SC_DEFAULT_INFO_ACTIONS;
}
void
-sc_report::suppress_warnings(bool)
+sc_report::suppress_warnings(bool suppress)
{
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ if (suppress) {
+ sc_gem5::reportSevInfos[SC_WARNING].actions = SC_DO_NOTHING;
+ } else {
+ sc_gem5::reportSevInfos[SC_WARNING].actions =
+ SC_DEFAULT_WARNING_ACTIONS;
+ }
}
void
diff --git a/src/systemc/utils/sc_report_handler.cc b/src/systemc/utils/sc_report_handler.cc
index a8cdc363a..46ee84704 100644
--- a/src/systemc/utils/sc_report_handler.cc
+++ b/src/systemc/utils/sc_report_handler.cc
@@ -89,7 +89,7 @@ sc_report_handler::report(sc_severity severity, const char *msg_type,
::sc_gem5::Process *current = ::sc_gem5::scheduler.current();
sc_report report(severity, msg_type, msg, verbosity, file, line,
sc_time::from_value(::sc_gem5::scheduler.getCurTick()),
- current ? current->name() : nullptr, -1);
+ current ? current->name() : nullptr, msgInfo.id);
if (actions & SC_CACHE_REPORT) {
if (current) {
@@ -104,11 +104,17 @@ sc_report_handler::report(sc_severity severity, const char *msg_type,
}
void
-sc_report_handler::report(sc_severity, int id, const char *msg,
+sc_report_handler::report(sc_severity severity, int id, const char *msg,
const char *file, int line)
{
- warn("%s:%d %s\n", file, line, msg);
- warn("%s not implemented.\n", __PRETTY_FUNCTION__);
+ std::string &msg_type = sc_gem5::reportIdToMsgMap[id];
+ if (msg_type == "")
+ msg_type = "unknown id";
+
+ if (sc_gem5::reportWarningsAsErrors && severity == SC_WARNING)
+ severity = SC_ERROR;
+
+ report(severity, msg_type.c_str(), msg, file, line);
}
sc_actions