report.hh (13323:1cfcaaf573b9) report.hh (13401:3bf529b4bc51)
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#ifndef __SYSTEMC_UTILS_REPORT_HH__
31#define __SYSTEMC_UTILS_REPORT_HH__
32
33#include <initializer_list>
34#include <map>
35#include <memory>
36#include <string>
37#include <utility>
38
39#include "systemc/ext/utils/sc_report.hh"
40#include "systemc/ext/utils/sc_report_handler.hh"
41
42namespace sc_gem5
43{
44
45struct ReportMsgInfo
46{
47 explicit ReportMsgInfo() :
48 actions(sc_core::SC_UNSPECIFIED), count(0), limit(-1),
49 sevActions{ sc_core::SC_UNSPECIFIED, sc_core::SC_UNSPECIFIED,
50 sc_core::SC_UNSPECIFIED, sc_core::SC_UNSPECIFIED },
51 sevCounts{0, 0, 0, 0}, sevLimits{-1, -1, -1, -1}, id(-1)
52 {}
53
54 void
55 checkLimits(sc_core::sc_severity severity, sc_core::sc_actions &actions)
56 {
57 int sevLimit = sevLimits[severity];
58 int sevCount = sevCounts[severity];
59 if ((limit != -1 && limit >= count) ||
60 (sevLimit != 1 && sevLimit >= sevCount)) {
61 actions |= sc_core::SC_STOP;
62 }
63 }
64
65 sc_core::sc_actions actions;
66 int count;
67 int limit;
68
69 sc_core::sc_actions sevActions[sc_core::SC_MAX_SEVERITY];
70 int sevCounts[sc_core::SC_MAX_SEVERITY];
71 int sevLimits[sc_core::SC_MAX_SEVERITY];
72
73 int id;
74};
75
76struct ReportSevInfo
77{
78 explicit ReportSevInfo(sc_core::sc_actions actions) :
79 actions(actions), count(0), limit(-1)
80 {}
81
82 void
83 checkLimit(sc_core::sc_actions &actions)
84 {
85 if (limit != -1 && limit >= count)
86 actions |= sc_core::SC_STOP;
87 }
88
89 sc_core::sc_actions actions;
90 int count;
91 int limit;
92};
93
94extern const char *reportSeverityNames[sc_core::SC_MAX_SEVERITY];
95extern ReportSevInfo reportSevInfos[sc_core::SC_MAX_SEVERITY];
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#ifndef __SYSTEMC_UTILS_REPORT_HH__
31#define __SYSTEMC_UTILS_REPORT_HH__
32
33#include <initializer_list>
34#include <map>
35#include <memory>
36#include <string>
37#include <utility>
38
39#include "systemc/ext/utils/sc_report.hh"
40#include "systemc/ext/utils/sc_report_handler.hh"
41
42namespace sc_gem5
43{
44
45struct ReportMsgInfo
46{
47 explicit ReportMsgInfo() :
48 actions(sc_core::SC_UNSPECIFIED), count(0), limit(-1),
49 sevActions{ sc_core::SC_UNSPECIFIED, sc_core::SC_UNSPECIFIED,
50 sc_core::SC_UNSPECIFIED, sc_core::SC_UNSPECIFIED },
51 sevCounts{0, 0, 0, 0}, sevLimits{-1, -1, -1, -1}, id(-1)
52 {}
53
54 void
55 checkLimits(sc_core::sc_severity severity, sc_core::sc_actions &actions)
56 {
57 int sevLimit = sevLimits[severity];
58 int sevCount = sevCounts[severity];
59 if ((limit != -1 && limit >= count) ||
60 (sevLimit != 1 && sevLimit >= sevCount)) {
61 actions |= sc_core::SC_STOP;
62 }
63 }
64
65 sc_core::sc_actions actions;
66 int count;
67 int limit;
68
69 sc_core::sc_actions sevActions[sc_core::SC_MAX_SEVERITY];
70 int sevCounts[sc_core::SC_MAX_SEVERITY];
71 int sevLimits[sc_core::SC_MAX_SEVERITY];
72
73 int id;
74};
75
76struct ReportSevInfo
77{
78 explicit ReportSevInfo(sc_core::sc_actions actions) :
79 actions(actions), count(0), limit(-1)
80 {}
81
82 void
83 checkLimit(sc_core::sc_actions &actions)
84 {
85 if (limit != -1 && limit >= count)
86 actions |= sc_core::SC_STOP;
87 }
88
89 sc_core::sc_actions actions;
90 int count;
91 int limit;
92};
93
94extern const char *reportSeverityNames[sc_core::SC_MAX_SEVERITY];
95extern ReportSevInfo reportSevInfos[sc_core::SC_MAX_SEVERITY];
96extern std::map<std::string, ReportMsgInfo> reportMsgInfoMap;
97extern std::map<int, std::string> reportIdToMsgMap;
98
96
97std::map<std::string, ReportMsgInfo> &reportMsgInfoMap();
98std::map<int, std::string> &reportIdToMsgMap();
99
99extern int reportVerbosityLevel;
100
101extern sc_core::sc_actions reportSuppressedActions;
102extern sc_core::sc_actions reportForcedActions;
103extern sc_core::sc_actions reportCatchActions;
104
105extern sc_core::sc_report_handler_proc reportHandlerProc;
106
107extern std::unique_ptr<sc_core::sc_report> globalReportCache;
108
109extern bool reportWarningsAsErrors;
110
111struct DefaultReportMessages
112{
113 protected:
114 static DefaultReportMessages *&top();
115 DefaultReportMessages *next;
116
117 std::initializer_list<std::pair<int, const char *>> msgs;
118 void install();
119
120 public:
121 DefaultReportMessages(std::initializer_list<std::pair<int, const char *>>);
122
123 static void installAll();
124};
125
126} // namespace sc_gem5
127
128#endif // __SYSTEMC_UTILS_REPORT_HH__
100extern int reportVerbosityLevel;
101
102extern sc_core::sc_actions reportSuppressedActions;
103extern sc_core::sc_actions reportForcedActions;
104extern sc_core::sc_actions reportCatchActions;
105
106extern sc_core::sc_report_handler_proc reportHandlerProc;
107
108extern std::unique_ptr<sc_core::sc_report> globalReportCache;
109
110extern bool reportWarningsAsErrors;
111
112struct DefaultReportMessages
113{
114 protected:
115 static DefaultReportMessages *&top();
116 DefaultReportMessages *next;
117
118 std::initializer_list<std::pair<int, const char *>> msgs;
119 void install();
120
121 public:
122 DefaultReportMessages(std::initializer_list<std::pair<int, const char *>>);
123
124 static void installAll();
125};
126
127} // namespace sc_gem5
128
129#endif // __SYSTEMC_UTILS_REPORT_HH__