gem5  v20.1.0.0
sc_report_handler.hh
Go to the documentation of this file.
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 
28 #ifndef __SYSTEMC_EXT_UTIL_SC_REPORT_HANDLER_HH__
29 #define __SYSTEMC_EXT_UTIL_SC_REPORT_HANDLER_HH__
30 
31 #include <string>
32 
33 #include "messages.hh"
34 #include "sc_report.hh" // for sc_severity
35 
36 namespace sc_core
37 {
38 
39 typedef unsigned sc_actions;
40 
41 enum
42 {
43  SC_UNSPECIFIED = 0x0000,
44  SC_DO_NOTHING = 0x0001,
45  SC_THROW = 0x0002,
46  SC_LOG = 0x0004,
47  SC_DISPLAY = 0x0008,
48  SC_CACHE_REPORT = 0x0010,
49  SC_INTERRUPT = 0x0020,
50  SC_STOP = 0x0040,
51  SC_ABORT = 0x0080,
52 
53  // The spec says these should be macros, but that breaks the build for the
54  // regression tests since they refer to, for instance,
55  // sc_core::SC_DEFAULT_INFO_ACTIONS.
60 };
61 
62 typedef void (*sc_report_handler_proc)(const sc_report &, const sc_actions &);
63 
65 {
66  public:
67  static void report(sc_severity, const char *msg_type, const char *msg,
68  const char *file, int line);
69  static void report(sc_severity, const char *msg_type, const char *msg,
70  int verbosity, const char *file, int line);
71 
72  // Deprecated
73  static void report(sc_severity, int id, const char *msg, const char *file,
74  int line);
75 
77  static sc_actions set_actions(const char *msg_type,
79  static sc_actions set_actions(const char *msg_type, sc_severity,
81 
82  static int stop_after(sc_severity, int limit=-1);
83  static int stop_after(const char *msg_type, int limit=-1);
84  static int stop_after(const char *msg_type, sc_severity, int limit=-1);
85 
86  static int get_count(sc_severity);
87  static int get_count(const char *msg_type);
88  static int get_count(const char *msg_type, sc_severity);
89 
90  // Nonstandard
91  // In the spec, these aren't listed as static functions. They are static in
92  // the Accellera implementation and are used as such in the tests.
93  static int set_verbosity_level(int);
94  static int get_verbosity_level();
95 
97  static sc_actions suppress();
98  static sc_actions force(sc_actions);
99  static sc_actions force();
100 
102  static sc_actions get_catch_actions();
103 
104  static void set_handler(sc_report_handler_proc);
105  static void default_handler(const sc_report &, const sc_actions &);
106  static sc_actions get_new_action_id();
107 
108  static sc_report *get_cached_report();
109  static void clear_cached_report();
110 
111  static bool set_log_file_name(const char *);
112  static const char *get_log_file_name();
113 };
114 
115 #define SC_REPORT_INFO_VERB(msg_type, msg, verbosity) \
116  ::sc_core::sc_report_handler::report( \
117  ::sc_core::SC_INFO, msg_type, msg, verbosity, __FILE__, __LINE__)
118 
119 #define SC_REPORT_INFO(msg_type, msg) \
120  ::sc_core::sc_report_handler::report( \
121  ::sc_core::SC_INFO, msg_type, msg, __FILE__, __LINE__)
122 
123 #define SC_REPORT_WARNING(msg_type, msg) \
124  ::sc_core::sc_report_handler::report( \
125  ::sc_core::SC_WARNING, msg_type, msg, __FILE__, __LINE__)
126 
127 #define SC_REPORT_ERROR(msg_type, msg) \
128  ::sc_core::sc_report_handler::report( \
129  ::sc_core::SC_ERROR, msg_type, msg, __FILE__, __LINE__)
130 
131 #define SC_REPORT_FATAL(msg_type, msg) \
132  ::sc_core::sc_report_handler::report( \
133  ::sc_core::SC_FATAL, msg_type, msg, __FILE__, __LINE__)
134 
135 #define sc_assert(expr) \
136  ((void)((expr) ? 0 : (SC_REPORT_FATAL( \
137  ::sc_core::SC_ID_ASSERTION_FAILED_, #expr), 0)))
138 
139 void sc_interrupt_here(const char *msg_type, sc_severity);
140 void sc_stop_here(const char *msg_type, sc_severity);
141 
142 // Nonstandard
143 // From Accellera, "not documented, but available".
144 const std::string sc_report_compose_message(const sc_report &);
146 
147 } // namespace sc_core
148 
149 #endif //__SYSTEMC_EXT_UTIL_SC_REPORT_HANDLER_HH__
sc_core::SC_DEFAULT_ERROR_ACTIONS
@ SC_DEFAULT_ERROR_ACTIONS
Definition: sc_report_handler.hh:58
sc_core::sc_report_handler::get_count
static int get_count(sc_severity)
Definition: sc_report_handler.cc:189
messages.hh
sc_core::sc_actions
unsigned sc_actions
Definition: sc_report_handler.hh:39
sc_core::SC_THROW
@ SC_THROW
Definition: sc_report_handler.hh:45
sc_core::sc_severity
sc_severity
Definition: sc_report.hh:39
sc_core::sc_report_handler::set_catch_actions
static sc_actions set_catch_actions(sc_actions)
Definition: sc_report_handler.cc:257
sc_core::sc_report_compose_message
const std::string sc_report_compose_message(const sc_report &)
Definition: sc_report_handler.cc:370
sc_core::sc_report_handler::set_actions
static sc_actions set_actions(sc_severity, sc_actions=SC_UNSPECIFIED)
Definition: sc_report_handler.cc:121
sc_core::SC_UNSPECIFIED
@ SC_UNSPECIFIED
Definition: sc_report_handler.hh:43
sc_core
Definition: messages.cc:31
sc_core::sc_report_handler::default_handler
static void default_handler(const sc_report &, const sc_actions &)
Definition: sc_report_handler.cc:278
sc_core::sc_report_close_default_log
bool sc_report_close_default_log()
Definition: sc_report_handler.cc:403
sc_core::sc_report_handler::force
static sc_actions force()
Definition: sc_report_handler.cc:250
sc_core::sc_report_handler::clear_cached_report
static void clear_cached_report()
Definition: sc_report_handler.cc:322
sc_core::sc_report_handler::suppress
static sc_actions suppress()
Definition: sc_report_handler.cc:236
sc_core::sc_report_handler::stop_after
static int stop_after(sc_severity, int limit=-1)
Definition: sc_report_handler.cc:155
sc_core::sc_report_handler::get_catch_actions
static sc_actions get_catch_actions()
Definition: sc_report_handler.cc:265
sc_core::sc_report_handler
Definition: sc_report_handler.hh:64
sc_core::SC_DEFAULT_INFO_ACTIONS
@ SC_DEFAULT_INFO_ACTIONS
Definition: sc_report_handler.hh:56
sc_core::sc_report_handler::set_verbosity_level
static int set_verbosity_level(int)
Definition: sc_report_handler.cc:213
sc_core::sc_report_handler::report
static void report(sc_severity, const char *msg_type, const char *msg, const char *file, int line)
Definition: sc_report_handler.cc:53
sc_core::SC_LOG
@ SC_LOG
Definition: sc_report_handler.hh:46
sc_core::SC_ABORT
@ SC_ABORT
Definition: sc_report_handler.hh:51
sc_core::SC_DISPLAY
@ SC_DISPLAY
Definition: sc_report_handler.hh:47
sc_core::SC_STOP
@ SC_STOP
Definition: sc_report_handler.hh:50
sc_core::SC_INTERRUPT
@ SC_INTERRUPT
Definition: sc_report_handler.hh:49
sc_core::sc_report
Definition: sc_report.hh:60
sc_core::sc_stop_here
void sc_stop_here(const char *msg_type, sc_severity)
Definition: sc_report_handler.cc:364
sc_core::SC_DEFAULT_FATAL_ACTIONS
@ SC_DEFAULT_FATAL_ACTIONS
Definition: sc_report_handler.hh:59
sc_core::sc_report_handler_proc
void(* sc_report_handler_proc)(const sc_report &, const sc_actions &)
Definition: sc_report_handler.hh:62
sc_core::sc_report_handler::get_new_action_id
static sc_actions get_new_action_id()
Definition: sc_report_handler.cc:305
sc_report.hh
sc_core::sc_report_handler::set_handler
static void set_handler(sc_report_handler_proc)
Definition: sc_report_handler.cc:272
sc_core::sc_report_handler::get_verbosity_level
static int get_verbosity_level()
Definition: sc_report_handler.cc:221
sc_core::sc_interrupt_here
void sc_interrupt_here(const char *msg_type, sc_severity)
Definition: sc_report_handler.cc:358
X86ISA::limit
BitfieldType< SegDescriptorLimit > limit
Definition: misc.hh:924
sc_core::sc_report_handler::get_cached_report
static sc_report * get_cached_report()
Definition: sc_report_handler.cc:313
sc_core::sc_report_handler::get_log_file_name
static const char * get_log_file_name()
Definition: sc_report_handler.cc:349
sc_core::sc_report_handler::set_log_file_name
static bool set_log_file_name(const char *)
Definition: sc_report_handler.cc:333
sc_core::SC_DEFAULT_WARNING_ACTIONS
@ SC_DEFAULT_WARNING_ACTIONS
Definition: sc_report_handler.hh:57
sc_core::SC_CACHE_REPORT
@ SC_CACHE_REPORT
Definition: sc_report_handler.hh:48
sc_core::SC_DO_NOTHING
@ SC_DO_NOTHING
Definition: sc_report_handler.hh:44

Generated on Wed Sep 30 2020 14:02:16 for gem5 by doxygen 1.8.17