[Scummvm-cvs-logs] SF.net SVN: scummvm:[41302] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sat Jun 6 22:29:37 CEST 2009


Revision: 41302
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41302&view=rev
Author:   thebluegr
Date:     2009-06-06 20:29:37 +0000 (Sat, 06 Jun 2009)

Log Message:
-----------
Moved some more debug commands to ScummVM's coneole

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/console.h
    scummvm/trunk/engines/sci/engine/scriptdebug.cpp

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-06-06 20:22:16 UTC (rev 41301)
+++ scummvm/trunk/engines/sci/console.cpp	2009-06-06 20:29:37 UTC (rev 41302)
@@ -154,9 +154,13 @@
 	DCmd_Register("dissect_script",		WRAP_METHOD(Console, cmdDissectScript));
 	DCmd_Register("set_acc",			WRAP_METHOD(Console, cmdSetAccumulator));
 	DCmd_Register("backtrace",			WRAP_METHOD(Console, cmdBacktrace));
+	DCmd_Register("step",				WRAP_METHOD(Console, cmdStep));
 	DCmd_Register("step_event",			WRAP_METHOD(Console, cmdStepEvent));
 	DCmd_Register("step_ret",			WRAP_METHOD(Console, cmdStepRet));
 	DCmd_Register("step_global",		WRAP_METHOD(Console, cmdStepGlobal));
+	DCmd_Register("step_callk",			WRAP_METHOD(Console, cmdStepCallk));
+	DCmd_Register("disasm",				WRAP_METHOD(Console, cmdDissassemble));
+	DCmd_Register("disasm_addr",		WRAP_METHOD(Console, cmdDissassembleAddress));
 	// Breakpoints
 	DCmd_Register("bp_list",			WRAP_METHOD(Console, cmdBreakpointList));
 	DCmd_Register("bp_del",				WRAP_METHOD(Console, cmdBreakpointDelete));
@@ -307,9 +311,13 @@
 	DebugPrintf(" dissect_script - Examines a script\n");
 	DebugPrintf(" set_acc - Sets the accumulator\n");
 	DebugPrintf(" backtrace - Dumps the send/self/super/call/calle/callb stack\n");
+	DebugPrintf(" step - Executes one operation (no parameters) or several operations (specified as a parameter) \n");
 	DebugPrintf(" step_event - Steps forward until a SCI event is received.\n");
 	DebugPrintf(" step_ret - Steps forward until ret is called on the current execution stack level.\n");
 	DebugPrintf(" step_global - Steps until the global variable with the specified index is modified.\n");
+	DebugPrintf(" step_callk - Steps forward until it hits the next callk operation, or a specific callk (specified as a parameter)\n");
+	DebugPrintf(" disasm - Disassembles a method by name\n");
+	DebugPrintf(" disasm_addr - Disassembles one or more commands\n");
 	DebugPrintf("\n");
 	DebugPrintf("Breakpoints:\n");
 	DebugPrintf(" bp_list - Lists the current breakpoints\n");
@@ -2066,6 +2074,14 @@
 	return true;
 }
 
+bool Console::cmdStep(int argc, const char **argv) {
+	g_debugstate_valid = 0;
+	if (argc == 2 && atoi(argv[1]) > 0)
+		g_debug_step_running = atoi(argv[1]) - 1;
+
+	return true;
+}
+
 bool Console::cmdStepEvent(int argc, const char **argv) {
 	g_stop_on_event = 1;
 	g_debugstate_valid = 0;
@@ -2095,6 +2111,135 @@
 	return true;
 }
 
