Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: cReport.h | |
5 | * Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
6 | * 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
7 | * | |
8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License as published by | |
12 | * the Free Software Foundation; version 2 of the License. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 | * | |
23 | * For the avoidance of doubt, and except that if any non-GPL license | |
24 | * choice is available it will apply instead, Sun elects to use only | |
25 | * the General Public License version 2 (GPLv2) at this time for any | |
26 | * software where a choice of GPL license versions is made | |
27 | * available with the language indicating that GPLv2 or any later version | |
28 | * may be used, or where a choice of which version of the GPL is applied is | |
29 | * otherwise unspecified. | |
30 | * | |
31 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
32 | * CA 95054 USA or visit www.sun.com if you need additional information or | |
33 | * have any questions. | |
34 | * | |
35 | * | |
36 | * ========== Copyright Header End ============================================ | |
37 | */ | |
38 | #ifndef _CREPORT_H | |
39 | #define _CREPORT_H | |
40 | ||
41 | #include "report_msg_format.h" | |
42 | #include "report_info.h" | |
43 | ||
44 | // Definitions, constants, etc. | |
45 | #define REPORT_DEFAULT_PRINT_THRESHOLD RPRT_INFO | |
46 | #define REPORT_DEFAULT_PRINT_LEVEL RPRT_INFO | |
47 | #define REPORT_DEFAULT_MAX_ERROR_COUNT 1 | |
48 | #define REPORT_MAX_LINE_LENGTH 1024 | |
49 | #define REPORT_MAX_FIELD_WIDTH 256 | |
50 | #define REPORT_MAX_NUM_VARARGS 12 | |
51 | #define REPORT_CPP_DEFAULT_TIME_STR "" | |
52 | #define REPORT_CPP_DEFAULT_LOCATION_STR "C++" | |
53 | ||
54 | // This value is the number of cycles a sim will run before | |
55 | // is called after the maximum error count has been reached. | |
56 | #define REPORT_DEATH_CYCLE_DELAY 10 | |
57 | ||
58 | class ReportClass { | |
59 | private: | |
60 | // Private data | |
61 | ||
62 | // Class Variables (for all reports) | |
63 | static PrintLevel global_print_threshold; | |
64 | static int max_error_count; | |
65 | static int global_error_count; | |
66 | static int global_warning_count; | |
67 | static int use_short_pathnames; | |
68 | static const char* path_prefix; | |
69 | static int num_remaining_nonfatal_cycles; | |
70 | static int show_simulation_time; | |
71 | ||
72 | // For command line or Vera overriding | |
73 | static int global_print_threshold_locked_by; | |
74 | static int report_type_display_locked_by[R_NUM_REPORT_TYPES]; | |
75 | ||
76 | // Instance variables (just this message type) | |
77 | PrintLevel *localized_print_level_by_type; | |
78 | ErrorLevel *localized_error_level_by_type; | |
79 | int *localized_table_mode_by_type; | |
80 | ||
81 | public: | |
82 | // Public methods | |
83 | virtual void report(ReportType report_type, | |
84 | const char* time_str, const char* location_str, const char* format_str, ...); | |
85 | virtual void report_test_complete(int finish_cycle); | |
86 | virtual int this_will_print(ReportType report_type); | |
87 | ||
88 | // Accessors for class variables | |
89 | static void set_global_print_threshold(PrintLevel new_print_threshold, int locked_by = REPORT_LOCKED_BY_NO_ONE); | |
90 | static PrintLevel get_global_print_threshold(); | |
91 | static void set_max_error_count(int error_count); | |
92 | static int get_max_error_count(); | |
93 | static void inc_global_error_count(); | |
94 | static int get_global_error_count(); | |
95 | static void inc_global_warning_count(); | |
96 | static int get_global_warning_count(); | |
97 | static void set_short_pathnames(int use_short); | |
98 | static int get_short_pathnames(); | |
99 | static void set_path_prefix(const char* prefix); | |
100 | static const char* get_path_prefix(); | |
101 | static void disable_fatal_errors(int num_cycles); | |
102 | static int get_num_remaining_nonfatal_cycles(); | |
103 | static void dec_num_remaining_nonfatal_cycles(); | |
104 | static void set_show_simulation_time(int show_sim_time); | |
105 | static int get_show_simulation_time(); | |
106 | ||
107 | // Set defaults | |
108 | virtual void set_default_print_level(ReportType report_type, PrintLevel new_print_level); | |
109 | virtual void set_default_error_level(ReportType report_type, ErrorLevel new_error_level); | |
110 | virtual void set_default_table_mode(ReportType report_type, int mode); | |
111 | ||
112 | // Accessors for instance variables | |
113 | virtual void set_print_level(ReportType report_type, PrintLevel new_print_level, int silent = 0); | |
114 | virtual PrintLevel get_print_level(ReportType report_type); | |
115 | virtual void set_error_level(ReportType report_type, ErrorLevel new_error_level, int silent = 0); | |
116 | virtual ErrorLevel get_error_level(ReportType report_type); | |
117 | virtual void set_table_mode(ReportType report_type, int table_mode, int silent = 0); | |
118 | virtual int get_table_mode(ReportType report_type); | |
119 | ||
120 | // Public constructor | |
121 | ReportClass() { | |
122 | // Initialize all instance properties (to sane values) | |
123 | localized_print_level_by_type = NULL; | |
124 | localized_error_level_by_type = NULL; | |
125 | localized_table_mode_by_type = NULL; | |
126 | } | |
127 | ||
128 | protected: | |
129 | // Protected methods | |
130 | ||
131 | const char* get_prefix(ReportType type, ErrorLevel error_level) { | |
132 | switch (error_level) { | |
133 | case RERR_MESSAGE: { | |
134 | return report_prefix_by_type[type]; | |
135 | break; | |
136 | } | |
137 | case RERR_WARNING: { | |
138 | return REPORT_KEYWORD_WARNING; | |
139 | break; | |
140 | } | |
141 | case RERR_ERROR: { | |
142 | return REPORT_KEYWORD_FATAL_ERROR; | |
143 | break; | |
144 | } | |
145 | } | |
146 | return ">> INVALID_TYPE <<"; | |
147 | } | |
148 | ||
149 | virtual void handle_error() { | |
150 | // user can extend ReportClass to define this method. | |
151 | } | |
152 | ||
153 | }; | |
154 | ||
155 | ||
156 | #endif //#ifndef _CREPORT_H | |
157 | ||
158 |