File indexing completed on 2024-05-12 05:29:10

0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0002 
0003 #include "coredumpexcavator.h"
0004 
0005 #include <QDebug>
0006 #include <QProcess>
0007 
0008 using namespace Qt::StringLiterals;
0009 
0010 void CoredumpExcavator::excavateFromTo(const QString &coreFile, const QString &coreFileTarget)
0011 {
0012     auto proc = new QProcess(this);
0013     proc->setProcessChannelMode(QProcess::ForwardedChannels);
0014     proc->setProgram("coredumpctl"_L1);
0015     proc->setArguments({"--output"_L1, coreFileTarget, "dump"_L1, "COREDUMP_FILENAME=%1"_L1.arg(coreFile)});
0016     qDebug() << "excavating" << proc->arguments();
0017     QObject::connect(proc, &QProcess::finished, this, [this, coreFileTarget, proc](int exitCode, QProcess::ExitStatus exitStatus) mutable {
0018         qDebug() << "Core dump excavation complete" << exitCode << exitStatus << coreFileTarget;
0019         proc->deleteLater();
0020         Q_EMIT excavated(exitCode);
0021     });
0022     proc->start();
0023 }