+bool Console::cmdStepCallk(int argc, const char **argv) {
+	int callk_index;
+	char *endptr;
+
+	if (argc == 2) {
+		/* Try to convert the parameter to a number. If the conversion stops
+		   before end of string, assume that the parameter is a function name
+		   and scan the function table to find out the index. */
+		callk_index = strtoul(argv[1], &endptr, 0);
+		if (*endptr != '\0') {
+			callk_index = -1;
+			for (uint i = 0; i < g_EngineState->_kernel->getKernelNamesSize(); i++)
+				if (argv[1] == g_EngineState->_kernel->getKernelName(i)) {
+					callk_index = i;
+					break;
+				}
+
+			if (callk_index == -1) {
+				DebugPrintf("Unknown kernel function '%s'\n", argv[1]);
+				return true;
+			}
+		}
+
+		g_debug_seeking = kDebugSeekSpecialCallk;
+		g_debug_seek_special = callk_index;
+		g_debugstate_valid = 0;
+	} else {
+		g_debug_seeking = kDebugSeekCallk;
+		g_debugstate_valid = 0;
+	}
+
+	return true;
+}
+
+bool Console::cmdDissassemble(int argc, const char **argv) {
+	if (argc != 3) {
+		DebugPrintf("Disassembles a method by name.\n");
+		DebugPrintf("Usage: %s <object> <method>\n", argv[0]);
+		return true;
+	}
+
+	reg_t objAddr = NULL_REG;
+
+	if (parse_reg_t(g_EngineState, argv[1], &objAddr)) {
+		DebugPrintf("Invalid address passed.\n");
+		DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
+		return true;
+	}
+
+	Object *obj = obj_get(g_EngineState, objAddr);
+	int selector_id = g_EngineState->_kernel->findSelector(argv[2]);
+	reg_t addr;
+
+	if (!obj) {
+		DebugPrintf("Not an object.");
+		return true;
+	}
+
+	if (selector_id < 0) {
+		DebugPrintf("Not a valid selector name.");
+		return true;
+	}
+
+	if (lookup_selector(g_EngineState, objAddr, selector_id, NULL, &addr) != kSelectorMethod) {
+		DebugPrintf("Not a method.");
+		return true;
+	}
+
+	do {
+		// TODO
+		//addr = disassemble(g_EngineState, addr, 0, 0);
+	} while (addr.offset > 0);
+
+	return true;
+}
+
+bool Console::cmdDissassembleAddress(int argc, const char **argv) {
+	if (argc < 2) {
+		DebugPrintf("Disassembles one or more commands.\n");
+		DebugPrintf("Usage: %s [startaddr] <options>\n", argv[0]);
+		DebugPrintf("Valid options are:\n");
+		DebugPrintf(" bwt  : Print byte/word tag\n");
+		DebugPrintf(" c<x> : Disassemble <x> bytes\n");
+		DebugPrintf(" bc   : Print bytecode\n");
+		return true;
+	}
+
+	reg_t vpc = NULL_REG;
+	int op_count = 1;
+	int do_bwc = 0;
+	int do_bytes = 0;
+	int size;
+
+	if (parse_reg_t(g_EngineState, argv[1], &vpc)) {
+		DebugPrintf("Invalid address passed.\n");
+		DebugPrintf("Check the \"addresses\" command on how to use addresses\n");
+		return true;
+	}
+
+	g_EngineState->seg_manager->dereference(vpc, &size);
+	size += vpc.offset; // total segment size
+
+	for (int i = 1; i < argc; i++) {
+		if (!scumm_stricmp(argv[i], "bwt"))
+			do_bwc = 1;
+		else if (!scumm_stricmp(argv[i], "bc"))
+			do_bytes = 1;
+		else if (toupper(argv[i][0]) == 'C')
+			op_count = atoi(argv[i] + 1);
+		else {
+			DebugPrintf("Invalid option '%s'\n", argv[i]);
+			return true;
+		}
+	}
+
+	if (op_count < 0) {
+		DebugPrintf("Invalid op_count\n");
+		return true;
+	}
+
+	do {
+		// TODO
+		//vpc = disassemble(g_EngineState, vpc, do_bwc, do_bytes);
+
+	} while ((vpc.offset > 0) && (vpc.offset + 6 < size) && (--op_count));
+
+	return true;
+}
+
 bool Console::cmdBreakpointList(int argc, const char **argv) {
 	Breakpoint *bp = g_EngineState->bp_list;
 	int i = 0;

Modified: scummvm/trunk/engines/sci/console.h
===================================================================
--- scummvm/trunk/engines/sci/console.h	2009-06-06 20:22:16 UTC (rev 41301)
+++ scummvm/trunk/engines/sci/console.h	2009-06-06 20:29:37 UTC (rev 41302)
@@ -122,9 +122,13 @@
 	bool cmdDissectScript(int argc, const char **argv);
 	bool cmdSetAccumulator(int argc, const char **argv);
 	bool cmdBacktrace(int argc, const char **argv);
+	bool cmdStep(int argc, const char **argv);
 	bool cmdStepEvent(int argc, const char **argv);
 	bool cmdStepRet(int argc, const char **argv);
 	bool cmdStepGlobal(int argc, const char **argv);
+	bool cmdStepCallk(int argc, const char **argv);
+	bool cmdDissassemble(int argc, const char **argv);
+	bool cmdDissassembleAddress(int argc, const char **argv);
 	// Breakpoints
 	bool cmdBreakpointList(int argc, const char **argv);
 	bool cmdBreakpointDelete(int argc, const char **argv);

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-06-06 20:22:16 UTC (rev 41301)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-06-06 20:29:37 UTC (rev 41302)
@@ -87,14 +87,6 @@
 	return 0;
 }
 
-int c_step(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	g_debugstate_valid = 0;
-	if (cmdParams.size() && (cmdParams[0].val > 0))
-		g_debug_step_running = cmdParams[0].val - 1;
-
-	return 0;
-}
-
 extern const char *selector_name(EngineState *s, int selector);
 
 int prop_ofs_to_id(EngineState *s, int prop_ofs, reg_t objp) {
@@ -373,111 +365,6 @@
 	return retval;
 }
 
