sc_report.cc (13157:ca4c4e2552f2) sc_report.cc (13313:306a97d3b040)
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 <cstring>
31
32#include "base/logging.hh"
33#include "systemc/ext/utils/sc_report.hh"
34#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 <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"
35
36namespace sc_core
37{
38
39sc_report::sc_report(sc_severity _severity, const char *msg_type,
40 const char *msg, int _verbosity, const char *_fileName,
41 int _lineNumber, sc_time _time, const char *_processName, int _id) :
42 _severity(_severity), _msgType(msg_type), _msg(msg),
43 _verbosity(_verbosity), _fileName(_fileName), _lineNumber(_lineNumber),
44 _time(_time), _processName(_processName), _id(_id)
45{
46 if (_msgType)
47 _msgType = strdup(_msgType);
48 if (_msg)
49 _msg = strdup(_msg);
50 _what = sc_report_compose_message(*this);
51}
52
53sc_report::sc_report(const sc_report &r) :
54 sc_report(r._severity, r._msgType, r._msg, r._verbosity, r._fileName,
55 r._lineNumber, r._time, r._processName, r._id)
56{}
57
58sc_report &
59sc_report::operator = (const sc_report &r)
60{
61 _severity = r._severity;
62 free((void *)_msgType);
63 _msgType = r._msgType ? strdup(r._msgType) : nullptr;
64 free((void *)_msg);
65 _msg = r._msg ? strdup(r._msg) : nullptr;
66 _verbosity = r._verbosity;
67 _fileName = r._fileName;
68 _lineNumber = r._lineNumber;
69 _time = r._time;
70 _processName = r._processName;
71 _id = r._id;
72 return *this;
73}
74
75sc_report::~sc_report() throw()
76{
77 free((void *)_msgType);
78 free((void *)_msg);
79}
80
81const char *
82sc_report::what() const throw()
83{
84 return _what.c_str();
85}
86
87const char *
88sc_report::get_message(int id)
89{
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),
44 _verbosity(_verbosity), _fileName(_fileName), _lineNumber(_lineNumber),
45 _time(_time), _processName(_processName), _id(_id)
46{
47 if (_msgType)
48 _msgType = strdup(_msgType);
49 if (_msg)
50 _msg = strdup(_msg);
51 _what = sc_report_compose_message(*this);
52}
53
54sc_report::sc_report(const sc_report &r) :
55 sc_report(r._severity, r._msgType, r._msg, r._verbosity, r._fileName,
56 r._lineNumber, r._time, r._processName, r._id)
57{}
58
59sc_report &
60sc_report::operator = (const sc_report &r)
61{
62 _severity = r._severity;
63 free((void *)_msgType);
64 _msgType = r._msgType ? strdup(r._msgType) : nullptr;
65 free((void *)_msg);
66 _msg = r._msg ? strdup(r._msg) : nullptr;
67 _verbosity = r._verbosity;
68 _fileName = r._fileName;
69 _lineNumber = r._lineNumber;
70 _time = r._time;
71 _processName = r._processName;
72 _id = r._id;
73 return *this;
74}
75
76sc_report::~sc_report() throw()
77{
78 free((void *)_msgType);
79 free((void *)_msg);
80}
81
82const char *
83sc_report::what() const throw()
84{
85 return _what.c_str();
86}
87
88const char *
89sc_report::get_message(int id)
90{
90 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
91 return "";
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();
92}
93
94bool
95sc_report::is_suppressed(int id)
96{
96}
97
98bool
99sc_report::is_suppressed(int id)
100{
97 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
98 return false;
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;
99}
100
101void
106}
107
108void
102sc_report::make_warnings_errors(bool)
109sc_report::make_warnings_errors(bool val)
103{
110{
104 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
111 sc_gem5::reportWarningsAsErrors = val;
105}
106
107void
108sc_report::register_id(int id, const char *msg)
109{
112}
113
114void
115sc_report::register_id(int id, const char *msg)
116{
110 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
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 }
111}
112
113void
133}
134
135void
114sc_report::suppress_id(int id, bool)
136sc_report::suppress_id(int id, bool suppress)
115{
137{
116 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
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;
117}
118
119void
146}
147
148void
120sc_report::suppress_infos(bool)
149sc_report::suppress_infos(bool suppress)
121{
150{
122 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
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;
123}
124
125void
155}
156
157void
126sc_report::suppress_warnings(bool)
158sc_report::suppress_warnings(bool suppress)
127{
159{
128 warn("%s not implemented.\n", __PRETTY_FUNCTION__);
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 }
129}
130
131void
132sc_abort()
133{
134 panic("simulation aborted");
135}
136
137} // namespace sc_core
166}
167
168void
169sc_abort()
170{
171 panic("simulation aborted");
172}
173
174} // namespace sc_core