ScummVM API documentation
debug.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 SCI_DEBUG_H
23 #define SCI_DEBUG_H
24 
25 #include "common/list.h"
26 #include "sci/engine/vm_types.h" // for StackPtr
27 
28 namespace Sci {
29 
30 // These types are used both as identifiers and as elements of bitfields
36  BREAK_SELECTOREXEC = 1 << 0, // break when a function selector is executed
37  BREAK_SELECTORREAD = 1 << 1, // break when a variable selector is read
38  BREAK_SELECTORWRITE = 1 << 2, // break when a variable selector is written
39 
44  BREAK_EXPORT = 1 << 3,
45  BREAK_ADDRESS = 1 << 4, // break when pc is at _regAddress
46  BREAK_KERNEL = 1 << 5 // break on named kernel call
47 };
48 
49 enum BreakpointAction {
50  BREAK_NONE, // ignore breakpoint
51  BREAK_BREAK, // break into debugger when breakpoint is triggered
52  BREAK_LOG, // log the breakpoint, and don't break into debugger
53  BREAK_BACKTRACE, // show a backtrace, and don't break into debugger
54  BREAK_INSPECT // show object, and don't break into debugger
55 };
56 
57 struct Breakpoint {
58  BreakpointType _type;
59  uint32 _address;
62  BreakpointAction _action;
63 };
64 
65 enum DebugSeeking {
66  kDebugSeekNothing = 0,
67  kDebugSeekCallk = 1, // Step forward until callk is found
68  kDebugSeekLevelRet = 2, // Step forward until returned from this level
69  kDebugSeekSpecialCallk = 3, // Step forward until a /special/ callk is found
70  kDebugSeekGlobal = 4, // Step forward until one specified global variable is modified
71  kDebugSeekStepOver = 5 // Step forward until we reach same stack-level again
72 };
73 
74 struct DebugState {
75  bool debugging;
76  bool breakpointWasHit;
77  bool stopOnEvent;
78  DebugSeeking seeking; // Stepping forward until some special condition is met
79  int runningStep; // Set to > 0 to allow multiple stepping
80  int seekLevel; // Used for seekers that want to check their exec stack depth
81  int seekSpecial; // Used for special seeks
82  int old_pc_offset;
83  StackPtr old_sp;
84  Common::List<Breakpoint> _breakpoints; //< List of breakpoints
85  int _activeBreakpointTypes; //< Bit mask specifying which types of breakpoints are active
86 
87  void updateActiveBreakpointTypes();
88 };
89 
90 // Various global variables used for debugging are declared here
91 extern int g_debug_sleeptime_factor;
92 extern int g_debug_simulated_key;
93 extern bool g_debug_track_mouse_clicks;
94 
95 } // End of namespace Sci
96 
97 #endif
Definition: debug.h:44
BreakpointType
Definition: debug.h:31
Definition: str.h:59
Definition: debug.h:74
reg_t _regAddress
Breakpoints on addresses.
Definition: debug.h:60
Definition: list.h:44
Common::String _name
Breakpoints on selector names.
Definition: debug.h:61
Definition: console.h:28
uint32 _address
Breakpoints on exports.
Definition: debug.h:59
Definition: debug.h:36
Definition: vm_types.h:39
Definition: debug.h:57