| 173 | } |
| 174 | |
| 175 | bool DebugSession::execInferior(KDevelop::ILaunchConfiguration *cfg, IExecutePlugin *, const QString &executable) |
| 176 | { |
| 177 | qCDebug(DEBUGGERGDB) << "Executing inferior"; |
| 178 | |
| 179 | KConfigGroup grp = cfg->config(); |
| 180 | QUrl configGdbScript = grp.readEntry(Config::RemoteGdbConfigEntry, QUrl()); |
| 181 | QUrl runShellScript = grp.readEntry(Config::RemoteGdbShellEntry, QUrl()); |
| 182 | QUrl runGdbScript = grp.readEntry(Config::RemoteGdbRunEntry, QUrl()); |
| 183 | |
| 184 | // handle remote debug |
| 185 | if (configGdbScript.isValid()) { |
| 186 | addCommand(MI::NonMI, QLatin1String("source ") + configGdbScript.toLocalFile()); |
| 187 | } |
| 188 | |
| 189 | // FIXME: have a check box option that controls remote debugging |
| 190 | if (runShellScript.isValid()) { |
| 191 | // Special for remote debug, the remote inferior is started by this shell script |
| 192 | const auto tty = m_tty->getSlave(); |
| 193 | const auto options = QString(QLatin1String(">") + tty + QLatin1String(" 2>&1 <") + tty); |
| 194 | |
| 195 | const QStringList arguments { |
| 196 | QStringLiteral("-c"), |
| 197 | KShell::quoteArg(runShellScript.toLocalFile()) + QLatin1Char(' ') + KShell::quoteArg(executable) + options, |
| 198 | }; |
| 199 | |
| 200 | qCDebug(DEBUGGERGDB) << "starting sh" << arguments; |
| 201 | QProcess::startDetached(QStringLiteral("sh"), arguments); |
| 202 | } |
| 203 | |
| 204 | if (runGdbScript.isValid()) { |
| 205 | // Special for remote debug, gdb script at run is requested, to connect to remote inferior |
| 206 | |
| 207 | // Race notice: wait for the remote gdbserver/executable |
| 208 | // - but that might be an issue for this script to handle... |
| 209 | |
| 210 | // Note: script could contain "run" or "continue" |
| 211 | |
| 212 | // Future: the shell script should be able to pass info (like pid) |
| 213 | // to the gdb script... |
| 214 | |
| 215 | addCommand(std::make_unique<SentinelCommand>( |
| 216 | [this, runGdbScript]() { |
| 217 | breakpointController()->initSendBreakpoints(); |
| 218 | |
| 219 | breakpointController()->setDeleteDuplicateBreakpoints(true); |
| 220 | qCDebug(DEBUGGERGDB) << "Running gdb script " << KShell::quoteArg(runGdbScript.toLocalFile()); |
| 221 | |
| 222 | addCommand( |
| 223 | MI::NonMI, QLatin1String("source ") + runGdbScript.toLocalFile(), |
| 224 | [this](const MI::ResultRecord&) { breakpointController()->setDeleteDuplicateBreakpoints(false); }, |
| 225 | CmdMaybeStartsRunning); |
| 226 | raiseEvent(connected_to_program); |
| 227 | }, |
| 228 | CmdMaybeStartsRunning)); |
| 229 | } else { |
| 230 | // normal local debugging |
| 231 | addFileExecAndSymbolsCommand(KShell::quoteArg(executable)); |
| 232 | raiseEvent(connected_to_program); |
nothing calls this directly
no test coverage detected