Use LL_DEBUG_TERMINAL_COMMAND and LL_DEBUG_GDB_PATH
Upgraded the code that attaches gdb to a plugin for linux to the code that I wrote for viewer 2.
This commit is contained in:
@@ -74,6 +74,7 @@ Aleric Inglewood
|
|||||||
VWR-24312
|
VWR-24312
|
||||||
VWR-24320
|
VWR-24320
|
||||||
VWR-24333
|
VWR-24333
|
||||||
|
VWR-24334
|
||||||
SNOW-47
|
SNOW-47
|
||||||
SNOW-84
|
SNOW-84
|
||||||
SNOW-86
|
SNOW-86
|
||||||
|
|||||||
@@ -38,6 +38,9 @@
|
|||||||
#include "llpluginprocessparent.h"
|
#include "llpluginprocessparent.h"
|
||||||
#include "llpluginmessagepipe.h"
|
#include "llpluginmessagepipe.h"
|
||||||
#include "llpluginmessageclasses.h"
|
#include "llpluginmessageclasses.h"
|
||||||
|
#if LL_LINUX
|
||||||
|
#include <boost/program_options/parsers.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "llapr.h"
|
#include "llapr.h"
|
||||||
|
|
||||||
@@ -373,14 +376,12 @@ void LLPluginProcessParent::idle(void)
|
|||||||
{
|
{
|
||||||
if(mDebug)
|
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.
|
// 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.
|
||||||
|
std::stringstream cmd;
|
||||||
|
|
||||||
|
#if LL_DARWIN
|
||||||
// The command we're constructing would look like this on the command line:
|
// 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'
|
// 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.setExecutable("/usr/bin/osascript");
|
||||||
mDebugger.addArgument("-e");
|
mDebugger.addArgument("-e");
|
||||||
mDebugger.addArgument("tell application \"Terminal\"");
|
mDebugger.addArgument("tell application \"Terminal\"");
|
||||||
@@ -392,19 +393,32 @@ void LLPluginProcessParent::idle(void)
|
|||||||
mDebugger.addArgument("-e");
|
mDebugger.addArgument("-e");
|
||||||
mDebugger.addArgument("end tell");
|
mDebugger.addArgument("end tell");
|
||||||
mDebugger.launch();
|
mDebugger.launch();
|
||||||
|
#elif LL_LINUX
|
||||||
#elif LL_LINUX
|
// The command we're constructing would look like this on the command line:
|
||||||
|
// /usr/bin/xterm -geometry 160x24-0+0 -e '/usr/bin/gdb -n /proc/12345/exe 12345'
|
||||||
std::stringstream cmd;
|
// This can be changed by setting the following environment variables, for example:
|
||||||
|
// export LL_DEBUG_TERMINAL_COMMAND="/usr/bin/gnome-terminal --geometry=165x24-0+0 -e %s"
|
||||||
mDebugger.setExecutable("/usr/bin/gnome-terminal");
|
// export LL_DEBUG_GDB_PATH=/usr/bin/gdb
|
||||||
mDebugger.addArgument("--geometry=165x24-0+0");
|
char const* env;
|
||||||
mDebugger.addArgument("-e");
|
std::string const terminal_command = (env = getenv("LL_DEBUG_TERMINAL_COMMAND")) ? env : "/usr/bin/xterm -geometry 160x24+0+0 -e %s";
|
||||||
cmd << "/usr/bin/gdb -n /proc/" << mProcess.getProcessID() << "/exe " << mProcess.getProcessID();
|
char const* const gdb_path = (env = getenv("LL_DEBUG_GDB_PATH")) ? env : "/usr/bin/gdb";
|
||||||
mDebugger.addArgument(cmd.str());
|
cmd << gdb_path << " -n /proc/" << mProcess.getProcessID() << "/exe " << mProcess.getProcessID();
|
||||||
|
std::vector<std::string> tokens = boost::program_options::split_unix(terminal_command, " ");
|
||||||
|
std::vector<std::string>::iterator token = tokens.begin();
|
||||||
|
mDebugger.setExecutable(*token);
|
||||||
|
while (++token != tokens.end())
|
||||||
|
{
|
||||||
|
if (*token == "%s")
|
||||||
|
{
|
||||||
|
mDebugger.addArgument(cmd.str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mDebugger.addArgument(*token);
|
||||||
|
}
|
||||||
|
}
|
||||||
mDebugger.launch();
|
mDebugger.launch();
|
||||||
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will allow us to time out if the process never starts.
|
// This will allow us to time out if the process never starts.
|
||||||
|
|||||||
@@ -1935,7 +1935,7 @@
|
|||||||
<key>PluginAttachDebuggerToPlugins</key>
|
<key>PluginAttachDebuggerToPlugins</key>
|
||||||
<map>
|
<map>
|
||||||
<key>Comment</key>
|
<key>Comment</key>
|
||||||
<string>TODO: understand what this actually does -.-sg</string>
|
<string>Opens a terminal window with a debugger and attach it, every time a new SLPlugin process is started.</string>
|
||||||
<key>Persist</key>
|
<key>Persist</key>
|
||||||
<integer>1</integer>
|
<integer>1</integer>
|
||||||
<key>Type</key>
|
<key>Type</key>
|
||||||
|
|||||||
Reference in New Issue
Block a user