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 41struct sc_msg_def 42{ 43 const char* msg_type; 44 sc_actions actions; 45 sc_actions sev_actions[SC_MAX_SEVERITY]; 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]; 51 char* msg_type_data; 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; 58extern bool sc_report_close_default_log(); 59class sc_report_handler 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 75 static sc_actions set_actions(sc_severity, 76 sc_actions = SC_UNSPECIFIED); 77 78 static sc_actions set_actions(const char * msg_type, 79 sc_actions = SC_UNSPECIFIED); 80 81 static sc_actions set_actions(const char * msg_type, 82 sc_severity, 83 sc_actions = SC_UNSPECIFIED); 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 105 static sc_report_handler_proc set_handler(sc_report_handler_proc); 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 121public: // private, actually 122 123 struct msg_def_items 124 { 125 sc_msg_def* md; // have to point to sc_msg_def-s 126 int count; // set to number of items in md[] 127 bool allocated; // used internally, previous value ignored 128 msg_def_items* next; // used internally, previous value ignored 129 }; 130 131 static void add_static_msg_types(msg_def_items *); 132 static sc_msg_def* add_msg_type(const char * msg_type); 133 134protected: 135 136 static void cache_report(const sc_report&); 137 static sc_actions execute(sc_msg_def*, sc_severity); 138 139 static sc_actions suppress_mask; 140 static sc_actions force_mask; 141 static sc_actions sev_actions[SC_MAX_SEVERITY]; 142 static unsigned sev_limit[SC_MAX_SEVERITY]; 143 static unsigned sev_call_count[SC_MAX_SEVERITY]; 144 static sc_report* last_global_report; 145 static sc_actions available_actions; 146 static char* log_file_name; 147 static int verbosity_level; 148 149 static msg_def_items* messages; 150 static msg_def_items msg_terminator; 151 152 static sc_report_handler_proc handler; 153 154 static sc_msg_def* mdlookup(const char* msg_type); 155 156private: // backward compatibility with 2.0+ 157 158 friend class sc_report; 159 static sc_msg_def* mdlookup(int id); 160 161public: 162 163 static void report(sc_severity, 164 int id, 165 const char* add_msg, 166 const char* file, 167 int line); 168 169}; 170 171} // namespace sc_core 172 173// $Log: sc_report_handler.h,v $ 174// Revision 1.5 2011/08/26 20:46:19 acg 175// Andy Goodrich: moved the modification log to the end of the file to 176// eliminate source line number skew when check-ins are done. 177// 178// Revision 1.4 2011/03/23 16:16:49 acg 179// Andy Goodrich: finish message verbosity support. 180// 181// Revision 1.3 2011/02/18 20:38:44 acg 182// Andy Goodrich: Updated Copyright notice. 183// 184// Revision 1.2 2011/02/01 23:02:05 acg 185// Andy Goodrich: IEEE 1666 2011 changes. 186// 187// Revision 1.1.1.1 2006/12/15 20:20:06 acg 188// SystemC 2.3 189// 190// Revision 1.3 2006/01/13 18:53:11 acg 191// Andy Goodrich: Added $Log command so that CVS comments are reproduced in 192// the source. 193// 194 195#endif 196 197// Taf! 198