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/sc_report_handler.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/sc_report_handler.hh"
|
| 40#include "systemc/utils/report.hh"
|
40 41namespace sc_core 42{ 43 44namespace 45{ 46 47std::unique_ptr<std::string> logFileName; 48std::unique_ptr<std::ofstream> logFile; 49
| 41 42namespace sc_core 43{ 44 45namespace 46{ 47 48std::unique_ptr<std::string> logFileName; 49std::unique_ptr<std::ofstream> logFile; 50
|
50struct ReportCatInfo 51{ 52 explicit ReportCatInfo(sc_actions actions) : 53 actions(actions), count(0), limit(-1) 54 {} 55 ReportCatInfo() : ReportCatInfo(SC_UNSPECIFIED) {} 56 57 bool 58 checkLimit(sc_actions &actions) 59 { 60 if (limit == 0 || count < limit) 61 return false; 62 if (limit != -1) 63 actions |= SC_STOP; 64 return true; 65 } 66 67 sc_actions actions; 68 int count; 69 int limit; 70}; 71 72const char *severityNames[] = { 73 [SC_INFO] = "Info", 74 [SC_WARNING] = "Warning", 75 [SC_ERROR] = "Error", 76 [SC_FATAL] = "Fatal" 77}; 78 79ReportCatInfo catForSeverity[SC_MAX_SEVERITY] = 80{ 81 [SC_INFO] = ReportCatInfo(SC_DEFAULT_INFO_ACTIONS), 82 [SC_WARNING] = ReportCatInfo(SC_DEFAULT_WARNING_ACTIONS), 83 [SC_ERROR] = ReportCatInfo(SC_DEFAULT_ERROR_ACTIONS), 84 [SC_FATAL] = ReportCatInfo(SC_DEFAULT_FATAL_ACTIONS) 85}; 86 87std::map<std::string, ReportCatInfo> catForMsgType; 88std::map<std::pair<std::string, sc_severity>, ReportCatInfo> 89 catForSeverityAndMsgType; 90 91int verbosityLevel = SC_MEDIUM; 92 93sc_actions suppressedActions = SC_UNSPECIFIED; 94sc_actions forcedActions = SC_UNSPECIFIED; 95sc_actions catchActions = SC_DISPLAY; 96 97sc_report_handler_proc reportHandlerProc = &sc_report_handler::default_handler; 98 99sc_actions maxAction = SC_ABORT; 100 101std::unique_ptr<sc_report> globalReportCache; 102
| |
103} // anonymous namespace 104 105void 106sc_report_handler::report(sc_severity severity, const char *msg_type, 107 const char *msg, const char *file, int line) 108{ 109 report(severity, msg_type, msg, SC_MEDIUM, file, line); 110} 111 112void 113sc_report_handler::report(sc_severity severity, const char *msg_type, 114 const char *msg, int verbosity, const char *file, 115 int line) 116{
| 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{
|
117 if (severity == SC_INFO && verbosity > verbosityLevel)
| 65 if (severity == SC_INFO && verbosity > sc_gem5::reportVerbosityLevel)
|
118 return; 119
| 66 return; 67
|
120 ReportCatInfo &sevInfo = catForSeverity[severity]; 121 ReportCatInfo &msgInfo = catForMsgType[msg_type]; 122 ReportCatInfo &sevMsgInfo = catForSeverityAndMsgType[ 123 std::make_pair(std::string(msg_type), severity)];
| 68 sc_gem5::ReportSevInfo &sevInfo = sc_gem5::reportSevInfos[severity]; 69 sc_gem5::ReportMsgInfo &msgInfo = sc_gem5::reportMsgInfoMap[msg_type];
|
124 125 sevInfo.count++; 126 msgInfo.count++;
| 70 71 sevInfo.count++; 72 msgInfo.count++;
|
127 sevMsgInfo.count++;
| 73 msgInfo.sevCounts[severity]++;
|
128 129 sc_actions actions = SC_UNSPECIFIED;
| 74 75 sc_actions actions = SC_UNSPECIFIED;
|
130 if (sevMsgInfo.actions != SC_UNSPECIFIED) 131 actions = sevMsgInfo.actions;
| 76 if (msgInfo.sevActions[severity] != SC_UNSPECIFIED) 77 actions = msgInfo.sevActions[severity];
|
132 else if (msgInfo.actions != SC_UNSPECIFIED) 133 actions = msgInfo.actions; 134 else if (sevInfo.actions != SC_UNSPECIFIED) 135 actions = sevInfo.actions; 136
| 78 else if (msgInfo.actions != SC_UNSPECIFIED) 79 actions = msgInfo.actions; 80 else if (sevInfo.actions != SC_UNSPECIFIED) 81 actions = sevInfo.actions; 82
|
137 actions &= ~suppressedActions; 138 actions |= forcedActions;
| 83 actions &= ~sc_gem5::reportSuppressedActions; 84 actions |= sc_gem5::reportForcedActions;
|
139
| 85
|
140 if (sevMsgInfo.checkLimit(actions) && msgInfo.checkLimit(actions)) 141 sevInfo.checkLimit(actions);
| 86 msgInfo.checkLimits(severity, actions); 87 sevInfo.checkLimit(actions);
|
142 143 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 144 sc_report report(severity, msg_type, msg, verbosity, file, line, 145 sc_time::from_value(::sc_gem5::scheduler.getCurTick()), 146 current ? current->name() : nullptr, -1); 147 148 if (actions & SC_CACHE_REPORT) { 149 if (current) { 150 current->lastReport(&report); 151 } else {
| 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, -1); 93 94 if (actions & SC_CACHE_REPORT) { 95 if (current) { 96 current->lastReport(&report); 97 } else {
|
152 globalReportCache =
| 98 sc_gem5::globalReportCache =
|
153 std::unique_ptr<sc_report>(new sc_report(report)); 154 } 155 } 156
| 99 std::unique_ptr<sc_report>(new sc_report(report)); 100 } 101 } 102
|
157 reportHandlerProc(report, actions);
| 103 sc_gem5::reportHandlerProc(report, actions);
|
158} 159 160void 161sc_report_handler::report(sc_severity, int id, const char *msg, 162 const char *file, int line) 163{ 164 warn("%s:%d %s\n", file, line, msg); 165 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 166} 167 168sc_actions 169sc_report_handler::set_actions(sc_severity severity, sc_actions actions) 170{
| 104} 105 106void 107sc_report_handler::report(sc_severity, int id, const char *msg, 108 const char *file, int line) 109{ 110 warn("%s:%d %s\n", file, line, msg); 111 warn("%s not implemented.\n", __PRETTY_FUNCTION__); 112} 113 114sc_actions 115sc_report_handler::set_actions(sc_severity severity, sc_actions actions) 116{
|
171 ReportCatInfo &info = catForSeverity[severity];
| 117 sc_gem5::ReportSevInfo &info = sc_gem5::reportSevInfos[severity];
|
172 sc_actions previous = info.actions; 173 info.actions = actions; 174 return previous; 175} 176 177sc_actions 178sc_report_handler::set_actions(const char *msg_type, sc_actions actions) 179{
| 118 sc_actions previous = info.actions; 119 info.actions = actions; 120 return previous; 121} 122 123sc_actions 124sc_report_handler::set_actions(const char *msg_type, sc_actions actions) 125{
|
180 ReportCatInfo &info = catForMsgType[msg_type];
| 126 sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type];
|
181 sc_actions previous = info.actions; 182 info.actions = actions; 183 return previous; 184} 185 186sc_actions 187sc_report_handler::set_actions( 188 const char *msg_type, sc_severity severity, sc_actions actions) 189{
| 127 sc_actions previous = info.actions; 128 info.actions = actions; 129 return previous; 130} 131 132sc_actions 133sc_report_handler::set_actions( 134 const char *msg_type, sc_severity severity, sc_actions actions) 135{
|
190 ReportCatInfo &info = catForSeverityAndMsgType[ 191 std::make_pair(std::string(msg_type), severity)]; 192 sc_actions previous = info.actions; 193 info.actions = actions;
| 136 sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type]; 137 sc_actions previous = info.sevActions[severity]; 138 info.sevActions[severity] = actions;
|
194 return previous; 195} 196 197int 198sc_report_handler::stop_after(sc_severity severity, int limit) 199{
| 139 return previous; 140} 141 142int 143sc_report_handler::stop_after(sc_severity severity, int limit) 144{
|
200 ReportCatInfo &info = catForSeverity[severity];
| 145 sc_gem5::ReportSevInfo &info = sc_gem5::reportSevInfos[severity];
|
201 int previous = info.limit; 202 info.limit = limit; 203 return previous; 204} 205 206int 207sc_report_handler::stop_after(const char *msg_type, int limit) 208{
| 146 int previous = info.limit; 147 info.limit = limit; 148 return previous; 149} 150 151int 152sc_report_handler::stop_after(const char *msg_type, int limit) 153{
|
209 ReportCatInfo &info = catForMsgType[msg_type];
| 154 sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type];
|
210 int previous = info.limit; 211 info.limit = limit; 212 return previous; 213} 214 215int 216sc_report_handler::stop_after( 217 const char *msg_type, sc_severity severity, int limit) 218{
| 155 int previous = info.limit; 156 info.limit = limit; 157 return previous; 158} 159 160int 161sc_report_handler::stop_after( 162 const char *msg_type, sc_severity severity, int limit) 163{
|
219 ReportCatInfo &info = catForSeverityAndMsgType[ 220 std::make_pair(std::string(msg_type), severity)]; 221 int previous = info.limit; 222 info.limit = limit;
| 164 sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type]; 165 int previous = info.sevLimits[severity]; 166 info.sevLimits[severity] = limit;
|
223 return previous; 224} 225 226int 227sc_report_handler::get_count(sc_severity severity) 228{
| 167 return previous; 168} 169 170int 171sc_report_handler::get_count(sc_severity severity) 172{
|
229 return catForSeverity[severity].count;
| 173 return sc_gem5::reportSevInfos[severity].count;
|
230} 231 232int 233sc_report_handler::get_count(const char *msg_type) 234{
| 174} 175 176int 177sc_report_handler::get_count(const char *msg_type) 178{
|
235 return catForMsgType[msg_type].count;
| 179 return sc_gem5::reportMsgInfoMap[msg_type].count;
|
236} 237 238int 239sc_report_handler::get_count(const char *msg_type, sc_severity severity) 240{
| 180} 181 182int 183sc_report_handler::get_count(const char *msg_type, sc_severity severity) 184{
|
241 return catForSeverityAndMsgType[ 242 std::make_pair(std::string(msg_type), severity)].count;
| 185 return sc_gem5::reportMsgInfoMap[msg_type].sevCounts[severity];
|
243} 244 245int 246sc_report_handler::set_verbosity_level(int vl) 247{
| 186} 187 188int 189sc_report_handler::set_verbosity_level(int vl) 190{
|
248 int previous = verbosityLevel; 249 verbosityLevel = vl;
| 191 int previous = sc_gem5::reportVerbosityLevel; 192 sc_gem5::reportVerbosityLevel = vl;
|
250 return previous; 251} 252 253int 254sc_report_handler::get_verbosity_level() 255{
| 193 return previous; 194} 195 196int 197sc_report_handler::get_verbosity_level() 198{
|
256 return verbosityLevel;
| 199 return sc_gem5::reportVerbosityLevel;
|
257} 258 259 260sc_actions 261sc_report_handler::suppress(sc_actions actions) 262{
| 200} 201 202 203sc_actions 204sc_report_handler::suppress(sc_actions actions) 205{
|
263 sc_actions previous = suppressedActions; 264 suppressedActions = actions;
| 206 sc_actions previous = sc_gem5::reportSuppressedActions; 207 sc_gem5::reportSuppressedActions = actions;
|
265 return previous; 266} 267 268sc_actions 269sc_report_handler::suppress() 270{ 271 return suppress(SC_UNSPECIFIED); 272} 273 274sc_actions 275sc_report_handler::force(sc_actions actions) 276{
| 208 return previous; 209} 210 211sc_actions 212sc_report_handler::suppress() 213{ 214 return suppress(SC_UNSPECIFIED); 215} 216 217sc_actions 218sc_report_handler::force(sc_actions actions) 219{
|
277 sc_actions previous = forcedActions; 278 forcedActions = actions;
| 220 sc_actions previous = sc_gem5::reportForcedActions; 221 sc_gem5::reportForcedActions = actions;
|
279 return previous; 280} 281 282sc_actions 283sc_report_handler::force() 284{ 285 return force(SC_UNSPECIFIED); 286} 287 288 289sc_actions 290sc_report_handler::set_catch_actions(sc_actions actions) 291{
| 222 return previous; 223} 224 225sc_actions 226sc_report_handler::force() 227{ 228 return force(SC_UNSPECIFIED); 229} 230 231 232sc_actions 233sc_report_handler::set_catch_actions(sc_actions actions) 234{
|
292 sc_actions previous = catchActions; 293 catchActions = actions;
| 235 sc_actions previous = sc_gem5::reportCatchActions; 236 sc_gem5::reportCatchActions = actions;
|
294 return previous; 295} 296 297sc_actions 298sc_report_handler::get_catch_actions() 299{
| 237 return previous; 238} 239 240sc_actions 241sc_report_handler::get_catch_actions() 242{
|
300 return catchActions;
| 243 return sc_gem5::reportCatchActions;
|
301} 302 303 304void 305sc_report_handler::set_handler(sc_report_handler_proc proc) 306{
| 244} 245 246 247void 248sc_report_handler::set_handler(sc_report_handler_proc proc) 249{
|
307 reportHandlerProc = proc;
| 250 sc_gem5::reportHandlerProc = proc;
|
308} 309 310void 311sc_report_handler::default_handler( 312 const sc_report &report, const sc_actions &actions) 313{ 314 if (actions & SC_DISPLAY) 315 cprintf("\n%s\n", sc_report_compose_message(report)); 316 317 if ((actions & SC_LOG) && logFile) { 318 ccprintf(*logFile, "%s: %s\n", report.get_time().to_string(), 319 sc_report_compose_message(report)); 320 } 321 if (actions & SC_STOP) { 322 sc_stop_here(report.get_msg_type(), report.get_severity()); 323 sc_stop(); 324 } 325 if (actions & SC_INTERRUPT) 326 sc_interrupt_here(report.get_msg_type(), report.get_severity()); 327 if (actions & SC_ABORT) 328 sc_abort(); 329 if (actions & SC_THROW) { 330 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 331 if (current) 332 current->isUnwinding(false); 333 throw report; 334 } 335} 336 337sc_actions 338sc_report_handler::get_new_action_id() 339{
| 251} 252 253void 254sc_report_handler::default_handler( 255 const sc_report &report, const sc_actions &actions) 256{ 257 if (actions & SC_DISPLAY) 258 cprintf("\n%s\n", sc_report_compose_message(report)); 259 260 if ((actions & SC_LOG) && logFile) { 261 ccprintf(*logFile, "%s: %s\n", report.get_time().to_string(), 262 sc_report_compose_message(report)); 263 } 264 if (actions & SC_STOP) { 265 sc_stop_here(report.get_msg_type(), report.get_severity()); 266 sc_stop(); 267 } 268 if (actions & SC_INTERRUPT) 269 sc_interrupt_here(report.get_msg_type(), report.get_severity()); 270 if (actions & SC_ABORT) 271 sc_abort(); 272 if (actions & SC_THROW) { 273 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 274 if (current) 275 current->isUnwinding(false); 276 throw report; 277 } 278} 279 280sc_actions 281sc_report_handler::get_new_action_id() 282{
|
| 283 static sc_actions maxAction = SC_ABORT;
|
340 maxAction = maxAction << 1; 341 return maxAction; 342} 343
| 284 maxAction = maxAction << 1; 285 return maxAction; 286} 287
|
344sc_report_handler_proc 345sc_report_handler::get_handler() 346{ 347 return reportHandlerProc; 348} 349
| |
350sc_report * 351sc_report_handler::get_cached_report() 352{ 353 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 354 if (current) 355 return current->lastReport();
| 288sc_report * 289sc_report_handler::get_cached_report() 290{ 291 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 292 if (current) 293 return current->lastReport();
|
356 return globalReportCache.get();
| 294 return ::sc_gem5::globalReportCache.get();
|
357} 358 359void 360sc_report_handler::clear_cached_report() 361{ 362 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 363 if (current) { 364 current->lastReport(nullptr); 365 } else {
| 295} 296 297void 298sc_report_handler::clear_cached_report() 299{ 300 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 301 if (current) { 302 current->lastReport(nullptr); 303 } else {
|
366 globalReportCache = nullptr;
| 304 ::sc_gem5::globalReportCache = nullptr;
|
367 } 368} 369 370bool 371sc_report_handler::set_log_file_name(const char *new_name) 372{ 373 if (!new_name) { 374 logFile = nullptr; 375 logFileName = nullptr; 376 return false; 377 } else { 378 if (logFileName) 379 return false; 380 logFileName = std::unique_ptr<std::string>(new std::string(new_name)); 381 logFile = std::unique_ptr<std::ofstream>(new std::ofstream(new_name)); 382 return true; 383 } 384} 385 386const char * 387sc_report_handler::get_log_file_name() 388{ 389 if (!logFileName) 390 return nullptr; 391 else 392 return logFileName->c_str(); 393} 394 395void 396sc_interrupt_here(const char *msg_type, sc_severity) 397{ 398 // Purposefully empty, for setting breakpoints supposedly. 399} 400 401void 402sc_stop_here(const char *msg_type, sc_severity) 403{ 404 // Purposefully empty, for setting breakpoints supposedly. 405} 406 407const std::string 408sc_report_compose_message(const sc_report &report) 409{ 410 std::ostringstream str; 411
| 305 } 306} 307 308bool 309sc_report_handler::set_log_file_name(const char *new_name) 310{ 311 if (!new_name) { 312 logFile = nullptr; 313 logFileName = nullptr; 314 return false; 315 } else { 316 if (logFileName) 317 return false; 318 logFileName = std::unique_ptr<std::string>(new std::string(new_name)); 319 logFile = std::unique_ptr<std::ofstream>(new std::ofstream(new_name)); 320 return true; 321 } 322} 323 324const char * 325sc_report_handler::get_log_file_name() 326{ 327 if (!logFileName) 328 return nullptr; 329 else 330 return logFileName->c_str(); 331} 332 333void 334sc_interrupt_here(const char *msg_type, sc_severity) 335{ 336 // Purposefully empty, for setting breakpoints supposedly. 337} 338 339void 340sc_stop_here(const char *msg_type, sc_severity) 341{ 342 // Purposefully empty, for setting breakpoints supposedly. 343} 344 345const std::string 346sc_report_compose_message(const sc_report &report) 347{ 348 std::ostringstream str; 349
|
412 const char *sevName = severityNames[report.get_severity()];
| 350 const char *sevName = sc_gem5::reportSeverityNames[report.get_severity()];
|
413 int id = report.get_id(); 414 415 str << sevName << ": "; 416 if (id >= 0) { 417 ccprintf(str, "(%c%d) ", sevName[0], id); 418 } 419 str << report.get_msg_type(); 420 421 const char *msg = report.get_msg(); 422 if (msg && msg[0]) 423 str << ": " << msg; 424 425 if (report.get_severity() > SC_INFO) { 426 ccprintf(str, "\nIn file: %s:%d", report.get_file_name(), 427 report.get_line_number()); 428 429 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 430 const char *name = report.get_process_name(); 431 if (current && sc_is_running() && name) { 432 ccprintf(str, "\nIn process: %s @ %s", name, 433 report.get_time().to_string()); 434 } 435 } 436 437 return str.str(); 438} 439 440bool 441sc_report_close_default_log() 442{ 443 if (logFile) { 444 logFile = nullptr; 445 logFileName = nullptr; 446 return false; 447 } 448 return true; 449} 450 451} // namespace sc_core
| 351 int id = report.get_id(); 352 353 str << sevName << ": "; 354 if (id >= 0) { 355 ccprintf(str, "(%c%d) ", sevName[0], id); 356 } 357 str << report.get_msg_type(); 358 359 const char *msg = report.get_msg(); 360 if (msg && msg[0]) 361 str << ": " << msg; 362 363 if (report.get_severity() > SC_INFO) { 364 ccprintf(str, "\nIn file: %s:%d", report.get_file_name(), 365 report.get_line_number()); 366 367 ::sc_gem5::Process *current = ::sc_gem5::scheduler.current(); 368 const char *name = report.get_process_name(); 369 if (current && sc_is_running() && name) { 370 ccprintf(str, "\nIn process: %s @ %s", name, 371 report.get_time().to_string()); 372 } 373 } 374 375 return str.str(); 376} 377 378bool 379sc_report_close_default_log() 380{ 381 if (logFile) { 382 logFile = nullptr; 383 logFileName = nullptr; 384 return false; 385 } 386 return true; 387} 388 389} // namespace sc_core
|