systemc: Handle integer based IDs like Accellera does.

This is actually not consistent with how it was handled in 2.0.1 which
is supposedly what this is supposed to be backwards compatible with,
in that in the earlier version on info and warning messages were
suppressed. This is exposed by one of the tests,
utils/sc_report/test01, which suppresses an integer ID and then reports
an error with it. The "golden" output shows the message supressed, but
the actual implementation makes no such distinction.

This implementation duplicates Accelleras for now, but a future change
will make it consistent with the old implementation so the test will
pass.

Change-Id: I8f959321151e2bb60b94000594f30531b80e2684
Reviewed-on: https://gem5-review.googlesource.com/c/13319
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
This commit is contained in:
Gabe Black
2018-10-06 20:09:42 -07:00
parent 7eb6ad4aaa
commit 5220003e38
4 changed files with 66 additions and 17 deletions

View File

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

View File

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

View File

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

View File

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