This patch removes the WARN_* and ERROR_* from src/mem/ruby/common/Debug.hh file...
[gem5.git] / src / mem / ruby / common / Debug.hh
1 /*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef __MEM_RUBY_COMMON_DEBUG_HH__
30 #define __MEM_RUBY_COMMON_DEBUG_HH__
31
32 #include <unistd.h>
33
34 #include <fstream>
35 #include <iostream>
36 #include <string>
37 #include <vector>
38
39 #include "mem/ruby/common/Global.hh"
40 #include "sim/sim_object.hh"
41
42 #include "params/RubyDebug.hh"
43
44 extern std::ostream * debug_cout_ptr;
45
46 // component enumeration
47 enum DebugComponents
48 {
49 SYSTEM_COMP,
50 NODE_COMP,
51 QUEUE_COMP,
52 EVENTQUEUE_COMP,
53 NETWORK_COMP,
54 SEQUENCER_COMP,
55 TESTER_COMP,
56 GENERATED_COMP,
57 SLICC_COMP,
58 NETWORKQUEUE_COMP,
59 TIME_COMP,
60 NETWORK_INTERNALS_COMP,
61 STOREBUFFER_COMP,
62 CACHE_COMP,
63 PREDICTOR_COMP,
64 MEMORY_COMP,
65 NUMBER_OF_COMPS
66 };
67
68 enum PriorityLevel {HighPrio, MedPrio, LowPrio};
69 enum VerbosityLevel {No_Verb, Low_Verb, Med_Verb, High_Verb};
70
71 class Debug : public SimObject
72 {
73 public:
74 typedef RubyDebugParams Params;
75 Debug(const Params *p);
76 ~Debug();
77
78 static bool getProtocolTrace() { return m_protocol_trace; }
79 bool validDebug(int module, PriorityLevel priority);
80 void printVerbosity(std::ostream& out) const;
81 void setVerbosity(VerbosityLevel vb);
82 bool setVerbosityString(const char *);
83 VerbosityLevel getVerbosity() const { return m_verbosityLevel; }
84 void setFilter(int);
85 static bool checkFilter( char);
86 static bool checkFilterString(const char *);
87 bool setFilterString(const char *);
88 void setDebugTime(Time);
89 Time getDebugTime() const { return m_starting_cycle; }
90 bool addFilter(char);
91 void clearFilter();
92 void allFilter();
93 void print(std::ostream& out) const;
94 /* old school debugging "vararg": sends messages to screen and log */
95 void debugMsg(const char *fmt, ...);
96
97 void setDebugOutputFile (const char * filename);
98 void closeDebugOutputFile ();
99 static void usageInstructions(void);
100
101 private:
102 // Private copy constructor and assignment operator
103 Debug(const Debug& obj);
104 Debug& operator=(const Debug& obj);
105
106 static bool m_protocol_trace;
107 VerbosityLevel m_verbosityLevel;
108 int m_filter;
109 Time m_starting_cycle;
110
111 std::fstream m_fout;
112 };
113
114 inline std::ostream&
115 operator<<(std::ostream& out, const Debug& obj)
116 {
117 obj.print(out);
118 out << std::flush;
119 return out;
120 }
121
122 #undef assert
123 #define assert(EXPR) ASSERT(EXPR)
124 #undef ASSERT
125
126 #ifndef NDEBUG
127
128 #define ASSERT(EXPR) do { \
129 using namespace std; \
130 if (!(EXPR)) { \
131 cerr << "failed assertion '" \
132 << #EXPR << "' at fn " \
133 << __PRETTY_FUNCTION__ << " in " \
134 << __FILE__ << ":" \
135 << __LINE__ << endl << flush; \
136 (*debug_cout_ptr) << "failed assertion '" \
137 << #EXPR << "' at fn " \
138 << __PRETTY_FUNCTION__ << " in " \
139 << __FILE__ << ":" \
140 << __LINE__ << endl << flush; \
141 if (isatty(STDIN_FILENO)) { \
142 cerr << "At this point you might want to attach a debug to " \
143 << "the running and get to the" << endl \
144 << "crash site; otherwise press enter to continue" \
145 << endl \
146 << "PID: " << getpid() \
147 << endl << flush; \
148 char c; \
149 cin.get(c); \
150 } \
151 abort(); \
152 } \
153 } while (0)
154
155 #else
156
157 #define ASSERT(EXPR) do {} while (0)
158
159 #endif // NDEBUG
160
161 #endif // __MEM_RUBY_COMMON_DEBUG_HH__
162