Commits

kevinclancy committed 6b61cbd Merge

added printing to the debugger, changed DEBUG preprocessor constant to NDEBUG in release.

  • Participants
  • Parent commits ee915f3, 55bf339

Comments (0)

Files changed (6)

platform/msvc2010/love.vcxproj

     <ConfigurationType>Application</ConfigurationType>
     <UseDebugLibraries>true</UseDebugLibraries>
     <CharacterSet>Unicode</CharacterSet>
-    <PlatformToolset>v110</PlatformToolset>
+    <PlatformToolset>v100</PlatformToolset>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
     <ConfigurationType>Application</ConfigurationType>
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
       <ObjectFileName>%(Identity).obj</ObjectFileName>
-      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;VC_EXTRALEAN;NDEBUG;WIN32;LOVE_LEGENDARY_CONSOLE_HACK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;VC_EXTRALEAN;DEBUG;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>
       </StringPooling>
       <MinimalRebuild>
       <AdditionalOptions>/FORCE:MULTIPLE %(AdditionalOptions)</AdditionalOptions>
     </Link>
     <ProjectReference>
-      <LinkLibraryDependencies>false</LinkLibraryDependencies>
+      <LinkLibraryDependencies>true</LinkLibraryDependencies>
     </ProjectReference>
   </ItemDefinitionGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
 	extern int luaopen_love_timer(lua_State*);
 	extern int luaopen_love_thread(lua_State*);
 	extern int luaopen_love_debugger(lua_State*);
+	extern int w_debugger_print(lua_State*);
 }
 
 static const luaL_Reg modules[] = {
+	{ "love.debugger", luaopen_love_debugger },
 	{ "love.audio", luaopen_love_audio },
 	{ "love.event", luaopen_love_event },
 	{ "love.filesystem", luaopen_love_filesystem },
 	{ "love.sound", luaopen_love_sound },
 	{ "love.timer", luaopen_love_timer },
 	{ "love.thread", luaopen_love_thread },
-	{ "love.debugger", luaopen_love_debugger },
 	{ 0, 0 }
 };
 
 		lua_setglobal(L, "arg");
 	}
 
+	/// Add in love studio's print function
+	{
+		lua_pushcfunction(L,w_debugger_print);
+		lua_setglobal(L,"print");
+	}
+
 	// Add love.__exe = true.
 	// This indicates that we're running the
 	// standalone version of love, and not the

src/modules/debugger/Debugger.cpp

 	data.WriteString(breakMessage ? breakMessage : "");
 
 	lua_Debug ar;
-	int stackSize = stackDepth(luaState);
+	int stackSize = min(stackDepth(luaState),100);
 	data.WriteInt(stackSize);
 
 	int i = 0;
-	while (lua_getstack(luaState,i,&ar) == 1 && i < 100)
+	int sentFrames = 0;
+	while (lua_getstack(luaState,i,&ar) == 1 && sentFrames < stackSize)
 	{
 		int res = lua_getinfo(luaState, "nSl", &ar);
 		_assert(res == 1);
 		data.WriteInt(ar.currentline);
 		data.WriteInt(i);
 
+		++sentFrames;
 		++i;
 	}
 
 	_assert(topInit == lua_gettop(L));
 }
 
+void sendChunk(connection_t* connection, char* buffer, int length)
+{
+	lion_output(connection,buffer, length);
+
+}
+
 void Debugger::sendLocals(
 	lua_State * L, 
 	lua_Debug * ar, 
 	}
 }
 
+void Debugger::sendDebugLine(const char* msg)
+{
+	OutChunk chunk;
+	chunk.WriteChar(DEBUG_PRINT);
+	chunk.WriteString(msg);
+	lion_output(outgoing,chunk.GetBytes(),chunk.GetLength());
+}
+
 }
 
 }

src/modules/debugger/Debugger.h

 		/// Send each upvalue in the current activation record to the debugger.
 		void sendUpvalues(lua_State * L, lua_Debug * ar, int debugLevel);
 
+		/// Sends a large chunk of data, waiting until the buffer empties out
+		/// to continue
+		void sendChunk(connection_t* connection, char* buffer, int length);
+
 		// ** end breaking
 	public:
 		/// Identifies the purpose and data format of a message.
 			/// All debugging info has been received from love studio, and 
 			/// execution may begin
 			INIT_FINISH,
-			/// Love Studio has signaled the target to shut down. 
-			TERMINATE
+			///in: Love Studio has signaled the target to shut down. 
+			TERMINATE,
+			///out: A debug line has been received from the target
+			DEBUG_PRINT,
 		};
 
 		/// Labels for browser messages--both incoming and outgoing--which tell 
 		/// debugs the given thread
 		void debugThread(lua_State* L, std::string msg);
 
+		/// Sends a debug message to the IDE debugger.
+		void sendDebugLine(const char* msg);
+
 		// overridden from Module
 		virtual const char * getName() const { return "love.debugger"; }
 	};

src/modules/debugger/wrap_Debugger.cpp

 	return 0;
 }
 
+int w_debugger_print(lua_State* L)
+{
+	if (debuggerInstance == NULL) return 0;
+
+	luaL_checktype(L,1,LUA_TSTRING);
+	const char* msg = lua_tostring(L,-1);
+	debuggerInstance->sendDebugLine(msg);
+	return 0;
+}
+
 static const luaL_Reg functions[] = {
 	{ "update", w_update },
 	{ "errorHandler", w_errorHandler },

src/modules/debugger/wrap_Debugger.h

 	/// Waits for a resume message from the debug proxy, and then shuts down
 	/// love.
 	int w_errorHandler(lua_State * L);
-
 	/// Debugs the thread at the top of the stack specified by the argument.
 	int w_debugThread(lua_State* L);
+	
+	/// Sends a debug message to the IDE debugger.
+	extern "C" LOVE_EXPORT int w_debugger_print(lua_State* L);
+
 	extern "C" LOVE_EXPORT int luaopen_love_debugger(lua_State * L);
 } // debugger
 } // love