aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2010-05-19 07:25:06 +0000
committerFilippos Karapetis2010-05-19 07:25:06 +0000
commit852cb16c49aaca1891d25e420ddf1459efa55ae8 (patch)
tree6cd9788c74028aac189cf95addc52159a384992c
parentdb3fc7a89e5a450e82f0b4a5a3b724ad251c8d54 (diff)
downloadscummvm-rg350-852cb16c49aaca1891d25e420ddf1459efa55ae8.tar.gz
scummvm-rg350-852cb16c49aaca1891d25e420ddf1459efa55ae8.tar.bz2
scummvm-rg350-852cb16c49aaca1891d25e420ddf1459efa55ae8.zip
Moved the breakpoint information inside the DebugState struct
svn-id: r49092
-rw-r--r--engines/sci/console.cpp24
-rw-r--r--engines/sci/debug.h23
-rw-r--r--engines/sci/engine/game.cpp3
-rw-r--r--engines/sci/engine/savegame.cpp4
-rw-r--r--engines/sci/engine/state.cpp1
-rw-r--r--engines/sci/engine/state.h4
-rw-r--r--engines/sci/engine/vm.cpp8
-rw-r--r--engines/sci/engine/vm.h22
8 files changed, 40 insertions, 49 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index 7cf3958257..7a83d6a261 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -197,6 +197,8 @@ Console::Console(SciEngine *engine) : GUI::Debugger() {
g_debugState.stopOnEvent = false;
g_debugState.debugging = false;
g_debugState.breakpointWasHit = false;
+ g_debugState._breakpoints.clear(); // No breakpoints defined
+ g_debugState._activeBreakpointTypes = 0;
}
Console::~Console() {
@@ -2380,8 +2382,8 @@ bool Console::cmdBreakpointList(int argc, const char **argv) {
DebugPrintf("Breakpoint list:\n");
- Common::List<Breakpoint>::const_iterator bp = _engine->_gamestate->_breakpoints.begin();
- Common::List<Breakpoint>::const_iterator end = _engine->_gamestate->_breakpoints.end();
+ Common::List<Breakpoint>::const_iterator bp = g_debugState._breakpoints.begin();
+ Common::List<Breakpoint>::const_iterator end = g_debugState._breakpoints.end();
for (; bp != end; ++bp) {
DebugPrintf(" #%i: ", i);
switch (bp->type) {
@@ -2410,8 +2412,8 @@ bool Console::cmdBreakpointDelete(int argc, const char **argv) {
const int idx = atoi(argv[1]);
// Find the breakpoint at index idx.
- Common::List<Breakpoint>::iterator bp = _engine->_gamestate->_breakpoints.begin();
- const Common::List<Breakpoint>::iterator end = _engine->_gamestate->_breakpoints.end();
+ Common::List<Breakpoint>::iterator bp = g_debugState._breakpoints.begin();
+ const Common::List<Breakpoint>::iterator end = g_debugState._breakpoints.end();
for (int i = 0; bp != end && i < idx; ++bp, ++i) {
// do nothing
}
@@ -2422,15 +2424,15 @@ bool Console::cmdBreakpointDelete(int argc, const char **argv) {
}
// Delete it
- _engine->_gamestate->_breakpoints.erase(bp);
+ g_debugState._breakpoints.erase(bp);
// Update EngineState::_activeBreakpointTypes.
int type = 0;
- for (bp = _engine->_gamestate->_breakpoints.begin(); bp != end; ++bp) {
+ for (bp = g_debugState._breakpoints.begin(); bp != end; ++bp) {
type |= bp->type;
}
- _engine->_gamestate->_activeBreakpointTypes = type;
+ g_debugState._activeBreakpointTypes = type;
return true;
}
@@ -2452,8 +2454,8 @@ bool Console::cmdBreakpointExecMethod(int argc, const char **argv) {
bp.type = BREAK_SELECTOR;
bp.name = argv[1];
- _engine->_gamestate->_breakpoints.push_back(bp);
- _engine->_gamestate->_activeBreakpointTypes |= BREAK_SELECTOR;
+ g_debugState._breakpoints.push_back(bp);
+ g_debugState._activeBreakpointTypes |= BREAK_SELECTOR;
return true;
}
@@ -2473,8 +2475,8 @@ bool Console::cmdBreakpointExecFunction(int argc, const char **argv) {
bp.type = BREAK_EXPORT;
bp.address = (atoi(argv[1]) << 16 | atoi(argv[2]));
- _engine->_gamestate->_breakpoints.push_back(bp);
- _engine->_gamestate->_activeBreakpointTypes |= BREAK_EXPORT;
+ g_debugState._breakpoints.push_back(bp);
+ g_debugState._activeBreakpointTypes |= BREAK_EXPORT;
return true;
}
diff --git a/engines/sci/debug.h b/engines/sci/debug.h
index 637eba89e1..8383722956 100644
--- a/engines/sci/debug.h
+++ b/engines/sci/debug.h
@@ -31,6 +31,27 @@
namespace Sci {
+// These types are used both as identifiers and as elements of bitfields
+enum BreakpointType {
+ /**
+ * Break when selector is executed. data contains (char *) selector name
+ * (in the format Object::Method)
+ */
+ BREAK_SELECTOR = 1,
+
+ /**
+ * Break when an exported function is called. data contains
+ * script_no << 16 | export_no.
+ */
+ BREAK_EXPORT = 2
+};
+
+struct Breakpoint {
+ BreakpointType type;
+ uint32 address; ///< Breakpoints on exports
+ Common::String name; ///< Breakpoints on selector names
+};
+
enum DebugSeeking {
kDebugSeekNothing = 0,
kDebugSeekCallk = 1, // Step forward until callk is found
@@ -50,6 +71,8 @@ struct DebugState {
int seekSpecial; // Used for special seeks
int old_pc_offset;
StackPtr old_sp;
+ Common::List<Breakpoint> _breakpoints; //< List of breakpoints
+ int _activeBreakpointTypes; //< Bit mask specifying which types of breakpoints are active
};
// Various global variables used for debugging are declared here
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp
index d46ca65fbe..721ba31f24 100644
--- a/engines/sci/engine/game.cpp
+++ b/engines/sci/engine/game.cpp
@@ -218,9 +218,6 @@ int script_init_engine(EngineState *s) {
s->restarting_flags = SCI_GAME_IS_NOT_RESTARTING;
- s->_breakpoints.clear(); // No breakpoints defined
- s->_activeBreakpointTypes = 0;
-
if (g_sci->_features->detectLofsType() == SCI_VERSION_1_MIDDLE)
s->_segMan->setExportAreWide(true);
else
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index bf251eafcb..ce905ac008 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -996,10 +996,6 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
if (retval->_voc)
retval->_voc->parser_base = make_reg(s->sys_strings_segment, SYS_STRING_PARSER_BASE);
- // Copy breakpoint information from current game instance
- retval->_breakpoints = s->_breakpoints;
- retval->_activeBreakpointTypes = s->_activeBreakpointTypes;
-
retval->successor = NULL;
retval->_gameId = s->_gameId;
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index a8093e0224..bd78639c77 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -94,7 +94,6 @@ EngineState::EngineState(Vocabulary *voc, SegManager *segMan)
script_000 = 0;
- _activeBreakpointTypes = 0;
sys_strings_segment = 0;
sys_strings = 0;
diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h
index 4f36ae00c4..c4b995806f 100644
--- a/engines/sci/engine/state.h
+++ b/engines/sci/engine/state.h
@@ -157,10 +157,6 @@ public:
uint16 currentRoomNumber() const;
void setRoomNumber(uint16 roomNumber);
- /* Debugger data: */
- Common::List<Breakpoint> _breakpoints; /**< List of breakpoints */
- int _activeBreakpointTypes; /**< Bit mask specifying which types of breakpoints are active */
-
/* System strings */
SegmentId sys_strings_segment;
SystemStrings *sys_strings;
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index 856c76f56f..913c4a0c66 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -275,13 +275,13 @@ ExecStack *execute_method(EngineState *s, uint16 script, uint16 pubfunct, StackP
}
// Check if a breakpoint is set on this method
- if (s->_activeBreakpointTypes & BREAK_EXPORT) {
+ if (g_debugState._activeBreakpointTypes & BREAK_EXPORT) {
uint32 bpaddress;
bpaddress = (script << 16 | pubfunct);
Common::List<Breakpoint>::const_iterator bp;
- for (bp = s->_breakpoints.begin(); bp != s->_breakpoints.end(); ++bp) {
+ for (bp = g_debugState._breakpoints.begin(); bp != g_debugState._breakpoints.end(); ++bp) {
if (bp->type == BREAK_EXPORT && bp->address == bpaddress) {
Console *con = g_sci->getSciDebugger();
con->DebugPrintf("Break on script %d, export %d\n", script, pubfunct);
@@ -354,13 +354,13 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
}
// Check if a breakpoint is set on this method
- if (s->_activeBreakpointTypes & BREAK_SELECTOR) {
+ if (g_debugState._activeBreakpointTypes & BREAK_SELECTOR) {
char method_name[256];
sprintf(method_name, "%s::%s", s->_segMan->getObjectName(send_obj), g_sci->getKernel()->getSelectorName(selector).c_str());
Common::List<Breakpoint>::const_iterator bp;
- for (bp = s->_breakpoints.begin(); bp != s->_breakpoints.end(); ++bp) {
+ for (bp = g_debugState._breakpoints.begin(); bp != g_debugState._breakpoints.end(); ++bp) {
int cmplen = bp->name.size();
if (bp->name.lastChar() != ':')
cmplen = 256;
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index 112646ddb6..8e40fed818 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -277,28 +277,6 @@ struct ScriptState {
*/
extern ScriptState scriptState;
-
-// These types are used both as identifiers and as elements of bitfields
-enum BreakpointType {
- /**
- * Break when selector is executed. data contains (char *) selector name
- * (in the format Object::Method)
- */
- BREAK_SELECTOR = 1,
-
- /**
- * Break when an exported function is called. data contains
- * script_no << 16 | export_no.
- */
- BREAK_EXPORT = 2
-};
-
-struct Breakpoint {
- BreakpointType type;
- uint32 address; ///< Breakpoints on exports
- Common::String name; ///< Breakpoints on selector names
-};
-
/**
* Set this to 1 to abort script execution immediately. Aborting will
* leave the debug exec stack intact.