SystemC 3.0.0
Accellera SystemC proof-of-concept library
sc_report_handler.h
Go to the documentation of this file.
1/*****************************************************************************
2
3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4 more contributor license agreements. See the NOTICE file distributed
5 with this work for additional information regarding copyright ownership.
6 Accellera licenses this file to you under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with the
8 License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15 implied. See the License for the specific language governing
16 permissions and limitations under the License.
17
18 *****************************************************************************/
19
20/*****************************************************************************
21
22 sc_report_handler.h -
23
24 Original Author: Alex Riesen, Synopsys, Inc.
25 see also sc_report.h
26
27 CHANGE LOG AT END OF FILE
28 *****************************************************************************/
29
30#ifndef SC_REPORT_HANDLER_H
31#define SC_REPORT_HANDLER_H
32
33namespace sc_core {
34
35// ----------------------------------------------------------------------------
36// STRUCT : sc_msg_def
37//
38// Exception message definition structure
39// ----------------------------------------------------------------------------
40
42{
43 const char* msg_type;
46 unsigned limit;
47 unsigned sev_limit[SC_MAX_SEVERITY];
48 unsigned limit_mask; // 0 - limit, 1..4 - sev_limit
49 unsigned call_count;
50 unsigned sev_call_count[SC_MAX_SEVERITY];
52
53 int id; // backward compatibility with 2.0+
54};
55
56typedef void (* sc_report_handler_proc)(const sc_report&, const sc_actions &);
57class sc_report;
60{
61public:
62 static void report(sc_severity,
63 const char* msg_type,
64 const char* msg,
65 const char* file,
66 int line);
67
68 static void report( sc_severity,
69 const char* msg_type,
70 const char* msg,
71 int verbosity,
72 const char* file,
73 int line );
74
77
78 static sc_actions set_actions(const char * msg_type,
80
81 static sc_actions set_actions(const char * msg_type,
84
85 static int stop_after(sc_severity, int limit = -1);
86 static int stop_after(const char* msg_type, int limit = -1);
87 static int stop_after(const char* msg_type, sc_severity, int limit = -1);
88
92 static sc_actions force();
93
94 static int get_count(sc_severity severity_);
95 static int get_count(const char* msg_type_);
96 static int get_count(const char* msg_type_, sc_severity severity_);
97
98 static int get_verbosity_level();
99 static int set_verbosity_level( int level );
100
101
102 static void initialize(); // just reset counters
103 static void release(); // initialize() needed for reports after it
104
107 // use set_handler(NULL); to restore default handler
108 static void default_handler(const sc_report&, const sc_actions&);
109
111
113 static void clear_cached_report();
114
115 // if filename is NULL, the previous log file name will be removed.
116 // The provider of a report_handler supposed to handle this.
117 // Return false if filename is not NULL and filename is already set.
118 static bool set_log_file_name(const char* filename);
119 static const char* get_log_file_name();
120
121 // how the implementation should handle caught (sc_report) exceptions
124
125public: // private, actually
126
128 {
129 sc_msg_def* md; // have to point to sc_msg_def-s
130 int count; // set to number of items in md[]
131 bool allocated; // used internally, previous value ignored
132 msg_def_items* next; // used internally, previous value ignored
133 };
134
136 static sc_msg_def* add_msg_type(const char * msg_type);
137
138protected:
139
140 static void cache_report(const sc_report&);
142
145 static sc_actions sev_actions[SC_MAX_SEVERITY];
146 static unsigned sev_limit[SC_MAX_SEVERITY];
147 static unsigned sev_call_count[SC_MAX_SEVERITY];
151 static char* log_file_name;
152 static int verbosity_level;
153
156
158
159 static sc_msg_def* mdlookup(const char* msg_type);
160
161private: // backward compatibility with 2.0+
162
163 friend class sc_report;
164 static sc_msg_def* mdlookup(int id);
165
166public:
167
168 /* PJF extra wrapper to match SC_REPORT_INFO etc macros */
169 static void report(sc_severity,
170 int id,
171 const char* add_msg,
172 int verbosity,
173 const char* file,
174 int line);
175
176 static void report(sc_severity,
177 int id,
178 const char* add_msg,
179 const char* file,
180 int line);
181
182};
183
184} // namespace sc_core
185
186// $Log: sc_report_handler.h,v $
187// Revision 1.5 2011/08/26 20:46:19 acg
188// Andy Goodrich: moved the modification log to the end of the file to
189// eliminate source line number skew when check-ins are done.
190//
191// Revision 1.4 2011/03/23 16:16:49 acg
192// Andy Goodrich: finish message verbosity support.
193//
194// Revision 1.3 2011/02/18 20:38:44 acg
195// Andy Goodrich: Updated Copyright notice.
196//
197// Revision 1.2 2011/02/01 23:02:05 acg
198// Andy Goodrich: IEEE 1666 2011 changes.
199//
200// Revision 1.1.1.1 2006/12/15 20:20:06 acg
201// SystemC 2.3
202//
203// Revision 1.3 2006/01/13 18:53:11 acg
204// Andy Goodrich: Added $Log command so that CVS comments are reproduced in
205// the source.
206//
207
208#endif
209
210// Taf!
#define SC_API
Definition: sc_cmnhdr.h:148
@ SC_UNSPECIFIED
Definition: sc_report.h:86
unsigned sc_actions
Definition: sc_report.h:83
SC_API bool sc_report_close_default_log()
sc_severity
Definition: sc_report.h:54
@ SC_MAX_SEVERITY
Definition: sc_report.h:59
void(* sc_report_handler_proc)(const sc_report &, const sc_actions &)
static void add_static_msg_types(msg_def_items *)
static sc_msg_def * mdlookup(const char *msg_type)
static int set_verbosity_level(int level)
static sc_actions set_actions(sc_severity, sc_actions=SC_UNSPECIFIED)
static sc_report_handler_proc handler
static sc_report_handler_proc get_handler()
static void report(sc_severity, const char *msg_type, const char *msg, const char *file, int line)
static sc_report * last_global_report
static void default_handler(const sc_report &, const sc_actions &)
static sc_actions force()
static void report(sc_severity, int id, const char *add_msg, int verbosity, const char *file, int line)
static msg_def_items msg_terminator
static int stop_after(const char *msg_type, sc_severity, int limit=-1)
static void report(sc_severity, const char *msg_type, const char *msg, int verbosity, const char *file, int line)
static sc_msg_def * add_msg_type(const char *msg_type)
static sc_actions get_new_action_id()
static sc_actions suppress()
static sc_actions get_catch_actions()
static int stop_after(const char *msg_type, int limit=-1)
static sc_actions set_actions(const char *msg_type, sc_severity, sc_actions=SC_UNSPECIFIED)
static sc_report_handler_proc set_handler(sc_report_handler_proc)
static int get_count(const char *msg_type_)
static sc_actions execute(sc_msg_def *, sc_severity)
static sc_actions catch_actions
static sc_report * get_cached_report()
static sc_actions set_actions(const char *msg_type, sc_actions=SC_UNSPECIFIED)
static sc_actions force(sc_actions)
static void cache_report(const sc_report &)
static sc_actions suppress_mask
static sc_actions set_catch_actions(sc_actions)
static int stop_after(sc_severity, int limit=-1)
static int get_verbosity_level()
static int get_count(const char *msg_type_, sc_severity severity_)
static sc_actions suppress(sc_actions)
static sc_actions available_actions
static int get_count(sc_severity severity_)
static void clear_cached_report()
static void report(sc_severity, int id, const char *add_msg, const char *file, int line)
static const char * get_log_file_name()
static bool set_log_file_name(const char *filename)
static msg_def_items * messages