debug.isa (7626:bdd926760470) debug.isa (7965:f4c89fe1246b)
1// Copyright (c) 2008 The Hewlett-Packard Development Company
2// All rights reserved.
3//
4// The license below extends only to copyright in the software and shall
5// not be construed as granting a license to any other intellectual
6// property including but not limited to intellectual property relating
7// to a hardware implementation of the functionality of the software
8// licensed hereunder. You may use the software subject to the license

--- 31 unchanged lines hidden (view full) ---

40// Debug Microops
41//
42//////////////////////////////////////////////////////////////////////////
43
44output header {{
45 class MicroDebugBase : public X86ISA::X86MicroopBase
46 {
47 protected:
1// Copyright (c) 2008 The Hewlett-Packard Development Company
2// All rights reserved.
3//
4// The license below extends only to copyright in the software and shall
5// not be construed as granting a license to any other intellectual
6// property including but not limited to intellectual property relating
7// to a hardware implementation of the functionality of the software
8// licensed hereunder. You may use the software subject to the license

--- 31 unchanged lines hidden (view full) ---

40// Debug Microops
41//
42//////////////////////////////////////////////////////////////////////////
43
44output header {{
45 class MicroDebugBase : public X86ISA::X86MicroopBase
46 {
47 protected:
48 typedef GenericISA::M5DebugFault::DebugFunc DebugFunc;
49 DebugFunc func;
48 std::string message;
49 uint8_t cc;
50
51 public:
50 std::string message;
51 uint8_t cc;
52
53 public:
52 MicroDebugBase(ExtMachInst _machInst, const char * mnem,
54 MicroDebugBase(ExtMachInst machInst, const char * mnem,
53 const char * instMnem, uint64_t setFlags,
55 const char * instMnem, uint64_t setFlags,
54 std::string _message, uint8_t _cc);
56 DebugFunc _func, std::string _message, uint8_t _cc) :
57 X86MicroopBase(machInst, mnem, instMnem, setFlags, No_OpClass),
58 func(_func), message(_message), cc(_cc)
59 {}
55
60
56 std::string generateDisassembly(Addr pc,
57 const SymbolTable *symtab) const;
61 std::string
62 generateDisassembly(Addr pc, const SymbolTable *symtab) const
63 {
64 std::stringstream response;
65
66 printMnemonic(response, instMnem, mnemonic);
67 response << "\"" << message << "\"";
68
69 return response.str();
70 }
58 };
59}};
60
61def template MicroDebugDeclare {{
62 class %(class_name)s : public %(base_class)s
63 {
64 public:
65 %(class_name)s(ExtMachInst _machInst, const char * instMnem,
66 uint64_t setFlags, std::string _message, uint8_t _cc);
67
68 %(BasicExecDeclare)s
69 };
70}};
71
72def template MicroDebugExecute {{
71 };
72}};
73
74def template MicroDebugDeclare {{
75 class %(class_name)s : public %(base_class)s
76 {
77 public:
78 %(class_name)s(ExtMachInst _machInst, const char * instMnem,
79 uint64_t setFlags, std::string _message, uint8_t _cc);
80
81 %(BasicExecDeclare)s
82 };
83}};
84
85def template MicroDebugExecute {{
73 Fault %(class_name)s::execute(%(CPU_exec_context)s *xc,
86 Fault
87 %(class_name)s::execute(%(CPU_exec_context)s *xc,
74 Trace::InstRecord *traceData) const
75 {
76 %(op_decl)s
77 %(op_rd)s
78 if (%(cond_test)s) {
88 Trace::InstRecord *traceData) const
89 {
90 %(op_decl)s
91 %(op_rd)s
92 if (%(cond_test)s) {
79 %(func)s("%s\n", message);
93 return new GenericISA::M5DebugFault(func, message);
94 } else {
95 return NoFault;
80 }
96 }
81 return NoFault;
82 }
83}};
84
97 }
98}};
99
85output decoder {{
86 inline MicroDebugBase::MicroDebugBase(
87 ExtMachInst machInst, const char * mnem, const char * instMnem,
88 uint64_t setFlags, std::string _message, uint8_t _cc) :
89 X86MicroopBase(machInst, mnem, instMnem,
90 setFlags, No_OpClass),
91 message(_message), cc(_cc)
92 {
93 }
94}};
95
96def template MicroDebugConstructor {{
97 inline %(class_name)s::%(class_name)s(
98 ExtMachInst machInst, const char * instMnem, uint64_t setFlags,
99 std::string _message, uint8_t _cc) :
100 %(base_class)s(machInst, "%(func)s", instMnem,
100def template MicroDebugConstructor {{
101 inline %(class_name)s::%(class_name)s(
102 ExtMachInst machInst, const char * instMnem, uint64_t setFlags,
103 std::string _message, uint8_t _cc) :
104 %(base_class)s(machInst, "%(func)s", instMnem,
101 setFlags, _message, _cc)
105 setFlags, %(func_num)s, _message, _cc)
102 {
103 %(constructor)s;
104 }
105}};
106
106 {
107 %(constructor)s;
108 }
109}};
110
107output decoder {{
108 std::string MicroDebugBase::generateDisassembly(Addr pc,
109 const SymbolTable *symtab) const
110 {
111 std::stringstream response;
112
113 printMnemonic(response, instMnem, mnemonic);
114 response << "\"" << message << "\"";
115
116 return response.str();
117 }
118}};
119
120let {{
121 class MicroDebug(X86Microop):
122 def __init__(self, message, flags=None):
123 self.message = message
124 if flags:
125 if not isinstance(flags, (list, tuple)):
126 raise Exception, "flags must be a list or tuple of flags"
127 self.cond = " | ".join(flags)

--- 9 unchanged lines hidden (view full) ---

137 "message" : self.message,
138 "cc" : self.cond}
139 return allocator
140
141 exec_output = ""
142 header_output = ""
143 decoder_output = ""
144
111let {{
112 class MicroDebug(X86Microop):
113 def __init__(self, message, flags=None):
114 self.message = message
115 if flags:
116 if not isinstance(flags, (list, tuple)):
117 raise Exception, "flags must be a list or tuple of flags"
118 self.cond = " | ".join(flags)

--- 9 unchanged lines hidden (view full) ---

128 "message" : self.message,
129 "cc" : self.cond}
130 return allocator
131
132 exec_output = ""
133 header_output = ""
134 decoder_output = ""
135
145 def buildDebugMicro(func):
136 def buildDebugMicro(func, func_num):
146 global exec_output, header_output, decoder_output
147
148 iop = InstObjParams(func, "Micro%sFlags" % func.capitalize(),
149 "MicroDebugBase",
150 {"code": "",
151 "func": func,
137 global exec_output, header_output, decoder_output
138
139 iop = InstObjParams(func, "Micro%sFlags" % func.capitalize(),
140 "MicroDebugBase",
141 {"code": "",
142 "func": func,
143 "func_num": "GenericISA::M5DebugFault::%s" % func_num,
152 "cond_test": "checkCondition(ccFlagBits, cc)"})
153 exec_output += MicroDebugExecute.subst(iop)
154 header_output += MicroDebugDeclare.subst(iop)
155 decoder_output += MicroDebugConstructor.subst(iop)
156
157 iop = InstObjParams(func, "Micro%s" % func.capitalize(),
158 "MicroDebugBase",
159 {"code": "",
160 "func": func,
144 "cond_test": "checkCondition(ccFlagBits, cc)"})
145 exec_output += MicroDebugExecute.subst(iop)
146 header_output += MicroDebugDeclare.subst(iop)
147 decoder_output += MicroDebugConstructor.subst(iop)
148
149 iop = InstObjParams(func, "Micro%s" % func.capitalize(),
150 "MicroDebugBase",
151 {"code": "",
152 "func": func,
153 "func_num": "GenericISA::M5DebugFault::%s" % func_num,
161 "cond_test": "true"})
162 exec_output += MicroDebugExecute.subst(iop)
163 header_output += MicroDebugDeclare.subst(iop)
164 decoder_output += MicroDebugConstructor.subst(iop)
165
166 class MicroDebugChild(MicroDebug):
167 className = "Micro%s" % func.capitalize()
168
169 global microopClasses
170 microopClasses[func] = MicroDebugChild
171
154 "cond_test": "true"})
155 exec_output += MicroDebugExecute.subst(iop)
156 header_output += MicroDebugDeclare.subst(iop)
157 decoder_output += MicroDebugConstructor.subst(iop)
158
159 class MicroDebugChild(MicroDebug):
160 className = "Micro%s" % func.capitalize()
161
162 global microopClasses
163 microopClasses[func] = MicroDebugChild
164
172 buildDebugMicro("panic")
173 buildDebugMicro("fatal")
174 buildDebugMicro("warn")
175 buildDebugMicro("warn_once")
165 buildDebugMicro("panic", "PanicFunc")
166 buildDebugMicro("fatal", "FatalFunc")
167 buildDebugMicro("warn", "WarnFunc")
168 buildDebugMicro("warn_once", "WarnOnceFunc")
176}};
169}};