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
28namespace 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
49enum 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
57struct Breakpoint {
58 BreakpointType _type;
59 uint32 _address;
62 BreakpointAction _action;
63
65 _type(type),
66 _address(0),
67 _regAddress(NULL_REG),
68 _action(BREAK_NONE) { }
69};
70
71enum DebugSeeking {
72 kDebugSeekNothing = 0,
73 kDebugSeekCallk = 1, // Step forward until callk is found
74 kDebugSeekLevelRet = 2, // Step forward until returned from this level
75 kDebugSeekSpecialCallk = 3, // Step forward until a /special/ callk is found
76 kDebugSeekGlobal = 4, // Step forward until one specified global variable is modified
77 kDebugSeekStepOver = 5 // Step forward until we reach same stack-level again
78};
79
80struct DebugState {
81 bool debugging;
82 bool breakpointWasHit;
83 bool stopOnEvent;
84 DebugSeeking seeking; // Stepping forward until some special condition is met
85 int runningStep; // Set to > 0 to allow multiple stepping
86 int seekLevel; // Used for seekers that want to check their exec stack depth
87 int seekSpecial; // Used for special seeks
88 int old_pc_offset;
89 StackPtr old_sp;
90 Common::List<Breakpoint> _breakpoints; //< List of breakpoints
91 int _activeBreakpointTypes; //< Bit mask specifying which types of breakpoints are active
92
93 void updateActiveBreakpointTypes();
94};
95
96// Various global variables used for debugging are declared here
97extern int g_debug_sleeptime_factor;
98extern int g_debug_simulated_key;
99extern bool g_debug_track_mouse_clicks;
100
101} // End of namespace Sci
102
103#endif
Definition: list.h:44
Definition: str.h:59
Definition: console.h:28
BreakpointType
Definition: debug.h:31
@ BREAK_SELECTOREXEC
Definition: debug.h:36
@ BREAK_EXPORT
Definition: debug.h:44
Definition: debug.h:57
reg_t _regAddress
Breakpoints on addresses.
Definition: debug.h:60
uint32 _address
Breakpoints on exports.
Definition: debug.h:59
Common::String _name
Breakpoints on selector names.
Definition: debug.h:61
Definition: debug.h:80
Definition: vm_types.h:39