Deleted Added
sdiff udiff text old ( 13300:e22889f59b74 ) new ( 13312:a7685ffbead8 )
full compact
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

--- 23 unchanged lines hidden (view full) ---

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"
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{
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, -1);
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, 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{
117 sc_gem5::ReportSevInfo &info = sc_gem5::reportSevInfos[severity];
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{
126 sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type];
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{
136 sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type];
137 sc_actions previous = info.sevActions[severity];
138 info.sevActions[severity] = actions;
139 return previous;
140}
141
142int
143sc_report_handler::stop_after(sc_severity severity, int limit)
144{
145 sc_gem5::ReportSevInfo &info = sc_gem5::reportSevInfos[severity];
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{
154 sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type];
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{
164 sc_gem5::ReportMsgInfo &info = sc_gem5::reportMsgInfoMap[msg_type];
165 int previous = info.sevLimits[severity];
166 info.sevLimits[severity] = limit;
167 return previous;
168}
169
170int
171sc_report_handler::get_count(sc_severity severity)
172{
173 return sc_gem5::reportSevInfos[severity].count;
174}
175
176int
177sc_report_handler::get_count(const char *msg_type)
178{
179 return sc_gem5::reportMsgInfoMap[msg_type].count;
180}
181
182int
183sc_report_handler::get_count(const char *msg_type, sc_severity severity)
184{
185 return sc_gem5::reportMsgInfoMap[msg_type].sevCounts[severity];
186}
187
188int
189sc_report_handler::set_verbosity_level(int vl)
190{
191 int previous = sc_gem5::reportVerbosityLevel;
192 sc_gem5::reportVerbosityLevel = vl;
193 return previous;
194}
195
196int
197sc_report_handler::get_verbosity_level()
198{
199 return sc_gem5::reportVerbosityLevel;
200}
201
202
203sc_actions
204sc_report_handler::suppress(sc_actions actions)
205{
206 sc_actions previous = sc_gem5::reportSuppressedActions;
207 sc_gem5::reportSuppressedActions = actions;
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{
220 sc_actions previous = sc_gem5::reportForcedActions;
221 sc_gem5::reportForcedActions = actions;
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{
235 sc_actions previous = sc_gem5::reportCatchActions;
236 sc_gem5::reportCatchActions = actions;
237 return previous;
238}
239
240sc_actions
241sc_report_handler::get_catch_actions()
242{
243 return sc_gem5::reportCatchActions;
244}
245
246
247void
248sc_report_handler::set_handler(sc_report_handler_proc proc)
249{
250 sc_gem5::reportHandlerProc = proc;
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));

--- 16 unchanged lines hidden (view full) ---

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;
284 maxAction = maxAction << 1;
285 return maxAction;
286}
287
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();
294 return ::sc_gem5::globalReportCache.get();
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 {
304 ::sc_gem5::globalReportCache = nullptr;
305 }
306}
307
308bool
309sc_report_handler::set_log_file_name(const char *new_name)
310{
311 if (!new_name) {
312 logFile = nullptr;

--- 29 unchanged lines hidden (view full) ---

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
350 const char *sevName = sc_gem5::reportSeverityNames[report.get_severity()];
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

--- 31 unchanged lines hidden ---