-static int c_disasm_addr(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	reg_t vpc = cmdParams[0].reg;
-	int op_count = 1;
-	int do_bwc = 0;
-	int do_bytes = 0;
-	unsigned int i;
-	int invalid = 0;
-	int size;
-
-	s->seg_manager->dereference(vpc, &size);
-	size += vpc.offset; // total segment size
-
-	for (i = 1; i < cmdParams.size(); i++) {
-		if (!scumm_stricmp(cmdParams[i].str, "bwt"))
-			do_bwc = 1;
-		else if (!scumm_stricmp(cmdParams[i].str, "bc"))
-			do_bytes = 1;
-		else if (toupper(cmdParams[i].str[0]) == 'C')
-			op_count = atoi(cmdParams[i].str + 1);
-		else {
-			invalid = 1;
-			sciprintf("Invalid option '%s'\n", cmdParams[i].str);
-		}
-	}
-
-	if (invalid || op_count < 0)
-		return invalid;
-
-	do {
-		vpc = disassemble(s, vpc, do_bwc, do_bytes);
-
-	} while ((vpc.offset > 0) && (vpc.offset + 6 < size) && (--op_count));
-	return 0;
-}
-
-static int c_disasm(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-	Object *obj = obj_get(s, cmdParams[0].reg);
-	int selector_id = s->_kernel->findSelector(cmdParams[1].str);
-	reg_t addr;
-
-	if (!obj) {
-		sciprintf("Not an object.");
-		return 1;
-	}
-
-	if (selector_id < 0) {
-		sciprintf("Not a valid selector name.");
-		return 1;
-	}
-
-	if (lookup_selector(s, cmdParams[0].reg, selector_id, NULL, &addr) != kSelectorMethod) {
-		sciprintf("Not a method.");
-		return 1;
-	}
-
-	do {
-		addr = disassemble(s, addr, 0, 0);
-	} while (addr.offset > 0);
-
-	return 0;
-}
-
-static int c_snk(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
-// TODO: disabled till this is moved in console.cpp
-#if 0
-
-	int callk_index;
-	char *endptr;
-
-	if (!g_debugstate_valid) {
-		sciprintf("Not in debug state\n");
-		return 1;
-	}
-
-	if (cmdParams.size() > 0) {
-		/* Try to convert the parameter to a number. If the conversion stops
-		   before end of string, assume that the parameter is a function name
-		   and scan the function table to find out the index. */
-		callk_index = strtoul(cmdParams [0].str, &endptr, 0);
-		if (*endptr != '\0') {
-			callk_index = -1;
-			for (uint i = 0; i < s->_kernel->getKernelNamesSize(); i++)
-				if (cmdParams [0].str == s->_kernel->getKernelName(i)) {
-					callk_index = i;
-					break;
-				}
-
-			if (callk_index == -1) {
-				sciprintf("Unknown kernel function '%s'\n", cmdParams[0].str);
-				return 1;
-			}
-		}
-
-		g_debug_seeking = kDebugSeekSpecialCallk;
-		g_debug_seek_special = callk_index;
-		g_debugstate_valid = 0;
-	} else {
-		g_debug_seeking = kDebugSeekCallk;
-		g_debugstate_valid = 0;
-	}
-#endif
-
-	return 0;
-}
-
 static int c_go(EngineState *s, const Common::Array<cmd_param_t> &cmdParams) {
 	g_debug_seeking = 0;
 	g_debugstate_valid = 0;
@@ -631,23 +518,10 @@
 		sciprintf("Step #%d\n", script_step_counter);
 		disassemble(s, *pc, 0, 1);
 
-			con_hook_command(c_step, "s", "i*", "Executes one or several operations\n\nEXAMPLES\n\n"
-			                 "    s 4\n\n  Execute 4 commands\n\n    s\n\n  Execute next command");
-			con_hook_command(c_disasm_addr, "disasm-addr", "!as*", "Disassembles one or more commands\n\n"
-			                 "USAGE\n\n  disasm-addr [startaddr] <options>\n\n"
-			                 "  Valid options are:\n"
-			                 "  bwt  : Print byte/word tag\n"
-			                 "  c<x> : Disassemble <x> bytes\n"
-			                 "  bc   : Print bytecode\n\n");
-			con_hook_command(c_disasm, "disasm", "!as", "Disassembles a method by name\n\nUSAGE\n\n  disasm <obj> <method>\n\n");
-			con_hook_command(c_snk, "snk", "s*", "Steps forward until it hits the next\n  callk operation.\n"
-			                 "  If invoked with a parameter, it will\n  look for that specific callk.\n");
-			con_hook_command(c_send, "send", "!asa*", "Sends a message to an object\nExample: send ?fooScript cue");
-			con_hook_command(c_go, "go", "", "Executes the script.\n");
+		con_hook_command(c_send, "send", "!asa*", "Sends a message to an object\nExample: send ?fooScript cue");
+		con_hook_command(c_go, "go", "", "Executes the script.\n");
 	}
 
-	if (g_debug_step_running)
-		g_debug_step_running--;
 }
 
 } // End of namespace Sci


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