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