diff options
author | Monroe Linden <monroe@lindenlab.com> | 2009-11-10 15:57:26 -0800 |
---|---|---|
committer | Monroe Linden <monroe@lindenlab.com> | 2009-11-10 15:57:26 -0800 |
commit | 2fd31363f747aaf0ec3d3d6b5711e0ecc99b2cf3 (patch) | |
tree | 0b17d949176aa80dbb0801ac240e36317e5f57e1 /indra/llplugin/llpluginprocessparent.cpp | |
parent | 2d5c6ea8207664ed3ef5de356638f7e30b812836 (diff) |
Added PluginAttachDebuggerToPlugins debug setting.
Added accessors to get platform-specific process ID from LLProcessLauncher.
Added an optional "debug" argument to LLPluginClassMedia::init() and LLPluginProcessParent::init() (defaults to false).
Mac only: made the state machine in LLPluginProcessParent::idle() open a new window in Terminal.app with a gdb session attached to the plugin process upon successful launch.
Diffstat (limited to 'indra/llplugin/llpluginprocessparent.cpp')
-rw-r--r-- | indra/llplugin/llpluginprocessparent.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/indra/llplugin/llpluginprocessparent.cpp b/indra/llplugin/llpluginprocessparent.cpp index 39f9438fb3..b7ce800c3a 100644 --- a/indra/llplugin/llpluginprocessparent.cpp +++ b/indra/llplugin/llpluginprocessparent.cpp @@ -55,6 +55,7 @@ LLPluginProcessParent::LLPluginProcessParent(LLPluginProcessParentOwner *owner) mBoundPort = 0; mState = STATE_UNINITIALIZED; mDisableTimeout = false; + mDebug = false; // initialize timer - heartbeat test (mHeartbeat.hasExpired()) // can sometimes return true immediately otherwise and plugins @@ -96,11 +97,12 @@ void LLPluginProcessParent::errorState(void) setState(STATE_ERROR); } -void LLPluginProcessParent::init(const std::string &launcher_filename, const std::string &plugin_filename) +void LLPluginProcessParent::init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug) { mProcess.setExecutable(launcher_filename); mPluginFile = plugin_filename; mCPUUsage = 0.0f; + mDebug = debug; setState(STATE_INITIALIZED); } @@ -291,6 +293,31 @@ void LLPluginProcessParent::idle(void) } else { + if(mDebug) + { + #if LL_DARWIN + // If we're set to debug, start up a gdb instance in a new terminal window and have it attach to the plugin process and continue. + + // The command we're constructing would look like this on the command line: + // osascript -e 'tell application "Terminal"' -e 'set win to do script "gdb -pid 12345"' -e 'do script "continue" in win' -e 'end tell' + + std::stringstream cmd; + + mDebugger.setExecutable("/usr/bin/osascript"); + mDebugger.addArgument("-e"); + mDebugger.addArgument("tell application \"Terminal\""); + mDebugger.addArgument("-e"); + cmd << "set win to do script \"gdb -pid " << mProcess.getProcessID() << "\""; + mDebugger.addArgument(cmd.str()); + mDebugger.addArgument("-e"); + mDebugger.addArgument("do script \"continue\" in win"); + mDebugger.addArgument("-e"); + mDebugger.addArgument("end tell"); + mDebugger.launch(); + + #endif + } + // This will allow us to time out if the process never starts. mHeartbeat.start(); mHeartbeat.setTimerExpirySec(PLUGIN_LAUNCH_SECONDS); @@ -661,7 +688,7 @@ bool LLPluginProcessParent::pluginLockedUpOrQuit() { bool result = false; - if(!mDisableTimeout) + if(!mDisableTimeout && !mDebug) { if(!mProcess.isRunning()) { |