mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-21 19:51:49 +00:00
Moved the breakpoint information inside the DebugState struct
svn-id: r49092
This commit is contained in:
parent
db3fc7a89e
commit
852cb16c49
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -94,7 +94,6 @@ EngineState::EngineState(Vocabulary *voc, SegManager *segMan)
|
||||
|
||||
script_000 = 0;
|
||||
|
||||
_activeBreakpointTypes = 0;
|
||||
sys_strings_segment = 0;
|
||||
sys_strings = 0;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user