[Scummvm-cvs-logs] CVS: scummvm/scumm debugger.cpp,1.111,1.112 debugger.h,1.33,1.34 script.cpp,1.143,1.144 scumm.h,1.355,1.356
James Brown
ender at users.sourceforge.net
Fri Jan 9 21:21:02 CET 2004
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/common util.h,1.34,1.35
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm/imuse_digi dimuse.cpp,1.21,1.22 dimuse.h,1.13,1.14 dimuse_sndmgr.cpp,1.19,1.20 dimuse_sndmgr.h,1.13,1.14
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv7204/scumm
Modified Files:
debugger.cpp debugger.h script.cpp scumm.h
Log Message:
Start of debug channel support. TODO: Move this to the common Debugger system?
Index: debugger.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/debugger.cpp,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -d -r1.111 -r1.112
--- debugger.cpp 8 Jan 2004 03:24:41 -0000 1.111
+++ debugger.cpp 10 Jan 2004 05:20:15 -0000 1.112
@@ -39,6 +39,24 @@
namespace Scumm {
+void CDECL debugC(int channel, const char *s, ...) {
+#ifdef __PALM_OS__
+ char buf[256]; // 1024 is too big overflow the stack
+#else
+ char buf[1024];
+#endif
+ va_list va;
+
+ if (!(g_scumm->_debugFlags & channel))
+ return;
+
+ va_start(va, s);
+ vsprintf(buf, s, va);
+ va_end(va);
+
+ debug(buf);
+};
+
ScummDebugger::ScummDebugger(ScummEngine *s)
: Common::Debugger<ScummDebugger>() {
_vm = s;
@@ -80,6 +98,7 @@
DCmd_Register("savegame", &ScummDebugger::Cmd_SaveGame);
DCmd_Register("level", &ScummDebugger::Cmd_DebugLevel);
+ DCmd_Register("debug", &ScummDebugger::Cmd_Debug);
DCmd_Register("help", &ScummDebugger::Cmd_Help);
DCmd_Register("show", &ScummDebugger::Cmd_Show);
@@ -518,6 +537,65 @@
return true;
}
+
+bool ScummDebugger::Cmd_Debug(int argc, const char **argv) {
+ int numChannels = sizeof(debugChannels) / sizeof(dbgChannelDesc);
+
+ bool setFlag = false; // Remove or add debug channel?
+
+ if ((argc == 1) && (_vm->_debugFlags == 0)) {
+ DebugPrintf("No debug flags are enabled\n");
+ DebugPrintf("Available Channels: ");
+ for (int i = 0; i < numChannels; i++) {
+ DebugPrintf("%s, ", debugChannels[i].channel);
+ }
+ DebugPrintf("\n");
+ return true;
+ }
+
+ if ((argc == 1) && (_vm->_debugFlags > 0)) {
+ for (int i = 0; i < numChannels; i++) {
+ if(_vm->_debugFlags & debugChannels[i].flag)
+ DebugPrintf("%s - %s\n", debugChannels[i].channel,
+ debugChannels[i].desc);
+ }
+ return true;
+ }
+
+ // Enable or disable channel?
+ if (argv[1][0] == '+') {
+ setFlag = true;
+ } else if (argv[1][0] == '-') {
+ setFlag = false;
+ } else {
+ DebugPrintf("Syntax: Debug +CHANNEL, or Debug -CHANNEL\n");
+ DebugPrintf("Available Channels: ");
+ for (int i = 0; i < numChannels; i++) {
+ DebugPrintf("%s, ", debugChannels[i].channel);
+ DebugPrintf("\n");
+ }
+ }
+
+ // Identify flag
+ const char *realFlag = argv[1] + 1;
+ for (int i = 0; i < numChannels; i++) {
+ if((scumm_stricmp(debugChannels[i].channel, realFlag)) == 0) {
+ if (setFlag) {
+ _vm->_debugFlags |= debugChannels[i].flag;
+ DebugPrintf("Enable ");
+ } else {
+ _vm->_debugFlags &= ~debugChannels[i].flag;
+ DebugPrintf("Disable ");
+ }
+
+ DebugPrintf("%s\n", debugChannels[i].desc);
+ return true;
+ }
+ }
+
+ DebugPrintf("Unknown flag. Type 'Debug ?' for syntax\n");
+ return true;
+};
bool ScummDebugger::Cmd_DebugLevel(int argc, const char **argv) {
if (argc == 1) {
Index: debugger.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/debugger.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- debugger.h 6 Jan 2004 12:45:30 -0000 1.33
+++ debugger.h 10 Jan 2004 05:20:15 -0000 1.34
@@ -57,6 +57,7 @@
bool Cmd_PrintDraft(int argc, const char **argv);
+ bool Cmd_Debug(int argc, const char **argv);
bool Cmd_DebugLevel(int argc, const char **argv);
bool Cmd_Help(int argc, const char **argv);
Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script.cpp,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- script.cpp 8 Jan 2004 20:37:25 -0000 1.143
+++ script.cpp 10 Jan 2004 05:20:15 -0000 1.144
@@ -50,11 +50,17 @@
scriptPtr = getResourceAddress(rtScript, script);
scriptOffs = _resourceHeaderSize;
scriptType = WIO_GLOBAL;
+
+ debugC(DEBUG_SCRIPTS, "runScript(Global-%d) from %d-%d", script,
+ vm.slot[_currentScript].number, _roomResource);
} else {
scriptOffs = _localScriptList[script - _numGlobalScripts];
if (scriptOffs == 0)
error("Local script %d is not in room %d", script, _roomResource);
scriptType = WIO_LOCAL;
+
+ debugC(DEBUG_SCRIPTS, "runScript(%d) from %d-%d", script,
+ vm.slot[_currentScript].number, _roomResource);
}
slot = getScriptSlot();
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.355
retrieving revision 1.356
diff -u -d -r1.355 -r1.356
--- scumm.h 9 Jan 2004 22:10:31 -0000 1.355
+++ scumm.h 10 Jan 2004 05:20:15 -0000 1.356
@@ -38,6 +38,7 @@
using GUI::Dialog;
class GameDetector;
+
namespace Scumm {
class Actor;
@@ -111,6 +112,32 @@
kObjectClassUntouchable = 32
};
+/* SCUMM Debug Channels */
+void CDECL debugC(int level, const char *s, ...);
+
+struct dbgChannelDesc {
+ const char *channel, *desc;
+ uint32 flag;
+};
+
+enum {
+ DEBUG_SCRIPTS = 1 << 0, // Track script execution (start/stop/pause)
+ DEBUG_OPCODES = 1 << 1, // Track opcode invocations
+ DEBUG_IMUSE = 1 << 2, // Track iMUSE events
+ DEBUG_RESOURCE = 1 << 3, // Track resource loading / allocation
+ DEBUG_VARS = 1 << 4 // Track variable changes
+};
+
+
+// Debug channel lookup table for Debugger console
+static const dbgChannelDesc debugChannels[] = {
+ {"SCRIPTS", "Track script execution", DEBUG_SCRIPTS},
+ {"OPCODES", "Track opcode execution", DEBUG_OPCODES},
+ {"IMUSE", "Track iMUSE events", DEBUG_IMUSE},
+ {"RESOURCE", "Track resource loading/management", DEBUG_RESOURCE},
+ {"VARS", "Track variable changes", DEBUG_VARS}
+};
+
struct MemBlkHeader {
uint32 size;
};
@@ -313,6 +340,7 @@
void clearClickedStatus();
// Misc utility functions
+ uint32 _debugFlags;
const char *getGameName() const { return _gameName.c_str(); }
const char *getGameDataPath() const;
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/common util.h,1.34,1.35
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm/imuse_digi dimuse.cpp,1.21,1.22 dimuse.h,1.13,1.14 dimuse_sndmgr.cpp,1.19,1.20 dimuse_sndmgr.h,1.13,1.14
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list