1 |
dpavlin |
1 |
/* |
2 |
|
|
* HT Editor |
3 |
|
|
* debugger.h |
4 |
|
|
* |
5 |
|
|
* Copyright (C) 2003 Stefan Weyergraf |
6 |
|
|
* |
7 |
|
|
* This program is free software; you can redistribute it and/or modify |
8 |
|
|
* it under the terms of the GNU General Public License version 2 as |
9 |
|
|
* published by the Free Software Foundation. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#ifndef __DEBUGGER_H__ |
22 |
|
|
#define __DEBUGGER_H__ |
23 |
|
|
|
24 |
|
|
#define HAVE_DEBUGGER |
25 |
|
|
|
26 |
|
|
#include "tools/data.h" |
27 |
|
|
#include "tools/str.h" |
28 |
|
|
#include "parsehelper.h" |
29 |
|
|
#include "cpu/cpu.h" |
30 |
|
|
|
31 |
|
|
#ifdef HAVE_DEBUGGER |
32 |
|
|
#include "cpu/cpu_generic/ppc_cpu.h" |
33 |
|
|
#endif |
34 |
|
|
|
35 |
|
|
enum EvalType { |
36 |
|
|
ET_INTEGER, |
37 |
|
|
ET_FLOAT, |
38 |
|
|
ET_STRING, |
39 |
|
|
ET_VARARGS |
40 |
|
|
}; |
41 |
|
|
|
42 |
|
|
/** |
43 |
|
|
* An abstract function |
44 |
|
|
*/ |
45 |
|
|
class Function: public Object { |
46 |
|
|
public: |
47 |
|
|
/* new */ |
48 |
|
|
virtual EvalType getReturnType() const = 0; |
49 |
|
|
virtual SInt64 * evalInteger() const; |
50 |
|
|
virtual Float * evalFloat() const; |
51 |
|
|
virtual String * evalString() const; |
52 |
|
|
virtual uint getArgCount() const; |
53 |
|
|
virtual Function * getArg(uint i) const; |
54 |
|
|
virtual void setArg(uint i, Function *f); |
55 |
|
|
}; |
56 |
|
|
|
57 |
|
|
/** |
58 |
|
|
* A constant (signed) integer function |
59 |
|
|
*/ |
60 |
|
|
class SInt64Function: public Function { |
61 |
|
|
protected: |
62 |
|
|
sint64 value; |
63 |
|
|
public: |
64 |
|
|
SInt64Function(sint64 v); |
65 |
|
|
/* extends Function */ |
66 |
|
|
virtual EvalType getReturnType() const; |
67 |
|
|
virtual SInt64 * evalInteger() const; |
68 |
|
|
}; |
69 |
|
|
|
70 |
|
|
/** |
71 |
|
|
* A GPR |
72 |
|
|
*/ |
73 |
|
|
class GPRFunction: public Function { |
74 |
|
|
protected: |
75 |
|
|
int mNumber; |
76 |
|
|
public: |
77 |
|
|
GPRFunction(int number); |
78 |
|
|
/* extends Function */ |
79 |
|
|
virtual EvalType getReturnType() const; |
80 |
|
|
virtual SInt64 * evalInteger() const; |
81 |
|
|
}; |
82 |
|
|
|
83 |
|
|
class FPRFunction: public Function { |
84 |
|
|
protected: |
85 |
|
|
int mNumber; |
86 |
|
|
public: |
87 |
|
|
FPRFunction(int number); |
88 |
|
|
/* extends Function */ |
89 |
|
|
virtual EvalType getReturnType() const; |
90 |
|
|
virtual Float * evalFloat() const; |
91 |
|
|
}; |
92 |
|
|
|
93 |
|
|
class UInt32PFunction: public Function { |
94 |
|
|
protected: |
95 |
|
|
uint32 *mValue; |
96 |
|
|
public: |
97 |
|
|
UInt32PFunction(uint32 *aValue); |
98 |
|
|
/* extends Function */ |
99 |
|
|
virtual EvalType getReturnType() const; |
100 |
|
|
virtual SInt64 * evalInteger() const; |
101 |
|
|
}; |
102 |
|
|
/** |
103 |
|
|
* A constant float function |
104 |
|
|
*/ |
105 |
|
|
class FloatFunction: public Function { |
106 |
|
|
protected: |
107 |
|
|
double value; |
108 |
|
|
public: |
109 |
|
|
FloatFunction(double v); |
110 |
|
|
/* extends Function */ |
111 |
|
|
virtual EvalType getReturnType() const; |
112 |
|
|
virtual Float * evalFloat() const; |
113 |
|
|
}; |
114 |
|
|
|
115 |
|
|
/** |
116 |
|
|
* A constant string function |
117 |
|
|
*/ |
118 |
|
|
class StringFunction: public Function { |
119 |
|
|
protected: |
120 |
|
|
String value; |
121 |
|
|
public: |
122 |
|
|
StringFunction(const byte *str, int len); |
123 |
|
|
/* extends Function */ |
124 |
|
|
virtual EvalType getReturnType() const; |
125 |
|
|
virtual String * evalString() const; |
126 |
|
|
}; |
127 |
|
|
|
128 |
|
|
/** |
129 |
|
|
* A parametrized function (implementation helper) |
130 |
|
|
*/ |
131 |
|
|
class PFunction: public Function { |
132 |
|
|
protected: |
133 |
|
|
Array mArgs; |
134 |
|
|
public: |
135 |
|
|
PFunction(); |
136 |
|
|
/* extends Function */ |
137 |
|
|
virtual uint getArgCount() const; |
138 |
|
|
virtual Function * getArg(uint i) const; |
139 |
|
|
virtual void setArg(uint i, Function *f); |
140 |
|
|
}; |
141 |
|
|
|
142 |
|
|
/* |
143 |
|
|
* |
144 |
|
|
*/ |
145 |
|
|
class Watch: public Object { |
146 |
|
|
String *mName; |
147 |
|
|
Function *f; |
148 |
|
|
public: |
149 |
|
|
Watch(String *aName, Function *f); |
150 |
|
|
virtual ~Watch(); |
151 |
|
|
virtual int toString(char *buf, int buflen) const; |
152 |
|
|
|
153 |
|
|
}; |
154 |
|
|
|
155 |
|
|
/* |
156 |
|
|
* A debugger |
157 |
|
|
*/ |
158 |
|
|
class Debugger { |
159 |
|
|
protected: |
160 |
|
|
Container *mWatches; |
161 |
|
|
#ifdef HAVE_DEBUGGER |
162 |
|
|
PPC_CPU_State savedCPUState; |
163 |
|
|
#endif |
164 |
|
|
bool mForceSinglestep; |
165 |
|
|
|
166 |
|
|
Function *eval_scalarToFunction(eval_scalar &s); |
167 |
|
|
virtual Function *matchFunction(const String &name, const Enumerator ¶ms); |
168 |
|
|
public: |
169 |
|
|
bool mAlwaysShowRegs; |
170 |
|
|
bool mUseColors; |
171 |
|
|
|
172 |
|
|
Debugger(); |
173 |
|
|
virtual ~Debugger(); |
174 |
|
|
bool parse(const String &str); |
175 |
|
|
void enter(); |
176 |
|
|
void dump(); |
177 |
|
|
}; |
178 |
|
|
|
179 |
|
|
void debugger_init_config(); |
180 |
|
|
|
181 |
|
|
#endif /* __EVAL_H__ */ |