Permalink
Browse files

Adds the server-side part of the javascript debugger. Refs #410

git-svn-id: http://svn.wildfiregames.com/public/ps/trunk@13238 3db68df2-c116-0410-a063-a993310a9797
  • Loading branch information...
Yves Yves
Yves authored and Yves committed Mar 7, 2013
1 parent 58eeab6 commit 3ba51149b4d76ec14e6bc360d4f1dc4bc5049ac8
@@ -290,11 +290,15 @@ hotkey.profile.save = "Shift+F11" ; Save current profiler data to logs
hotkey.profile2.enable = "F11" ; Enable HTTP/GPU modes for new profiler
profiler2.http.autoenable = false ; Enable HTTP server output at startup (default off for security/performance)
+profiler2.script.enable = false ; Enable Javascript profiling. Needs to be set before startup and can't be changed later. (default off for performance)
profiler2.gpu.autoenable = false ; Enable GPU timing at startup (default off for performance/compatibility)
profiler2.gpu.arb.enable = true ; Allow GL_ARB_timer_query timing mode when available
profiler2.gpu.ext.enable = true ; Allow GL_EXT_timer_query timing mode when available
profiler2.gpu.intel.enable = true ; Allow GL_INTEL_performance_queries timing mode when available
+; > JS DEBUGGER
+jsdebugger.enable = false ; Enable Javascript debugging (default off for security/performance)
+
; > QUICKSAVE
hotkey.quicksave = "Shift+F5"
hotkey.quickload = "Shift+F8"
@@ -545,6 +545,7 @@ function setup_all_libs ()
"boost",
"spidermonkey",
"valgrind",
+ "sdl",
}
setup_static_lib_project("scriptinterface", source_dirs, extern_libs, {})
@@ -63,6 +63,7 @@ void CMapGeneratorWorker::Initialize(const VfsPath& scriptFile, const std::strin
void* CMapGeneratorWorker::RunThread(void *data)
{
debug_SetThreadName("MapGenerator");
+ g_Profiler2.RegisterCurrentThread("MapGenerator");
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(data);
@@ -75,6 +75,7 @@ JSBool JSI_IGUIObject::getProperty(JSContext* cx, JSObject* obj, jsid id, jsval*
if (propName == "constructor" ||
propName == "prototype" ||
propName == "toString" ||
+ propName == "toJSON" ||
propName == "focus" ||
propName == "blur" ||
propName == "getComputedSize"
View
@@ -209,6 +209,10 @@ namespace ConfigDB_JS
};
CConfigDB::CConfigDB()
+{
+}
+
+void CConfigDB::RegisterJSConfigDB()
{
g_ScriptingHost.DefineCustomObjectType(&ConfigDB_JS::Class, ConfigDB_JS::Construct, 0, ConfigDB_JS::Props, ConfigDB_JS::Funcs, NULL, NULL);
g_ScriptingHost.DefineCustomObjectType(&ConfigNamespace_JS::Class, ConfigNamespace_JS::Construct, 0, NULL, ConfigNamespace_JS::Funcs, NULL, NULL);
View
@@ -80,9 +80,12 @@ class CConfigDB: public Singleton<CConfigDB>
static VfsPath m_ConfigFile[];
public:
- // NOTE: Construct the Singleton Object *after* JavaScript init, so that
- // the JS interface can be registered.
CConfigDB();
+
+ // NOTE: Construct the Singleton Object *after* JavaScript init, so that
+ // the JS interface can be registered. ConfigDB (C++) needs to be initialized before
+ // The ScriptInterface because the ScriptInterface requires some configuration information too.
+ void RegisterJSConfigDB();
/**
* Attempt to find a config variable with the given name; will search
@@ -21,6 +21,7 @@
#include "ps/ConfigDB.h"
#include "ps/CConsole.h"
+#include "ps/CLogger.h"
#include "ps/GameSetup/CmdLineArgs.h"
#include "lib/timer.h"
#include "soundmanager/SoundManager.h"
@@ -60,6 +61,9 @@ bool g_VSync = false;
bool g_Quickstart = false;
bool g_DisableAudio = false;
+bool g_JSDebuggerEnabled = false;
+bool g_ScriptProfilingEnabled = false;
+
// flag to switch on drawing terrain overlays
bool g_ShowPathfindingOverlay = false;
@@ -127,6 +131,14 @@ static void LoadGlobals()
g_SoundManager->SetMemoryUsage(bufferSize, bufferCount);
}
#endif // CONFIG2_AUDIO
+
+ CFG_GET_VAL("jsdebugger.enable", Bool, g_JSDebuggerEnabled);
+ CFG_GET_VAL("profiler2.script.enable", Bool, g_ScriptProfilingEnabled);
+
+ // Script Debugging and profiling does not make sense together because of the hooks
+ // that reduce performance a lot - and it wasn't tested if it even works together.
+ if (g_JSDebuggerEnabled && g_ScriptProfilingEnabled)
+ LOGERROR(L"Enabling both script profiling and script debugging is not supported!");
}
@@ -82,6 +82,9 @@ extern bool g_VSync;
extern bool g_Quickstart;
extern bool g_DisableAudio;
+extern bool g_JSDebuggerEnabled;
+extern bool g_ScriptProfilingEnabled;
+
extern CStrW g_CursorName;
class CmdLineArgs;
@@ -84,6 +84,7 @@
#include "renderer/ModelRenderer.h"
#include "scripting/ScriptingHost.h"
#include "scripting/ScriptGlue.h"
+#include "scriptinterface/DebuggingServer.h"
#include "scriptinterface/ScriptInterface.h"
#include "scriptinterface/ScriptStats.h"
#include "simulation2/Simulation2.h"
@@ -692,6 +693,7 @@ void Shutdown(int UNUSED(flags))
TIMER_BEGIN(L"shutdown ScriptingHost");
delete &g_ScriptingHost;
+ delete g_DebuggingServer;
TIMER_END(L"shutdown ScriptingHost");
TIMER_BEGIN(L"shutdown ConfigDB");
@@ -886,10 +888,16 @@ void Init(const CmdLineArgs& args, int UNUSED(flags))
CSoundManager::CreateSoundManager();
#endif
- InitScripting(); // before GUI
-
// g_ConfigDB, command line args, globals
CONFIG_Init(args);
+
+ // before scripting
+ if (g_JSDebuggerEnabled)
+ g_DebuggingServer = new CDebuggingServer();
+
+ InitScripting(); // before GUI
+
+ g_ConfigDB.RegisterJSConfigDB(); // after scripting
// Optionally start profiler HTTP output automatically
// (By default it's only enabled by a hotkey, for security/performance)
Oops, something went wrong.

0 comments on commit 3ba5114

Please sign in to comment.