| 74 | } |
| 75 | |
| 76 | bool ReverseDebugger::execCommand(const dpfservice::RunCommandInfo &info) |
| 77 | { |
| 78 | bool ret = false; |
| 79 | |
| 80 | auto target = info.program; |
| 81 | if (target.isEmpty() || !QFile::exists(target)) { |
| 82 | emit recordFailed(tr("target not found!")); |
| 83 | return ret; |
| 84 | } |
| 85 | |
| 86 | QProcess process; |
| 87 | process.setWorkingDirectory(info.workingDir); |
| 88 | process.setEnvironment(info.envs); |
| 89 | |
| 90 | auto program = "rr"; |
| 91 | QStringList arguments; |
| 92 | arguments.append("record"); |
| 93 | arguments.append(info.program); |
| 94 | arguments.append(info.arguments); |
| 95 | |
| 96 | connect(&process, &QProcess::readyReadStandardOutput, [&]() { |
| 97 | process.setReadChannel(QProcess::StandardOutput); |
| 98 | while (process.canReadLine()) { |
| 99 | QString line = QString::fromUtf8(process.readLine()); |
| 100 | outputMsg(process.pid(), line, OutputPane::OutputFormat::StdOut); |
| 101 | } |
| 102 | }); |
| 103 | |
| 104 | connect(&process, &QProcess::readyReadStandardError, [&]() { |
| 105 | process.setReadChannel(QProcess::StandardError); |
| 106 | while (process.canReadLine()) { |
| 107 | QString line = QString::fromUtf8(process.readLine()); |
| 108 | outputMsg(process.pid(), line, OutputPane::OutputFormat::StdErr); |
| 109 | } |
| 110 | }); |
| 111 | |
| 112 | process.start(program, arguments); |
| 113 | uiController.switchContext(tr("&Application Output")); |
| 114 | quint64 pid = process.pid(); |
| 115 | QString startMsg = tr("Start execute command: \"%1\" \"%2\" in workspace \"%3\".\n") |
| 116 | .arg(program, arguments.join(" "), info.workingDir); |
| 117 | QMetaObject::invokeMethod(AppOutputPane::instance(), "createApplicationPane", |
| 118 | Q_ARG(const QString &, QString::number(pid)), Q_ARG(QString, program)); |
| 119 | outputMsg(pid, startMsg, OutputPane::OutputFormat::NormalMessage); |
| 120 | process.waitForFinished(); |
| 121 | |
| 122 | AppOutputPane::instance()->setProcessFinished(QString::number(pid)); |
| 123 | |
| 124 | emit recordDone(); |
| 125 | |
| 126 | return ret; |
| 127 | } |
| 128 | |
| 129 | void ReverseDebugger::outputMsg(const quint64 &pid, const QString &content, OutputPane::OutputFormat format) |
| 130 | { |
nothing calls this directly
no test coverage detected