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 9 * notice, this list of conditions and the following disclaimer in the 10 * documentation and/or other materials provided with the distribution; 11 * neither the name of the copyright holders nor the names of its 12 * contributors may be used to endorse or promote products derived from 13 * this software without specific prior written permission. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * 27 * Authors: Gabe Black 28 */ 29 30#include <fstream> 31#include <map> 32#include <sstream> 33#include <string> 34 35#include "base/logging.hh" 36#include "systemc/core/process.hh" 37#include "systemc/core/scheduler.hh" 38#include "systemc/ext/core/sc_main.hh"
| 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 9 * notice, this list of conditions and the following disclaimer in the 10 * documentation and/or other materials provided with the distribution; 11 * neither the name of the copyright holders nor the names of its 12 * contributors may be used to endorse or promote products derived from 13 * this software without specific prior written permission. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * 27 * Authors: Gabe Black 28 */ 29 30#include <fstream> 31#include <map> 32#include <sstream> 33#include <string> 34 35#include "base/logging.hh" 36#include "systemc/core/process.hh" 37#include "systemc/core/scheduler.hh" 38#include "systemc/ext/core/sc_main.hh"
|
| 39#include "systemc/ext/utils/messages.hh"
|
39#include "systemc/ext/utils/sc_report_handler.hh" 40#include "systemc/utils/report.hh" 41 42namespace sc_core 43{ 44 45namespace 46{ 47 48std::unique_ptr<std::string> logFileName; 49std::unique_ptr<std::ofstream> logFile; 50 51} // anonymous namespace 52 53void 54sc_report_handler::report(sc_severity severity, const char *msg_type, 55 const char *msg, const char *file, int line) 56{ 57 report(severity, msg_type, msg, SC_MEDIUM, file, line); 58} 59 60void 61sc_report_handler::report(sc_severity severity, const char *msg_type, 62 const char *msg, int verbosity, const char *file, 63 int line) 64{
| 40#include "systemc/ext/utils/sc_report_handler.hh" 41#include "systemc/utils/report.hh" 42 43namespace sc_core 44{ 45 46namespace 47{ 48 49std::unique_ptr<std::string> logFileName; 50std::unique_ptr<std::ofstream> logFile; 51 52} // anonymous namespace 53 54void 55sc_report_handler::report(sc_severity severity, const char *msg_type, 56 const char *msg, const char *file, int line) 57{ 58 report(severity, msg_type, msg, SC_MEDIUM, file, line); 59} 60 61void 62sc_report_handler::report(sc_severity severity, const char *msg_type, 63 const char *msg, int verbosity, const char *file, 64 int line) 65{
|
| 66 if (!msg_type) 67 msg_type = SC_ID_UNKNOWN_ERROR_; 68
|
65 if (severity == SC_INFO && verbosity > sc_gem5::reportVerbosityLevel) 66 return; 67 68 sc_gem5::ReportSevInfo &sevInfo = sc_gem5::reportSevInfos[severity]; 69 sc_gem5::ReportMsgInfo &msgInfo = sc_gem5::reportMsgInfoMap[msg_type]; 70 71 sevInfo.count++; 72 msgInfo.count++; 73 msgInfo.sevCounts[severity]++; 74 75 sc_actions actions = SC_UNSPECIFIED; 76 if (msgInfo.sevActions[severity] != SC_UNSPECIFIED) 77 actions = msgInfo.sevActions[severity]; 78 else if (msgInfo.actions != SC_UNSPECIFIED) 79 actions = msgInfo.actions; 80 else if (sevInfo.actions != SC_UNSPECIFIED) 81 actions = sevInfo.actions; 82 83 actions &= ~sc_gem5::reportSuppressedActions; 84 actions |= sc_gem5::reportForcedActions; 85 86 msgInfo.checkLimits(severity, actions); 87 sevInfo.checkLimit(actions); 88 89 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 90 sc_report report(severity, msg_type, msg, verbosity, file, line, 91 sc_time::from_value(::sc_gem5::scheduler.getCurTick()), 92 current ? current->name() : nullptr, msgInfo.id); 93 94 if (actions & SC_CACHE_REPORT) { 95 if (current) { 96 current->lastReport(&report); 97 } else { 98 sc_gem5::globalReportCache = 99 std::unique_ptr<sc_report>(new sc_report(report)); 100 } 101 } 102 103 sc_gem5::reportHandlerProc(report, actions); 104} 105 106void 107sc_report_handler::report(sc_severity severity, int id, const char *msg, 108 const char *file, int line) 109{ 110 std::string &msg_type = sc_gem5::reportIdToMsgMap[id]; 111 112 if (sc_gem5::reportWarningsAsErrors && severity == SC_WARNING) 113 severity = SC_ERROR; 114 115 report(severity, msg_type.c_str(), msg, file, line); 116} 117 118sc_actions 119sc_report_handler::set_actions(sc_severity severity, sc_actions actions) 120{ 121 sc_gem5::ReportSevInfo &info = sc_gem5::reportSevInfos[severity]; 122 sc_actions previous = info.actions; 123 info.actions = actions; 124 return previous; 125} 126 127sc_actions 128sc_report_handler::set_actions(const char *msg_type, sc_actions actions) 129{
| 69 if (severity == SC_INFO && verbosity > sc_gem5::reportVerbosityLevel) 70 return; 71 72 sc_gem5::ReportSevInfo &sevInfo = sc_gem5::reportSevInfos[severity]; 73 sc_gem5::ReportMsgInfo &msgInfo = sc_gem5::reportMsgInfoMap[msg_type]; 74 75 sevInfo.count++; 76 msgInfo.count++; 77 msgInfo.sevCounts[severity]++; 78 79 sc_actions actions = SC_UNSPECIFIED; 80 if (msgInfo.sevActions[severity] != SC_UNSPECIFIED) 81 actions = msgInfo.sevActions[severity]; 82 else if (msgInfo.actions != SC_UNSPECIFIED) 83 actions = msgInfo.actions; 84 else if (sevInfo.actions != SC_UNSPECIFIED) 85 actions = sevInfo.actions; 86 87 actions &= ~sc_gem5::reportSuppressedActions; 88 actions |= sc_gem5::reportForcedActions; 89 90 msgInfo.checkLimits(severity, actions); 91 sevInfo.checkLimit(actions); 92 93 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 94 sc_report report(severity, msg_type, msg, verbosity, file, line, 95 sc_time::from_value(::sc_gem5::scheduler.getCurTick()), 96 current ? current->name() : nullptr, msgInfo.id); 97 98 if (actions & SC_CACHE_REPORT) { 99 if (current) { 100 current->lastReport(&report); 101 } else { 102 sc_gem5::globalReportCache = 103 std::unique_ptr<sc_report>(new sc_report(report)); 104 } 105 } 106 107 sc_gem5::reportHandlerProc(report, actions); 108} 109 110void 111sc_report_handler::report(sc_severity severity, int id, const char *msg, 112 const char *file, int line) 113{ 114 std::string &msg_type = sc_gem5::reportIdToMsgMap[id]; 115 116 if (sc_gem5::reportWarningsAsErrors && severity == SC_WARNING) 117 severity = SC_ERROR; 118 119 report(severity, msg_type.c_str(), msg, file, line); 120} 121 122sc_actions 123sc_report_handler::set_actions(sc_severity severity, sc_actions actions) 124{ 125 sc_gem5::ReportSevInfo &info = sc_gem5::reportSevInfos[severity]; 126 sc_actions previous = info.actions; 127 info.actions = actions; 128 return previous; 129} 130 131sc_actions 132sc_report_handler::set_actions(const char *msg_type, sc_actions actions) 133{
|
| 134 if (!msg_type) 135 msg_type = SC_ID_UNKNOWN_ERROR_; 136
|
130 sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type]; 131 sc_actions previous = info.actions; 132 info.actions = actions; 133 return previous; 134} 135 136sc_actions 137sc_report_handler::set_actions( 138 const char *msg_type, sc_severity severity, sc_actions actions) 139{
| 137 sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type]; 138 sc_actions previous = info.actions; 139 info.actions = actions; 140 return previous; 141} 142 143sc_actions 144sc_report_handler::set_actions( 145 const char *msg_type, sc_severity severity, sc_actions actions) 146{
|
| 147 if (!msg_type) 148 msg_type = SC_ID_UNKNOWN_ERROR_; 149
|
140 sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type]; 141 sc_actions previous = info.sevActions[severity]; 142 info.sevActions[severity] = actions; 143 return previous; 144} 145 146int 147sc_report_handler::stop_after(sc_severity severity, int limit) 148{ 149 sc_gem5::ReportSevInfo &info = sc_gem5::reportSevInfos[severity]; 150 int previous = info.limit; 151 info.limit = limit; 152 return previous; 153} 154 155int 156sc_report_handler::stop_after(const char *msg_type, int limit) 157{
| 150 sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type]; 151 sc_actions previous = info.sevActions[severity]; 152 info.sevActions[severity] = actions; 153 return previous; 154} 155 156int 157sc_report_handler::stop_after(sc_severity severity, int limit) 158{ 159 sc_gem5::ReportSevInfo &info = sc_gem5::reportSevInfos[severity]; 160 int previous = info.limit; 161 info.limit = limit; 162 return previous; 163} 164 165int 166sc_report_handler::stop_after(const char *msg_type, int limit) 167{
|
| 168 if (!msg_type) 169 msg_type = SC_ID_UNKNOWN_ERROR_; 170
|
158 sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type]; 159 int previous = info.limit; 160 info.limit = limit; 161 return previous; 162} 163 164int 165sc_report_handler::stop_after( 166 const char *msg_type, sc_severity severity, int limit) 167{
| 171 sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type]; 172 int previous = info.limit; 173 info.limit = limit; 174 return previous; 175} 176 177int 178sc_report_handler::stop_after( 179 const char *msg_type, sc_severity severity, int limit) 180{
|
| 181 if (!msg_type) 182 msg_type = SC_ID_UNKNOWN_ERROR_; 183
|
168 sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type]; 169 int previous = info.sevLimits[severity]; 170 info.sevLimits[severity] = limit; 171 return previous; 172} 173 174int 175sc_report_handler::get_count(sc_severity severity) 176{ 177 return sc_gem5::reportSevInfos[severity].count; 178} 179 180int 181sc_report_handler::get_count(const char *msg_type) 182{
| 184 sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type]; 185 int previous = info.sevLimits[severity]; 186 info.sevLimits[severity] = limit; 187 return previous; 188} 189 190int 191sc_report_handler::get_count(sc_severity severity) 192{ 193 return sc_gem5::reportSevInfos[severity].count; 194} 195 196int 197sc_report_handler::get_count(const char *msg_type) 198{
|
| 199 if (!msg_type) 200 msg_type = SC_ID_UNKNOWN_ERROR_; 201
|
183 return sc_gem5::reportMsgInfoMap[msg_type].count; 184} 185 186int 187sc_report_handler::get_count(const char *msg_type, sc_severity severity) 188{
| 202 return sc_gem5::reportMsgInfoMap[msg_type].count; 203} 204 205int 206sc_report_handler::get_count(const char *msg_type, sc_severity severity) 207{
|
| 208 if (!msg_type) 209 msg_type = SC_ID_UNKNOWN_ERROR_; 210
|
189 return sc_gem5::reportMsgInfoMap[msg_type].sevCounts[severity]; 190} 191 192int 193sc_report_handler::set_verbosity_level(int vl) 194{ 195 int previous = sc_gem5::reportVerbosityLevel; 196 sc_gem5::reportVerbosityLevel = vl; 197 return previous; 198} 199 200int 201sc_report_handler::get_verbosity_level() 202{ 203 return sc_gem5::reportVerbosityLevel; 204} 205 206 207sc_actions 208sc_report_handler::suppress(sc_actions actions) 209{ 210 sc_actions previous = sc_gem5::reportSuppressedActions; 211 sc_gem5::reportSuppressedActions = actions; 212 return previous; 213} 214 215sc_actions 216sc_report_handler::suppress() 217{ 218 return suppress(SC_UNSPECIFIED); 219} 220 221sc_actions 222sc_report_handler::force(sc_actions actions) 223{ 224 sc_actions previous = sc_gem5::reportForcedActions; 225 sc_gem5::reportForcedActions = actions; 226 return previous; 227} 228 229sc_actions 230sc_report_handler::force() 231{ 232 return force(SC_UNSPECIFIED); 233} 234 235 236sc_actions 237sc_report_handler::set_catch_actions(sc_actions actions) 238{ 239 sc_actions previous = sc_gem5::reportCatchActions; 240 sc_gem5::reportCatchActions = actions; 241 return previous; 242} 243 244sc_actions 245sc_report_handler::get_catch_actions() 246{ 247 return sc_gem5::reportCatchActions; 248} 249 250 251void 252sc_report_handler::set_handler(sc_report_handler_proc proc) 253{ 254 sc_gem5::reportHandlerProc = proc; 255} 256 257void 258sc_report_handler::default_handler( 259 const sc_report &report, const sc_actions &actions) 260{ 261 if (actions & SC_DISPLAY) 262 cprintf("\n%s\n", sc_report_compose_message(report)); 263 264 if ((actions & SC_LOG) && logFile) { 265 ccprintf(*logFile, "%s: %s\n", report.get_time().to_string(), 266 sc_report_compose_message(report)); 267 } 268 if (actions & SC_STOP) { 269 sc_stop_here(report.get_msg_type(), report.get_severity()); 270 sc_stop(); 271 } 272 if (actions & SC_INTERRUPT) 273 sc_interrupt_here(report.get_msg_type(), report.get_severity()); 274 if (actions & SC_ABORT) 275 sc_abort(); 276 if (actions & SC_THROW) { 277 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 278 if (current) 279 current->isUnwinding(false); 280 throw report; 281 } 282} 283 284sc_actions 285sc_report_handler::get_new_action_id() 286{ 287 static sc_actions maxAction = SC_ABORT; 288 maxAction = maxAction << 1; 289 return maxAction; 290} 291 292sc_report * 293sc_report_handler::get_cached_report() 294{ 295 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 296 if (current) 297 return current->lastReport(); 298 return ::sc_gem5::globalReportCache.get(); 299} 300 301void 302sc_report_handler::clear_cached_report() 303{ 304 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 305 if (current) { 306 current->lastReport(nullptr); 307 } else { 308 ::sc_gem5::globalReportCache = nullptr; 309 } 310} 311 312bool 313sc_report_handler::set_log_file_name(const char *new_name) 314{ 315 if (!new_name) { 316 logFile = nullptr; 317 logFileName = nullptr; 318 return false; 319 } else { 320 if (logFileName) 321 return false; 322 logFileName = std::unique_ptr<std::string>(new std::string(new_name)); 323 logFile = std::unique_ptr<std::ofstream>(new std::ofstream(new_name)); 324 return true; 325 } 326} 327 328const char * 329sc_report_handler::get_log_file_name() 330{ 331 if (!logFileName) 332 return nullptr; 333 else 334 return logFileName->c_str(); 335} 336 337void 338sc_interrupt_here(const char *msg_type, sc_severity) 339{ 340 // Purposefully empty, for setting breakpoints supposedly. 341} 342 343void 344sc_stop_here(const char *msg_type, sc_severity) 345{ 346 // Purposefully empty, for setting breakpoints supposedly. 347} 348 349const std::string 350sc_report_compose_message(const sc_report &report) 351{ 352 std::ostringstream str; 353 354 const char *sevName = sc_gem5::reportSeverityNames[report.get_severity()]; 355 int id = report.get_id(); 356 357 str << sevName << ": "; 358 if (id >= 0) { 359 ccprintf(str, "(%c%d) ", sevName[0], id); 360 } 361 str << report.get_msg_type(); 362 363 const char *msg = report.get_msg(); 364 if (msg && msg[0]) 365 str << ": " << msg; 366 367 if (report.get_severity() > SC_INFO) { 368 ccprintf(str, "\nIn file: %s:%d", report.get_file_name(), 369 report.get_line_number()); 370 371 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 372 const char *name = report.get_process_name(); 373 if (current && sc_is_running() && name) { 374 ccprintf(str, "\nIn process: %s @ %s", name, 375 report.get_time().to_string()); 376 } 377 } 378 379 return str.str(); 380} 381 382bool 383sc_report_close_default_log() 384{ 385 if (logFile) { 386 logFile = nullptr; 387 logFileName = nullptr; 388 return false; 389 } 390 return true; 391} 392 393} // namespace sc_core
| 211 return sc_gem5::reportMsgInfoMap[msg_type].sevCounts[severity]; 212} 213 214int 215sc_report_handler::set_verbosity_level(int vl) 216{ 217 int previous = sc_gem5::reportVerbosityLevel; 218 sc_gem5::reportVerbosityLevel = vl; 219 return previous; 220} 221 222int 223sc_report_handler::get_verbosity_level() 224{ 225 return sc_gem5::reportVerbosityLevel; 226} 227 228 229sc_actions 230sc_report_handler::suppress(sc_actions actions) 231{ 232 sc_actions previous = sc_gem5::reportSuppressedActions; 233 sc_gem5::reportSuppressedActions = actions; 234 return previous; 235} 236 237sc_actions 238sc_report_handler::suppress() 239{ 240 return suppress(SC_UNSPECIFIED); 241} 242 243sc_actions 244sc_report_handler::force(sc_actions actions) 245{ 246 sc_actions previous = sc_gem5::reportForcedActions; 247 sc_gem5::reportForcedActions = actions; 248 return previous; 249} 250 251sc_actions 252sc_report_handler::force() 253{ 254 return force(SC_UNSPECIFIED); 255} 256 257 258sc_actions 259sc_report_handler::set_catch_actions(sc_actions actions) 260{ 261 sc_actions previous = sc_gem5::reportCatchActions; 262 sc_gem5::reportCatchActions = actions; 263 return previous; 264} 265 266sc_actions 267sc_report_handler::get_catch_actions() 268{ 269 return sc_gem5::reportCatchActions; 270} 271 272 273void 274sc_report_handler::set_handler(sc_report_handler_proc proc) 275{ 276 sc_gem5::reportHandlerProc = proc; 277} 278 279void 280sc_report_handler::default_handler( 281 const sc_report &report, const sc_actions &actions) 282{ 283 if (actions & SC_DISPLAY) 284 cprintf("\n%s\n", sc_report_compose_message(report)); 285 286 if ((actions & SC_LOG) && logFile) { 287 ccprintf(*logFile, "%s: %s\n", report.get_time().to_string(), 288 sc_report_compose_message(report)); 289 } 290 if (actions & SC_STOP) { 291 sc_stop_here(report.get_msg_type(), report.get_severity()); 292 sc_stop(); 293 } 294 if (actions & SC_INTERRUPT) 295 sc_interrupt_here(report.get_msg_type(), report.get_severity()); 296 if (actions & SC_ABORT) 297 sc_abort(); 298 if (actions & SC_THROW) { 299 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 300 if (current) 301 current->isUnwinding(false); 302 throw report; 303 } 304} 305 306sc_actions 307sc_report_handler::get_new_action_id() 308{ 309 static sc_actions maxAction = SC_ABORT; 310 maxAction = maxAction << 1; 311 return maxAction; 312} 313 314sc_report * 315sc_report_handler::get_cached_report() 316{ 317 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 318 if (current) 319 return current->lastReport(); 320 return ::sc_gem5::globalReportCache.get(); 321} 322 323void 324sc_report_handler::clear_cached_report() 325{ 326 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 327 if (current) { 328 current->lastReport(nullptr); 329 } else { 330 ::sc_gem5::globalReportCache = nullptr; 331 } 332} 333 334bool 335sc_report_handler::set_log_file_name(const char *new_name) 336{ 337 if (!new_name) { 338 logFile = nullptr; 339 logFileName = nullptr; 340 return false; 341 } else { 342 if (logFileName) 343 return false; 344 logFileName = std::unique_ptr<std::string>(new std::string(new_name)); 345 logFile = std::unique_ptr<std::ofstream>(new std::ofstream(new_name)); 346 return true; 347 } 348} 349 350const char * 351sc_report_handler::get_log_file_name() 352{ 353 if (!logFileName) 354 return nullptr; 355 else 356 return logFileName->c_str(); 357} 358 359void 360sc_interrupt_here(const char *msg_type, sc_severity) 361{ 362 // Purposefully empty, for setting breakpoints supposedly. 363} 364 365void 366sc_stop_here(const char *msg_type, sc_severity) 367{ 368 // Purposefully empty, for setting breakpoints supposedly. 369} 370 371const std::string 372sc_report_compose_message(const sc_report &report) 373{ 374 std::ostringstream str; 375 376 const char *sevName = sc_gem5::reportSeverityNames[report.get_severity()]; 377 int id = report.get_id(); 378 379 str << sevName << ": "; 380 if (id >= 0) { 381 ccprintf(str, "(%c%d) ", sevName[0], id); 382 } 383 str << report.get_msg_type(); 384 385 const char *msg = report.get_msg(); 386 if (msg && msg[0]) 387 str << ": " << msg; 388 389 if (report.get_severity() > SC_INFO) { 390 ccprintf(str, "\nIn file: %s:%d", report.get_file_name(), 391 report.get_line_number()); 392 393 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 394 const char *name = report.get_process_name(); 395 if (current && sc_is_running() && name) { 396 ccprintf(str, "\nIn process: %s @ %s", name, 397 report.get_time().to_string()); 398 } 399 } 400 401 return str.str(); 402} 403 404bool 405sc_report_close_default_log() 406{ 407 if (logFile) { 408 logFile = nullptr; 409 logFileName = nullptr; 410 return false; 411 } 412 return true; 413} 414 415} // namespace sc_core
|