report.hh revision 13312
113312Sgabeblack@google.com/*
213312Sgabeblack@google.com * Copyright 2018 Google, Inc.
313312Sgabeblack@google.com *
413312Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
513312Sgabeblack@google.com * modification, are permitted provided that the following conditions are
613312Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
713312Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
813312Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
913312Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1013312Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1113312Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1213312Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1313312Sgabeblack@google.com * this software without specific prior written permission.
1413312Sgabeblack@google.com *
1513312Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1613312Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1713312Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1813312Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1913312Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2013312Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2113312Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2213312Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2313312Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2413312Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2513312Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2613312Sgabeblack@google.com *
2713312Sgabeblack@google.com * Authors: Gabe Black
2813312Sgabeblack@google.com */
2913312Sgabeblack@google.com
3013312Sgabeblack@google.com#ifndef __SYSTEMC_UTILS_REPORT_HH__
3113312Sgabeblack@google.com#define __SYSTEMC_UTILS_REPORT_HH__
3213312Sgabeblack@google.com
3313312Sgabeblack@google.com#include <map>
3413312Sgabeblack@google.com#include <memory>
3513312Sgabeblack@google.com#include <string>
3613312Sgabeblack@google.com
3713312Sgabeblack@google.com#include "systemc/ext/utils/sc_report.hh"
3813312Sgabeblack@google.com#include "systemc/ext/utils/sc_report_handler.hh"
3913312Sgabeblack@google.com
4013312Sgabeblack@google.comnamespace sc_gem5
4113312Sgabeblack@google.com{
4213312Sgabeblack@google.com
4313312Sgabeblack@google.comstruct ReportMsgInfo
4413312Sgabeblack@google.com{
4513312Sgabeblack@google.com    explicit ReportMsgInfo() :
4613312Sgabeblack@google.com        actions(sc_core::SC_UNSPECIFIED), count(0), limit(-1),
4713312Sgabeblack@google.com        sevActions{ sc_core::SC_UNSPECIFIED, sc_core::SC_UNSPECIFIED,
4813312Sgabeblack@google.com                sc_core::SC_UNSPECIFIED, sc_core::SC_UNSPECIFIED },
4913312Sgabeblack@google.com        sevCounts{0, 0, 0, 0}, sevLimits{-1, -1, -1, -1}, id(-1)
5013312Sgabeblack@google.com    {}
5113312Sgabeblack@google.com
5213312Sgabeblack@google.com    void
5313312Sgabeblack@google.com    checkLimits(sc_core::sc_severity severity, sc_core::sc_actions &actions)
5413312Sgabeblack@google.com    {
5513312Sgabeblack@google.com        int sevLimit = sevLimits[severity];
5613312Sgabeblack@google.com        int sevCount = sevCounts[severity];
5713312Sgabeblack@google.com        if ((limit != -1 && limit >= count) ||
5813312Sgabeblack@google.com                (sevLimit != 1 && sevLimit >= sevCount)) {
5913312Sgabeblack@google.com            actions |= sc_core::SC_STOP;
6013312Sgabeblack@google.com        }
6113312Sgabeblack@google.com    }
6213312Sgabeblack@google.com
6313312Sgabeblack@google.com    sc_core::sc_actions actions;
6413312Sgabeblack@google.com    int count;
6513312Sgabeblack@google.com    int limit;
6613312Sgabeblack@google.com
6713312Sgabeblack@google.com    sc_core::sc_actions sevActions[sc_core::SC_MAX_SEVERITY];
6813312Sgabeblack@google.com    int sevCounts[sc_core::SC_MAX_SEVERITY];
6913312Sgabeblack@google.com    int sevLimits[sc_core::SC_MAX_SEVERITY];
7013312Sgabeblack@google.com
7113312Sgabeblack@google.com    int id;
7213312Sgabeblack@google.com};
7313312Sgabeblack@google.com
7413312Sgabeblack@google.comstruct ReportSevInfo
7513312Sgabeblack@google.com{
7613312Sgabeblack@google.com    explicit ReportSevInfo(sc_core::sc_actions actions) :
7713312Sgabeblack@google.com        actions(actions), count(0), limit(-1)
7813312Sgabeblack@google.com    {}
7913312Sgabeblack@google.com
8013312Sgabeblack@google.com    void
8113312Sgabeblack@google.com    checkLimit(sc_core::sc_actions &actions)
8213312Sgabeblack@google.com    {
8313312Sgabeblack@google.com        if (limit != -1 && limit >= count)
8413312Sgabeblack@google.com            actions |= sc_core::SC_STOP;
8513312Sgabeblack@google.com    }
8613312Sgabeblack@google.com
8713312Sgabeblack@google.com    sc_core::sc_actions actions;
8813312Sgabeblack@google.com    int count;
8913312Sgabeblack@google.com    int limit;
9013312Sgabeblack@google.com};
9113312Sgabeblack@google.com
9213312Sgabeblack@google.comextern const char *reportSeverityNames[sc_core::SC_MAX_SEVERITY];
9313312Sgabeblack@google.comextern ReportSevInfo reportSevInfos[sc_core::SC_MAX_SEVERITY];
9413312Sgabeblack@google.comextern std::map<std::string, ReportMsgInfo> reportMsgInfoMap;
9513312Sgabeblack@google.com
9613312Sgabeblack@google.comextern int reportVerbosityLevel;
9713312Sgabeblack@google.com
9813312Sgabeblack@google.comextern sc_core::sc_actions reportSuppressedActions;
9913312Sgabeblack@google.comextern sc_core::sc_actions reportForcedActions;
10013312Sgabeblack@google.comextern sc_core::sc_actions reportCatchActions;
10113312Sgabeblack@google.com
10213312Sgabeblack@google.comextern sc_core::sc_report_handler_proc reportHandlerProc;
10313312Sgabeblack@google.com
10413312Sgabeblack@google.comextern std::unique_ptr<sc_core::sc_report> globalReportCache;
10513312Sgabeblack@google.com
10613312Sgabeblack@google.com} // namespace sc_gem5
10713312Sgabeblack@google.com
10813312Sgabeblack@google.com#endif // __SYSTEMC_UTILS_REPORT_HH__
109