- Factor out setting up the arguments for gdb handover.
- When using the graphical debugger by default, fall back to setting up gdb handover if the GUI is unavailable. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42446 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
de6f745cde
commit
9918b71672
@ -48,11 +48,10 @@ using std::nothrow;
|
|||||||
static const char *kSignature = "application/x-vnd.Haiku-debug_server";
|
static const char *kSignature = "application/x-vnd.Haiku-debug_server";
|
||||||
|
|
||||||
// paths to the apps used for debugging
|
// paths to the apps used for debugging
|
||||||
#ifdef HANDOVER_USE_GDB
|
|
||||||
static const char *kConsoledPath = "/bin/consoled";
|
static const char *kConsoledPath = "/bin/consoled";
|
||||||
static const char *kTerminalPath = "/boot/system/apps/Terminal";
|
static const char *kTerminalPath = "/boot/system/apps/Terminal";
|
||||||
static const char *kGDBPath = "/bin/gdb";
|
static const char *kGDBPath = "/bin/gdb";
|
||||||
#elif defined(HANDOVER_USE_DEBUGGER)
|
#ifdef HANDOVER_USE_DEBUGGER
|
||||||
static const char *kDebuggerPath = "/boot/system/apps/Debugger";
|
static const char *kDebuggerPath = "/boot/system/apps/Debugger";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -117,6 +116,8 @@ private:
|
|||||||
status_t _PopMessage(DebugMessage *&message);
|
status_t _PopMessage(DebugMessage *&message);
|
||||||
|
|
||||||
thread_id _EnterDebugger();
|
thread_id _EnterDebugger();
|
||||||
|
void _SetupGDBArguments(const char **argv, int &argc, char *teamString,
|
||||||
|
size_t teamStringSize, bool usingConsoled);
|
||||||
void _KillTeam();
|
void _KillTeam();
|
||||||
|
|
||||||
bool _HandleMessage(DebugMessage *message);
|
bool _HandleMessage(DebugMessage *message);
|
||||||
@ -435,6 +436,33 @@ TeamDebugHandler::_PopMessage(DebugMessage *&message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TeamDebugHandler::_SetupGDBArguments(const char **argv, int &argc,
|
||||||
|
char *teamString, size_t teamStringSize, bool usingConsoled)
|
||||||
|
{
|
||||||
|
// prepare the argument vector
|
||||||
|
snprintf(teamString, teamStringSize, "--pid=%ld", fTeam);
|
||||||
|
|
||||||
|
const char *terminal = (usingConsoled ? kConsoledPath : kTerminalPath);
|
||||||
|
|
||||||
|
argv[argc++] = terminal;
|
||||||
|
|
||||||
|
if (!usingConsoled) {
|
||||||
|
char windowTitle[64];
|
||||||
|
snprintf(windowTitle, sizeof(windowTitle), "Debug of Team %ld: %s",
|
||||||
|
fTeam, _LastPathComponent(fExecutablePath));
|
||||||
|
argv[argc++] = "-t";
|
||||||
|
argv[argc++] = windowTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
argv[argc++] = kGDBPath;
|
||||||
|
argv[argc++] = teamString;
|
||||||
|
if (strlen(fExecutablePath) > 0)
|
||||||
|
argv[argc++] = fExecutablePath;
|
||||||
|
argv[argc] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
thread_id
|
thread_id
|
||||||
TeamDebugHandler::_EnterDebugger()
|
TeamDebugHandler::_EnterDebugger()
|
||||||
{
|
{
|
||||||
@ -456,35 +484,21 @@ TeamDebugHandler::_EnterDebugger()
|
|||||||
const char *argv[16];
|
const char *argv[16];
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
char teamString[32];
|
char teamString[32];
|
||||||
#ifdef HANDOVER_USE_GDB
|
|
||||||
bool debugInConsoled = _IsGUIServer() || !_AreGUIServersAlive();
|
bool debugInConsoled = _IsGUIServer() || !_AreGUIServersAlive();
|
||||||
|
#ifdef HANDOVER_USE_GDB
|
||||||
|
|
||||||
// prepare the argument vector
|
_SetupGDBArguments(argv, argc, teamString, sizeof(teamString),
|
||||||
snprintf(teamString, sizeof(teamString), "--pid=%ld", fTeam);
|
debugInConsoled);
|
||||||
|
|
||||||
const char *terminal = (debugInConsoled ? kConsoledPath : kTerminalPath);
|
|
||||||
|
|
||||||
argv[argc++] = terminal;
|
|
||||||
|
|
||||||
if (!debugInConsoled) {
|
|
||||||
char windowTitle[64];
|
|
||||||
snprintf(windowTitle, sizeof(windowTitle), "Debug of Team %ld: %s",
|
|
||||||
fTeam, _LastPathComponent(fExecutablePath));
|
|
||||||
argv[argc++] = "-t";
|
|
||||||
argv[argc++] = windowTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
argv[argc++] = kGDBPath;
|
|
||||||
argv[argc++] = teamString;
|
|
||||||
if (strlen(fExecutablePath) > 0)
|
|
||||||
argv[argc++] = fExecutablePath;
|
|
||||||
argv[argc] = NULL;
|
|
||||||
|
|
||||||
// start the terminal
|
// start the terminal
|
||||||
TRACE(("debug_server: TeamDebugHandler::_EnterDebugger(): starting "
|
TRACE(("debug_server: TeamDebugHandler::_EnterDebugger(): starting "
|
||||||
"terminal (debugger) for team %ld...\n", fTeam));
|
"terminal (debugger) for team %ld...\n", fTeam));
|
||||||
|
|
||||||
#elif defined(HANDOVER_USE_DEBUGGER)
|
#elif defined(HANDOVER_USE_DEBUGGER)
|
||||||
|
if (debugInConsoled) {
|
||||||
|
_SetupGDBArguments(argv, argc, teamString, sizeof(teamString),
|
||||||
|
debugInConsoled);
|
||||||
|
} else {
|
||||||
// prepare the argument vector
|
// prepare the argument vector
|
||||||
snprintf(teamString, sizeof(teamString), "%ld", fTeam);
|
snprintf(teamString, sizeof(teamString), "%ld", fTeam);
|
||||||
|
|
||||||
@ -496,7 +510,7 @@ TeamDebugHandler::_EnterDebugger()
|
|||||||
// start the debugger
|
// start the debugger
|
||||||
TRACE(("debug_server: TeamDebugHandler::_EnterDebugger(): starting "
|
TRACE(("debug_server: TeamDebugHandler::_EnterDebugger(): starting "
|
||||||
"graphical debugger for team %ld...\n", fTeam));
|
"graphical debugger for team %ld...\n", fTeam));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
thread_id thread = load_image(argc, argv, (const char**)environ);
|
thread_id thread = load_image(argc, argv, (const char**)environ);
|
||||||
|
Loading…
Reference in New Issue
Block a user