SystemC  2.3.2
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 
33 namespace sc_core {
34 
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 
56 typedef void (* sc_report_handler_proc)(const sc_report&, const sc_actions &);
57 class sc_report;
60 {
61 public:
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 
75  static sc_actions set_actions(sc_severity,
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 
89  static sc_actions suppress(sc_actions);
90  static sc_actions suppress();
91  static sc_actions force(sc_actions);
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 
106  static sc_report_handler_proc get_handler();
107  // use set_handler(NULL); to restore default handler
108  static void default_handler(const sc_report&, const sc_actions&);
109 
110  static sc_actions get_new_action_id();
111 
112  static sc_report* get_cached_report();
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
122  static sc_actions set_catch_actions(sc_actions);
123  static sc_actions get_catch_actions();
124 
125 public: // 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 
135  static void add_static_msg_types(msg_def_items *);
136  static sc_msg_def* add_msg_type(const char * msg_type);
137 
138 protected:
139 
140  static void cache_report(const sc_report&);
141  static sc_actions execute(sc_msg_def*, sc_severity);
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];
148  static sc_report* last_global_report;
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 
161 private: // backward compatibility with 2.0+
162 
163  friend class sc_report;
164  static sc_msg_def* mdlookup(int id);
165 
166 public:
167 
168  static void report(sc_severity,
169  int id,
170  const char* add_msg,
171  const char* file,
172  int line);
173 
174 };
175 
176 } // namespace sc_core
177 
178 // $Log: sc_report_handler.h,v $
179 // Revision 1.5 2011/08/26 20:46:19 acg
180 // Andy Goodrich: moved the modification log to the end of the file to
181 // eliminate source line number skew when check-ins are done.
182 //
183 // Revision 1.4 2011/03/23 16:16:49 acg
184 // Andy Goodrich: finish message verbosity support.
185 //
186 // Revision 1.3 2011/02/18 20:38:44 acg
187 // Andy Goodrich: Updated Copyright notice.
188 //
189 // Revision 1.2 2011/02/01 23:02:05 acg
190 // Andy Goodrich: IEEE 1666 2011 changes.
191 //
192 // Revision 1.1.1.1 2006/12/15 20:20:06 acg
193 // SystemC 2.3
194 //
195 // Revision 1.3 2006/01/13 18:53:11 acg
196 // Andy Goodrich: Added $Log command so that CVS comments are reproduced in
197 // the source.
198 //
199 
200 #endif
201 
202 // Taf!
look for lower-priority rule
Definition: sc_report.h:90
Exception message definition structure.
static sc_actions suppress_mask
static sc_actions catch_actions
unsigned sc_actions
Definition: sc_report.h:87
static sc_actions available_actions
Exception reporting.
Definition: sc_report.h:121
static sc_report_handler_proc handler
sc_severity
Enumeration of possible exception severity levels.
Definition: sc_report.h:58
SC_API bool sc_report_close_default_log()
static msg_def_items * messages
static sc_report * last_global_report
static msg_def_items msg_terminator
#define SC_API
Definition: sc_cmnhdr.h:168
void(* sc_report_handler_proc)(const sc_report &, const sc_actions &)