| 38 | } |
| 39 | |
| 40 | bool GdbDebugger::start(KConfigGroup& config, const QStringList& extraArguments) |
| 41 | { |
| 42 | // FIXME: verify that default value leads to something sensible |
| 43 | QUrl gdbUrl = config.readEntry(Config::GdbPathEntry, QUrl()); |
| 44 | if (gdbUrl.isEmpty()) { |
| 45 | m_debuggerExecutable = QStringLiteral("gdb"); |
| 46 | } else { |
| 47 | // FIXME: verify its' a local path. |
| 48 | m_debuggerExecutable = gdbUrl.url(QUrl::PreferLocalFile | QUrl::StripTrailingSlash); |
| 49 | } |
| 50 | |
| 51 | QStringList arguments = extraArguments; |
| 52 | arguments << QStringLiteral("--interpreter=mi2") << QStringLiteral("-quiet"); |
| 53 | |
| 54 | QString fullCommand; |
| 55 | |
| 56 | QUrl shell = config.readEntry(Config::DebuggerShellEntry, QUrl()); |
| 57 | if(!shell.isEmpty()) { |
| 58 | qCDebug(DEBUGGERGDB) << "have shell" << shell; |
| 59 | QString shell_without_args = shell.toLocalFile().split(QLatin1Char(' ')).first(); |
| 60 | |
| 61 | QFileInfo info(shell_without_args); |
| 62 | /*if( info.isRelative() ) |
| 63 | { |
| 64 | shell_without_args = build_dir + "/" + shell_without_args; |
| 65 | info.setFile( shell_without_args ); |
| 66 | }*/ |
| 67 | if(!info.exists()) { |
| 68 | const QString messageText = i18n("Could not locate the debugging shell '%1'.", shell_without_args); |
| 69 | auto* message = new Sublime::Message(messageText, Sublime::Message::Error); |
| 70 | KDevelop::ICore::self()->uiController()->postMessage(message); |
| 71 | return false; |
| 72 | } |
| 73 | |
| 74 | arguments.insert(0, m_debuggerExecutable); |
| 75 | arguments.insert(0, shell.toLocalFile()); |
| 76 | m_process->setShellCommand(KShell::joinArgs(arguments)); |
| 77 | } else { |
| 78 | m_process->setProgram(m_debuggerExecutable, arguments); |
| 79 | fullCommand = m_debuggerExecutable + QLatin1Char(' '); |
| 80 | } |
| 81 | fullCommand += arguments.join(QLatin1Char(' ')); |
| 82 | |
| 83 | KDevelop::ICore::self()->runtimeController()->currentRuntime()->startProcess(m_process); |
| 84 | |
| 85 | qCDebug(DEBUGGERGDB) << "Starting GDB with command" << fullCommand; |
| 86 | qCDebug(DEBUGGERGDB) << "GDB process pid:" << m_process->processId(); |
| 87 | emit userCommandOutput(fullCommand + QLatin1Char('\n')); |
| 88 | return true; |
| 89 | } |
| 90 | |
| 91 | #include "moc_gdb.cpp" |