summaryrefslogtreecommitdiff
path: root/indra/llplugin
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2009-11-24 23:21:57 -0600
committerDave Parks <davep@lindenlab.com>2009-11-24 23:21:57 -0600
commite264f00c833805e1f813bc1d0b2cfd7a1bf7b272 (patch)
tree1a64a520502d2ed2c7dadc2316e543ae9e9a91d2 /indra/llplugin
parentc9e153c182dae9472a2b87cddfec8c47b30b06b9 (diff)
parent5b5354c933aa7b1ceeb307853c24fba28d4e31bf (diff)
Merge
Diffstat (limited to 'indra/llplugin')
-rw-r--r--indra/llplugin/llpluginclassmedia.cpp8
-rw-r--r--indra/llplugin/llpluginclassmedia.h2
-rw-r--r--indra/llplugin/llpluginprocesschild.cpp5
-rw-r--r--indra/llplugin/llpluginprocessparent.cpp31
-rw-r--r--indra/llplugin/llpluginprocessparent.h5
5 files changed, 41 insertions, 10 deletions
diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp
index 457c074ef1..c3d8a5aa23 100644
--- a/indra/llplugin/llpluginclassmedia.cpp
+++ b/indra/llplugin/llpluginclassmedia.cpp
@@ -61,14 +61,14 @@ LLPluginClassMedia::~LLPluginClassMedia()
reset();
}
-bool LLPluginClassMedia::init(const std::string &launcher_filename, const std::string &plugin_filename)
+bool LLPluginClassMedia::init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug)
{
LL_DEBUGS("Plugin") << "launcher: " << launcher_filename << LL_ENDL;
LL_DEBUGS("Plugin") << "plugin: " << plugin_filename << LL_ENDL;
mPlugin = new LLPluginProcessParent(this);
mPlugin->setSleepTime(mSleepTime);
- mPlugin->init(launcher_filename, plugin_filename);
+ mPlugin->init(launcher_filename, plugin_filename, debug);
return true;
}
@@ -593,10 +593,10 @@ void LLPluginClassMedia::setPriority(EPriority priority)
mSleepTime = 1.0f;
break;
case PRIORITY_LOW:
- mSleepTime = 1.0f / 50.0f;
+ mSleepTime = 1.0f / 25.0f;
break;
case PRIORITY_NORMAL:
- mSleepTime = 1.0f / 100.0f;
+ mSleepTime = 1.0f / 50.0f;
break;
case PRIORITY_HIGH:
mSleepTime = 1.0f / 100.0f;
diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h
index 90ecd1e073..dcc4a3bd6a 100644
--- a/indra/llplugin/llpluginclassmedia.h
+++ b/indra/llplugin/llpluginclassmedia.h
@@ -47,7 +47,7 @@ public:
virtual ~LLPluginClassMedia();
// local initialization, called by the media manager when creating a source
- virtual bool init(const std::string &launcher_filename, const std::string &plugin_filename);
+ virtual bool init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug = false);
// undoes everything init() didm called by the media manager when destroying a source
virtual void reset();
diff --git a/indra/llplugin/llpluginprocesschild.cpp b/indra/llplugin/llpluginprocesschild.cpp
index 450dcb3c78..fc95136d9e 100644
--- a/indra/llplugin/llpluginprocesschild.cpp
+++ b/indra/llplugin/llpluginprocesschild.cpp
@@ -37,12 +37,13 @@
#include "llpluginmessageclasses.h"
static const F32 HEARTBEAT_SECONDS = 1.0f;
+static const F32 PLUGIN_IDLE_SECONDS = 1.0f / 100.0f; // Each call to idle will give the plugin this much time.
LLPluginProcessChild::LLPluginProcessChild()
{
mInstance = NULL;
mSocket = LLSocket::create(gAPRPoolp, LLSocket::STREAM_TCP);
- mSleepTime = 1.0f / 100.0f; // default: send idle messages at 100Hz
+ mSleepTime = PLUGIN_IDLE_SECONDS; // default: send idle messages at 100Hz
mCPUElapsed = 0.0f;
}
@@ -155,7 +156,7 @@ void LLPluginProcessChild::idle(void)
{
// Provide some time to the plugin
LLPluginMessage message("base", "idle");
- message.setValueReal("time", mSleepTime);
+ message.setValueReal("time", PLUGIN_IDLE_SECONDS);
sendMessageToPlugin(message);
mInstance->idle();
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())
{
diff --git a/indra/llplugin/llpluginprocessparent.h b/indra/llplugin/llpluginprocessparent.h
index 754ebeb946..1289e86c13 100644
--- a/indra/llplugin/llpluginprocessparent.h
+++ b/indra/llplugin/llpluginprocessparent.h
@@ -56,7 +56,7 @@ public:
LLPluginProcessParent(LLPluginProcessParentOwner *owner);
~LLPluginProcessParent();
- void init(const std::string &launcher_filename, const std::string &plugin_filename);
+ void init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug = false);
void idle(void);
// returns true if the plugin is on its way to steady state
@@ -150,6 +150,9 @@ private:
F64 mCPUUsage;
bool mDisableTimeout;
+ bool mDebug;
+
+ LLProcessLauncher mDebugger;
};
#endif // LL_LLPLUGINPROCESSPARENT_H