ScummVM API documentation
debugger.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
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 as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef DIRECTOR_DEBUGGER_H
23 #define DIRECTOR_DEBUGGER_H
24 
25 #include "common/array.h"
26 #include "common/file.h"
27 #include "common/str.h"
28 #include "gui/debugger.h"
29 
30 namespace Director {
31 
32 struct Symbol;
33 
34 enum BreakpointType {
35  kBreakpointTypeNull = 0,
36  kBreakpointFunction = 1,
37  kBreakpointMovie = 2,
38  kBreakpointMovieFrame = 3,
39  kBreakpointVariable = 4,
40  kBreakpointEntity = 5,
41  kBreakpointEvent = 6,
42  kBreakpointProperty = 7,
43 };
44 
45 struct Breakpoint {
46  bool enabled = true;
47  BreakpointType type = kBreakpointTypeNull;
48  int id = 0;
49 
50  uint16 scriptId = 0;
51  Common::String funcName;
52  uint funcOffset = 0;
53  Common::String moviePath;
54  uint frameOffset = 0;
55  Common::String varName;
56  LEvent eventId = kEventNone;
57  int entity = 0;
58  int field = 0;
59  bool varRead = false;
60  bool varWrite = false;
61 
62  // Optional Lingo expression; the breakpoint only fires when it is true.
63  Common::String condition;
64 
65  Common::String format() const;
66 };
67 
68 class Cast;
69 
70 class Debugger : public GUI::Debugger {
71 public:
72  Debugger();
73  ~Debugger();
74  void debugLogFile(Common::String logs, bool prompt);
75  void stepHook();
76  void frameHook();
77  void movieHook();
78  void eventHook(LEvent eventId);
79  void pushContextHook();
80  void popContextHook();
81  void builtinHook(const Symbol &funcSym);
82  void propReadHook(const Common::String &varName);
83  void propWriteHook(const Common::String &varName);
84  void varReadHook(const Common::String &varName);
85  void varWriteHook(const Common::String &varName);
86  void entityReadHook(int entity, int field);
87  void entityWriteHook(int entity, int field);
88 
89 private:
90  void disasmAllCast(Cast *cast);
91  void disasmCast(Cast *cast, int scriptId, const Common::String &funcName);
92 
93  bool cmdHelp(int argc, const char **argv);
94 
95  bool cmdVersion(int argc, const char **argv);
96  bool cmdInfo(int argc, const char **argv);
97  bool cmdMovie(int argc, const char **argv);
98  bool cmdFrame(int argc, const char **argv);
99  bool cmdChannels(int argc, const char **argv);
100  bool cmdCast(int argc, const char **argv);
101  bool cmdNextFrame(int argc, const char **argv);
102  bool cmdNextMovie(int argc, const char **argv);
103  bool cmdPrint(int argc, const char **argv);
104  bool cmdRepl(int argc, const char **argv);
105  bool cmdBacktrace(int argc, const char **argv);
106  bool cmdDisasm(int argc, const char **argv);
107  bool cmdStack(int argc, const char **argv);
108  bool cmdScriptFrame(int argc, const char **argv);
109  bool cmdFuncs(int argc, const char **argv);
110  bool cmdActions(int argc, const char **argv);
111  bool cmdVar(int argc, const char **argv);
112  bool cmdMarkers(int argc, const char **argv);
113  bool cmdStep(int argc, const char **argv);
114  bool cmdNext(int argc, const char **argv);
115  bool cmdFinish(int argc, const char **argv);
116  bool cmdWindows(int argc, const char **argv);
117  bool cmdXLibs(int argc, const char **argv);
118 
119  bool cmdBpSet(int argc, const char **argv);
120  bool cmdBpMovie(int argc, const char **argv);
121  bool cmdBpFrame(int argc, const char **argv);
122  bool cmdBpEntity(int argc, const char **argv);
123  bool cmdBpProp(int argc, const char **argv);
124  bool cmdBpVar(int argc, const char **argv);
125  bool cmdBpEvent(int argc, const char **argv);
126  bool cmdBpDel(int argc, const char **argv);
127  bool cmdBpEnable(int argc, const char **argv);
128  bool cmdBpDisable(int argc, const char **argv);
129  bool cmdBpList(int argc, const char **argv);
130 
131  bool cmdDraw(int argc, const char **argv);
132  bool cmdForceRedraw(int argc, const char **argv);
133 
134  void bpUpdateState();
135  void bpTest(bool forceCheck = false);
136 
137  bool lingoCommandProcessor(const char *inputOrig);
138  bool lingoEval(const char *inputOrig);
139  bool evalCondition(const Common::String &cond);
140 
141 
142  Common::DumpFile _out;
143  Common::Path _outName;
144 
145  bool _nextFrame;
146  int _nextFrameCounter;
147  bool _nextMovie;
148  bool _step;
149  int _stepCounter;
150  bool _finish;
151  int _finishCounter;
152  bool _next;
153  int _nextCounter;
154  bool _lingoEval;
155  bool _lingoReplMode;
156 
157  bool _bpCheckFunc = false;
158  bool _bpCheckMoviePath = false;
159  bool _bpNextMovieMatch = false;
160  Common::String _bpMatchFuncName;
161  uint _bpMatchScriptId = 0;
162  Common::String _bpMatchMoviePath;
163  Common::HashMap<uint, void *> _bpMatchFuncOffsets;
164  Common::HashMap<uint, void *> _bpMatchFrameOffsets;
165  bool _bpCheckPropRead = false;
166  bool _bpCheckPropWrite = false;
167  bool _bpCheckVarRead = false;
168  bool _bpCheckVarWrite = false;
169  bool _bpCheckEntityRead = false;
170  bool _bpCheckEntityWrite = false;
171  bool _bpCheckEvent = false;
172 };
173 
174 
175 } // End of namespace Director
176 
177 #endif
Definition: cast.h:88
Definition: lingo.h:82
Definition: str.h:59
Definition: debugger.h:41
Definition: path.h:52
Definition: debugger.h:70
Definition: file.h:145
Definition: archive.h:36
Definition: hashmap.h:85
Definition: debugger.h:45