1/* 2 * Copyright 2018 Google, Inc. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer; 8 * redistributions in binary form must reproduce the above copyright --- 18 unchanged lines hidden (view full) --- 27 * Authors: Gabe Black 28 */ 29 30#include <cstring> 31 32#include "base/logging.hh" 33#include "systemc/ext/utils/sc_report.hh" 34#include "systemc/ext/utils/sc_report_handler.hh" |
35#include "systemc/utils/report.hh" |
36 37namespace sc_core 38{ 39 40sc_report::sc_report(sc_severity _severity, const char *msg_type, 41 const char *msg, int _verbosity, const char *_fileName, 42 int _lineNumber, sc_time _time, const char *_processName, int _id) : 43 _severity(_severity), _msgType(msg_type), _msg(msg), --- 39 unchanged lines hidden (view full) --- 83sc_report::what() const throw() 84{ 85 return _what.c_str(); 86} 87 88const char * 89sc_report::get_message(int id) 90{ |
91 auto it = sc_gem5::reportIdToMsgMap.find(id); 92 if (it == sc_gem5::reportIdToMsgMap.end()) 93 return "unknown id"; 94 else 95 return it->second.c_str(); |
96} 97 98bool 99sc_report::is_suppressed(int id) 100{ |
101 auto it = sc_gem5::reportIdToMsgMap.find(id); 102 if (it == sc_gem5::reportIdToMsgMap.end()) 103 return false; 104 105 return sc_gem5::reportMsgInfoMap[it->second].actions == SC_DO_NOTHING; |
106} 107 108void |
109sc_report::make_warnings_errors(bool val) |
110{ |
111 sc_gem5::reportWarningsAsErrors = val; |
112} 113 114void 115sc_report::register_id(int id, const char *msg) 116{ |
117 if (id < 0) { 118 SC_REPORT_ERROR("(E800) register_id failed", "invalid report id"); 119 return; 120 } 121 if (!msg) { 122 SC_REPORT_ERROR("(E800) register_id failed", "invalid report message"); 123 return; 124 } 125 auto p = sc_gem5::reportIdToMsgMap.insert( 126 std::pair<int, std::string>(id, msg)); 127 if (!p.second) { 128 SC_REPORT_ERROR("(E800) register_id failed", 129 "report id already exists"); 130 } else { 131 sc_gem5::reportMsgInfoMap[msg].id = id; 132 } |
133} 134 135void |
136sc_report::suppress_id(int id, bool suppress) |
137{ |
138 auto it = sc_gem5::reportIdToMsgMap.find(id); 139 if (it == sc_gem5::reportIdToMsgMap.end()) 140 return; 141 142 if (suppress) 143 sc_gem5::reportMsgInfoMap[it->second].actions = SC_DO_NOTHING; 144 else 145 sc_gem5::reportMsgInfoMap[it->second].actions = SC_UNSPECIFIED; |
146} 147 148void |
149sc_report::suppress_infos(bool suppress) |
150{ |
151 if (suppress) 152 sc_gem5::reportSevInfos[SC_INFO].actions = SC_DO_NOTHING; 153 else 154 sc_gem5::reportSevInfos[SC_INFO].actions = SC_DEFAULT_INFO_ACTIONS; |
155} 156 157void |
158sc_report::suppress_warnings(bool suppress) |
159{ |
160 if (suppress) { 161 sc_gem5::reportSevInfos[SC_WARNING].actions = SC_DO_NOTHING; 162 } else { 163 sc_gem5::reportSevInfos[SC_WARNING].actions = 164 SC_DEFAULT_WARNING_ACTIONS; 165 } |
166} 167 168void 169sc_abort() 170{ 171 panic("simulation aborted"); 172} 173 174} // namespace sc_core |