report.hh revision 13312:a7685ffbead8
11758SN/A/*
21762SN/A * Copyright 2018 Google, Inc.
31758SN/A *
41758SN/A * Redistribution and use in source and binary forms, with or without
51758SN/A * modification, are permitted provided that the following conditions are
61758SN/A * met: redistributions of source code must retain the above copyright
71758SN/A * notice, this list of conditions and the following disclaimer;
81758SN/A * redistributions in binary form must reproduce the above copyright
91758SN/A * notice, this list of conditions and the following disclaimer in the
101758SN/A * documentation and/or other materials provided with the distribution;
111758SN/A * neither the name of the copyright holders nor the names of its
121758SN/A * contributors may be used to endorse or promote products derived from
131758SN/A * this software without specific prior written permission.
141758SN/A *
151758SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
161758SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
171758SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
181758SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
191758SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
201758SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
211758SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
221758SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
231758SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
241758SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
251758SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
261758SN/A *
272665Ssaidi@eecs.umich.edu * Authors: Gabe Black
282665Ssaidi@eecs.umich.edu */
292665Ssaidi@eecs.umich.edu
301758SN/A#ifndef __SYSTEMC_UTILS_REPORT_HH__
312SN/A#define __SYSTEMC_UTILS_REPORT_HH__
322984Sgblack@eecs.umich.edu
33732SN/A#include <map>
343565Sgblack@eecs.umich.edu#include <memory>
35732SN/A#include <string>
362984Sgblack@eecs.umich.edu
375953Ssaidi@eecs.umich.edu#include "systemc/ext/utils/sc_report.hh"
385882Snate@binkert.org#include "systemc/ext/utils/sc_report_handler.hh"
391717SN/A
402683Sktlim@umich.edunamespace sc_gem5
412680Sktlim@umich.edu{
422710Sstever@eecs.umich.edu
432SN/Astruct ReportMsgInfo
445568Snate@binkert.org{
455566Snate@binkert.org    explicit ReportMsgInfo() :
4612406Sgabeblack@google.com        actions(sc_core::SC_UNSPECIFIED), count(0), limit(-1),
4712406Sgabeblack@google.com        sevActions{ sc_core::SC_UNSPECIFIED, sc_core::SC_UNSPECIFIED,
4812406Sgabeblack@google.com                sc_core::SC_UNSPECIFIED, sc_core::SC_UNSPECIFIED },
4912406Sgabeblack@google.com        sevCounts{0, 0, 0, 0}, sevLimits{-1, -1, -1, -1}, id(-1)
5012406Sgabeblack@google.com    {}
5112406Sgabeblack@google.com
5212406Sgabeblack@google.com    void
5312406Sgabeblack@google.com    checkLimits(sc_core::sc_severity severity, sc_core::sc_actions &actions)
5412406Sgabeblack@google.com    {
5512406Sgabeblack@google.com        int sevLimit = sevLimits[severity];
5612406Sgabeblack@google.com        int sevCount = sevCounts[severity];
5712406Sgabeblack@google.com        if ((limit != -1 && limit >= count) ||
5812406Sgabeblack@google.com                (sevLimit != 1 && sevLimit >= sevCount)) {
5912406Sgabeblack@google.com            actions |= sc_core::SC_STOP;
6012406Sgabeblack@google.com        }
6112406Sgabeblack@google.com    }
6212406Sgabeblack@google.com
6312406Sgabeblack@google.com    sc_core::sc_actions actions;
642SN/A    int count;
652SN/A    int limit;
662SN/A
672SN/A    sc_core::sc_actions sevActions[sc_core::SC_MAX_SEVERITY];
682SN/A    int sevCounts[sc_core::SC_MAX_SEVERITY];
695568Snate@binkert.org    int sevLimits[sc_core::SC_MAX_SEVERITY];
702SN/A
712680Sktlim@umich.edu    int id;
72190SN/A};
732680Sktlim@umich.edu
742680Sktlim@umich.edustruct ReportSevInfo
752114SN/A{
765568Snate@binkert.org    explicit ReportSevInfo(sc_core::sc_actions actions) :
772700Sktlim@umich.edu        actions(actions), count(0), limit(-1)
787720Sgblack@eecs.umich.edu    {}
792700Sktlim@umich.edu
802700Sktlim@umich.edu    void
812SN/A    checkLimit(sc_core::sc_actions &actions)
822SN/A    {
831133SN/A        if (limit != -1 && limit >= count)
84716SN/A            actions |= sc_core::SC_STOP;
855568Snate@binkert.org    }
86716SN/A
87716SN/A    sc_core::sc_actions actions;
88739SN/A    int count;
89739SN/A    int limit;
902683Sktlim@umich.edu};
912683Sktlim@umich.edu
92716SN/Aextern const char *reportSeverityNames[sc_core::SC_MAX_SEVERITY];
93716SN/Aextern ReportSevInfo reportSevInfos[sc_core::SC_MAX_SEVERITY];
944997Sgblack@eecs.umich.eduextern std::map<std::string, ReportMsgInfo> reportMsgInfoMap;
954997Sgblack@eecs.umich.edu
964997Sgblack@eecs.umich.eduextern int reportVerbosityLevel;
974997Sgblack@eecs.umich.edu
984997Sgblack@eecs.umich.eduextern sc_core::sc_actions reportSuppressedActions;
995568Snate@binkert.orgextern sc_core::sc_actions reportForcedActions;
1004997Sgblack@eecs.umich.eduextern sc_core::sc_actions reportCatchActions;
1014997Sgblack@eecs.umich.edu
1024997Sgblack@eecs.umich.eduextern sc_core::sc_report_handler_proc reportHandlerProc;
1034997Sgblack@eecs.umich.edu
1044997Sgblack@eecs.umich.eduextern std::unique_ptr<sc_core::sc_report> globalReportCache;
1055568Snate@binkert.org
1064997Sgblack@eecs.umich.edu} // namespace sc_gem5
1074997Sgblack@eecs.umich.edu
1084997Sgblack@eecs.umich.edu#endif // __SYSTEMC_UTILS_REPORT_HH__
1094997Sgblack@eecs.umich.edu