SystemC  2.3.1
Accellera SystemC proof-of-concept library
sc_report_handler.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  The following code is derived, directly or indirectly, from the SystemC
4  source code Copyright (c) 1996-2014 by all Contributors.
5  All Rights reserved.
6 
7  The contents of this file are subject to the restrictions and limitations
8  set forth in the SystemC Open Source License (the "License");
9  You may not use this file except in compliance with such restrictions and
10  limitations. You may obtain instructions on how to receive a copy of the
11  License at http://www.accellera.org/. Software distributed by Contributors
12  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
13  ANY KIND, either express or implied. See the License for the specific
14  language governing rights and limitations under the License.
15 
16  *****************************************************************************/
17 
18 /*****************************************************************************
19 
20  sc_report_handler.h -
21 
22  Original Author: Alex Riesen, Synopsys, Inc.
23  see also sc_report.h
24 
25  CHANGE LOG AT END OF FILE
26  *****************************************************************************/
27 
28 #ifndef SC_REPORT_HANDLER_H
29 #define SC_REPORT_HANDLER_H
30 
31 namespace sc_core {
32 
33 // ----------------------------------------------------------------------------
34 // STRUCT : sc_msg_def
35 //
36 // Exception message definition structure
37 // ----------------------------------------------------------------------------
38 
39 struct sc_msg_def
40 {
41  const char* msg_type;
44  unsigned limit;
46  unsigned limit_mask; // 0 - limit, 1..4 - sev_limit
47  unsigned call_count;
50 
51  int id; // backward compatibility with 2.0+
52 };
53 
54 typedef void (* sc_report_handler_proc)(const sc_report&, const sc_actions &);
55 class sc_report;
56 extern bool sc_report_close_default_log();
58 {
59 public:
60  static void report(sc_severity,
61  const char* msg_type,
62  const char* msg,
63  const char* file,
64  int line);
65 
66  static void report( sc_severity,
67  const char* msg_type,
68  const char* msg,
69  int verbosity,
70  const char* file,
71  int line );
72 
75 
76  static sc_actions set_actions(const char * msg_type,
78 
79  static sc_actions set_actions(const char * msg_type,
82 
83  static int stop_after(sc_severity, int limit = -1);
84  static int stop_after(const char* msg_type, int limit = -1);
85  static int stop_after(const char* msg_type, sc_severity, int limit = -1);
86 
88  static sc_actions suppress();
89  static sc_actions force(sc_actions);
90  static sc_actions force();
91 
92  static int get_count(sc_severity severity_);
93  static int get_count(const char* msg_type_);
94  static int get_count(const char* msg_type_, sc_severity severity_);
95 
96  static int get_verbosity_level();
97  static int set_verbosity_level( int level );
98 
99 
100  static void initialize(); // just reset counters
101  static void release(); // initialize() needed for reports after it
102 
105  // use set_handler(NULL); to restore default handler
106  static void default_handler(const sc_report&, const sc_actions&);
107 
108  static sc_actions get_new_action_id();
109 
110  static sc_report* get_cached_report();
111  static void clear_cached_report();
112 
113  // if filename is NULL, the previous log file name will be removed.
114  // The provider of a report_handler supposed to handle this.
115  // Return false if filename is not NULL and filename is already set.
116  static bool set_log_file_name(const char* filename);
117  static const char* get_log_file_name();
118 
119 public: // private, actually
120 
122  {
123  sc_msg_def* md; // have to point to sc_msg_def-s
124  int count; // set to number of items in md[]
125  bool allocated; // used internally, previous value ignored
126  msg_def_items* next; // used internally, previous value ignored
127  };
128 
129  static void add_static_msg_types(msg_def_items *);
130  static sc_msg_def* add_msg_type(const char * msg_type);
131 
132 protected:
133 
134  static void cache_report(const sc_report&);
136 
140  static unsigned sev_limit[SC_MAX_SEVERITY];
141  static unsigned sev_call_count[SC_MAX_SEVERITY];
144  static char* log_file_name;
145  static int verbosity_level;
146 
149 
151 
152  static sc_msg_def* mdlookup(const char* msg_type);
153 
154 private: // backward compatibility with 2.0+
155 
156  friend class sc_report;
157  static sc_msg_def* mdlookup(int id);
158 
159 public:
160 
161  static void report(sc_severity,
162  int id,
163  const char* add_msg,
164  const char* file,
165  int line);
166 
167 };
168 
169 } // namespace sc_core
170 
171 // $Log: sc_report_handler.h,v $
172 // Revision 1.5 2011/08/26 20:46:19 acg
173 // Andy Goodrich: moved the modification log to the end of the file to
174 // eliminate source line number skew when check-ins are done.
175 //
176 // Revision 1.4 2011/03/23 16:16:49 acg
177 // Andy Goodrich: finish message verbosity support.
178 //
179 // Revision 1.3 2011/02/18 20:38:44 acg
180 // Andy Goodrich: Updated Copyright notice.
181 //
182 // Revision 1.2 2011/02/01 23:02:05 acg
183 // Andy Goodrich: IEEE 1666 2011 changes.
184 //
185 // Revision 1.1.1.1 2006/12/15 20:20:06 acg
186 // SystemC 2.3
187 //
188 // Revision 1.3 2006/01/13 18:53:11 acg
189 // Andy Goodrich: Added $Log command so that CVS comments are reproduced in
190 // the source.
191 //
192 
193 #endif
194 
195 // Taf!
static sc_report_handler_proc get_handler()
static sc_actions force()
static sc_report_handler_proc handler
static const char * get_log_file_name()
sc_actions sev_actions[SC_MAX_SEVERITY]
sc_severity
Definition: sc_report.h:46
static sc_msg_def * mdlookup(const char *msg_type)
static void cache_report(const sc_report &)
static sc_actions execute(sc_msg_def *, sc_severity)
static void add_static_msg_types(msg_def_items *)
static sc_actions get_new_action_id()
unsigned sc_actions
Definition: sc_report.h:54
static sc_report * last_global_report
static unsigned sev_call_count[SC_MAX_SEVERITY]
static int get_count(sc_severity severity_)
unsigned sev_limit[SC_MAX_SEVERITY]
static msg_def_items msg_terminator
static sc_actions available_actions
static void default_handler(const sc_report &, const sc_actions &)
static sc_actions suppress_mask
static sc_actions suppress()
static void clear_cached_report()
static int set_verbosity_level(int level)
static sc_msg_def * add_msg_type(const char *msg_type)
bool sc_report_close_default_log()
unsigned sev_call_count[SC_MAX_SEVERITY]
static bool set_log_file_name(const char *filename)
static void report(sc_severity, const char *msg_type, const char *msg, const char *file, int line)
static int get_verbosity_level()
void(* sc_report_handler_proc)(const sc_report &, const sc_actions &)
static sc_actions sev_actions[SC_MAX_SEVERITY]
static sc_actions set_actions(sc_severity, sc_actions=SC_UNSPECIFIED)
static int stop_after(sc_severity, int limit=-1)
static sc_report_handler_proc set_handler(sc_report_handler_proc)
static msg_def_items * messages
static unsigned sev_limit[SC_MAX_SEVERITY]
static sc_report * get_cached_report()