report.cc (13316:0423798f1a05) report.cc (13323:1cfcaaf573b9)
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 "systemc/utils/report.hh"
31
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 "systemc/utils/report.hh"
31
32#include "systemc/core/python.hh"
33
32namespace sc_gem5
33{
34
35const char *reportSeverityNames[] = {
36 [sc_core::SC_INFO] = "Info",
37 [sc_core::SC_WARNING] = "Warning",
38 [sc_core::SC_ERROR] = "Error",
39 [sc_core::SC_FATAL] = "Fatal"
40};
41
42ReportSevInfo reportSevInfos[sc_core::SC_MAX_SEVERITY] =
43{
44 [sc_core::SC_INFO] = ReportSevInfo(sc_core::SC_DEFAULT_INFO_ACTIONS),
45 [sc_core::SC_WARNING] = ReportSevInfo(sc_core::SC_DEFAULT_WARNING_ACTIONS),
46 [sc_core::SC_ERROR] = ReportSevInfo(sc_core::SC_DEFAULT_ERROR_ACTIONS),
47 [sc_core::SC_FATAL] = ReportSevInfo(sc_core::SC_DEFAULT_FATAL_ACTIONS)
48};
49
50std::map<std::string, ReportMsgInfo> reportMsgInfoMap;
51std::map<int, std::string> reportIdToMsgMap;
52
53int reportVerbosityLevel = sc_core::SC_MEDIUM;
54
55sc_core::sc_actions reportSuppressedActions = sc_core::SC_UNSPECIFIED;
56sc_core::sc_actions reportForcedActions = sc_core::SC_UNSPECIFIED;
57sc_core::sc_actions reportCatchActions = sc_core::SC_DISPLAY;
58
59sc_core::sc_report_handler_proc reportHandlerProc =
60 &sc_core::sc_report_handler::default_handler;
61
62std::unique_ptr<sc_core::sc_report> globalReportCache;
63
64bool reportWarningsAsErrors = false;
65
34namespace sc_gem5
35{
36
37const char *reportSeverityNames[] = {
38 [sc_core::SC_INFO] = "Info",
39 [sc_core::SC_WARNING] = "Warning",
40 [sc_core::SC_ERROR] = "Error",
41 [sc_core::SC_FATAL] = "Fatal"
42};
43
44ReportSevInfo reportSevInfos[sc_core::SC_MAX_SEVERITY] =
45{
46 [sc_core::SC_INFO] = ReportSevInfo(sc_core::SC_DEFAULT_INFO_ACTIONS),
47 [sc_core::SC_WARNING] = ReportSevInfo(sc_core::SC_DEFAULT_WARNING_ACTIONS),
48 [sc_core::SC_ERROR] = ReportSevInfo(sc_core::SC_DEFAULT_ERROR_ACTIONS),
49 [sc_core::SC_FATAL] = ReportSevInfo(sc_core::SC_DEFAULT_FATAL_ACTIONS)
50};
51
52std::map<std::string, ReportMsgInfo> reportMsgInfoMap;
53std::map<int, std::string> reportIdToMsgMap;
54
55int reportVerbosityLevel = sc_core::SC_MEDIUM;
56
57sc_core::sc_actions reportSuppressedActions = sc_core::SC_UNSPECIFIED;
58sc_core::sc_actions reportForcedActions = sc_core::SC_UNSPECIFIED;
59sc_core::sc_actions reportCatchActions = sc_core::SC_DISPLAY;
60
61sc_core::sc_report_handler_proc reportHandlerProc =
62 &sc_core::sc_report_handler::default_handler;
63
64std::unique_ptr<sc_core::sc_report> globalReportCache;
65
66bool reportWarningsAsErrors = false;
67
66DefaultReportMessages::DefaultReportMessages(
67 std::initializer_list<std::pair<int, const char *>> msgs)
68DefaultReportMessages *&
69DefaultReportMessages::top()
68{
70{
71 static DefaultReportMessages *top_ptr = nullptr;
72 return top_ptr;
73}
74
75void
76DefaultReportMessages::install()
77{
69 for (auto &p: msgs)
70 sc_core::sc_report::register_id(p.first, p.second);
71}
72
78 for (auto &p: msgs)
79 sc_core::sc_report::register_id(p.first, p.second);
80}
81
82DefaultReportMessages::DefaultReportMessages(
83 std::initializer_list<std::pair<int, const char *>> msgs) :
84 next(top()), msgs(msgs)
85{
86 top() = this;
87}
88
89void
90DefaultReportMessages::installAll()
91{
92 for (DefaultReportMessages *ptr = top(); ptr; ptr = ptr->next)
93 ptr->install();
94}
95
96namespace
97{
98
99struct InstallDefaultReportMessages : public PythonReadyFunc
100{
101 void run() override { DefaultReportMessages::installAll(); }
102} messageInstaller;
103
104} // anonymous namespace
105
73} // namespace sc_gem5
106} // namespace sc_gem5