string sh_command(const string& command, bool force_local) { string ret = _sh_command(command, force_local); dddlog << "+ " << ret << "\n"; dddlog.flush(); return ret; }
GDBAgent *new_gdb(DebuggerType type, const AppData& app_data, XtAppContext app_context, int argc, char *argv[]) { // Build call static string gdb_call = app_data.debugger_command; if (app_data.play_log != 0) { gdb_call += string(" --PLAY ") + app_data.play_log; } else { switch(type) { case GDB: // Do not issue introductiory messages; output full file names. gdb_call += " -q -fullname"; break; case DBX: // Nothing special. (Anyway, every DBX has its own sets of // options, so there is not much we could do here.) break; case JDB: // Nothing special. break; case PERL: // Be sure to invoke the debugger. gdb_call += " -d"; break; case BASH: // Be sure to invoke the debugger. gdb_call += " --debugger"; break; case DBG: // Nothing special? break; case PYDB: // Nothing special. break; case XDB: // Enable line mode. gdb_call += " -L"; break; } } for (int i = 1; i < argc; i++) { string arg = argv[i]; gdb_call += " " + sh_quote(arg); } if (argc <= 1) { if (type == PERL) { // Invoked without args. Add a dummy `eval' arg. gdb_call += " -e 42"; } else if (type == BASH) { gdb_call += " -c ': type \\\"debug *script-name*\\\" to start your script.'"; } } GDBAgent *gdb; if (app_data.debugger_rhost == 0 || app_data.debugger_rhost[0] == '\0') { // Use direct invocation gdb_call = sh_command("exec " + gdb_call); gdb = new GDBAgent(app_context, gdb_call, type); } else { // Use interactive rsh gdb = new GDBAgent(app_context, sh_command(), type); gdb_call = "exec " + _sh_command("exec " + gdb_call, true, true) + "\n"; gdb->addHandler(Input, InvokeGDBFromShellHP, (void *)&gdb_call); } // Set up Agent resources switch (app_data.block_tty_input) { case On: gdb->block_tty_input(true); break; case Off: gdb->block_tty_input(false); break; case Auto: // Leave default setting unchanged break; } // Set up Agent resources switch (app_data.buffer_gdb_output) { case On: gdb->buffer_gdb_output(true); break; case Off: gdb->buffer_gdb_output(false); break; case Auto: // Tie buffering to existence of separate window gdb->buffer_gdb_output(app_data.separate_exec_window); break; } return gdb; }