[Scummvm-cvs-logs] SF.net SVN: scummvm:[53267] scummvm/trunk/engines/sword25

sev at users.sourceforge.net sev at users.sourceforge.net
Wed Oct 13 01:09:53 CEST 2010


Revision: 53267
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53267&view=rev
Author:   sev
Date:     2010-10-12 23:09:53 +0000 (Tue, 12 Oct 2010)

Log Message:
-----------
SWORD25: Implemented script tracing

To turn on traces turn on debugchannel 'script' and then use
debug level as a bitmask:
  1 - show function calls
  2 - show function exits
  3 - show every line

Modified Paths:
--------------
    scummvm/trunk/engines/sword25/script/luascript.cpp
    scummvm/trunk/engines/sword25/sword25.cpp

Modified: scummvm/trunk/engines/sword25/script/luascript.cpp
===================================================================
--- scummvm/trunk/engines/sword25/script/luascript.cpp	2010-10-12 23:09:32 UTC (rev 53266)
+++ scummvm/trunk/engines/sword25/script/luascript.cpp	2010-10-12 23:09:53 UTC (rev 53267)
@@ -39,6 +39,9 @@
 // -----------------------------------------------------------------------------
 
 #include "common/array.h"
+#include "common/debug-channels.h"
+
+#include "sword25/sword25.h"
 #include "sword25/package/packagemanager.h"
 #include "sword25/script/luascript.h"
 #include "sword25/script/luabindhelper.h"
@@ -92,7 +95,14 @@
 	BS_LOG_ERRORLN("Lua panic. Error message: %s", lua_isnil(L, -1) ? "" : lua_tostring(L, -1));
 	return 0;
 }
+
+void debugHook(lua_State *L, lua_Debug *ar) {
+	if (!lua_getinfo(L, "Sn", ar))
+		return;
+
+	debug("LUA: %s %s: %s %d", ar->namewhat, ar->name, ar->short_src, ar->currentline);
 }
+}
 
 // -----------------------------------------------------------------------------
 
@@ -139,6 +149,20 @@
 	luaopen_pluto(m_State);
 	lua_pop(m_State, 1);
 
+	// Initialize debugging callback
+	if (DebugMan.isDebugChannelEnabled(kDebugScript)) {
+		int mask = 0;
+		if (gDebugLevel == 1)
+			mask |= LUA_MASKCALL;
+		if (gDebugLevel == 2)
+			mask |= LUA_MASKRET;
+		if (gDebugLevel == 4)
+			mask |= LUA_MASKLINE;
+
+		if (mask != 0)
+			lua_sethook(m_State, debugHook, mask, 0);
+	}
+
 	BS_LOGLN("Lua initialized.");
 
 	return true;

Modified: scummvm/trunk/engines/sword25/sword25.cpp
===================================================================
--- scummvm/trunk/engines/sword25/sword25.cpp	2010-10-12 23:09:32 UTC (rev 53266)
+++ scummvm/trunk/engines/sword25/sword25.cpp	2010-10-12 23:09:53 UTC (rev 53267)
@@ -33,6 +33,7 @@
  */
 
 #include "common/config-manager.h"
+#include "common/debug-channels.h"
 #include "engines/util.h"
 
 #include "sword25/sword25.h"
@@ -55,6 +56,8 @@
 Sword25Engine::Sword25Engine(OSystem *syst, const ADGameDescription *gameDesc):
 	Engine(syst),
 	_gameDescription(gameDesc) {
+
+	DebugMan.addDebugChannel(kDebugScript, "Script", "Script debug level");
 }
 
 Sword25Engine::~Sword25Engine() {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list