#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
{
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
::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) {
}
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