forked from qt-creator/qt-creator
Debugger: Support gz core unpacking
Change-Id: If69b890484ea27c8c35c77936186d183b8b47b98 Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
7fffe3cef6
commit
d6da0901eb
@@ -67,6 +67,8 @@ GdbCoreEngine::~GdbCoreEngine()
|
||||
m_coreUnpackProcess->terminate();
|
||||
m_coreUnpackProcess->deleteLater();
|
||||
m_coreUnpackProcess = 0;
|
||||
if (m_tempCoreFile.isOpen())
|
||||
m_tempCoreFile.close();
|
||||
}
|
||||
if (!m_tempCoreName.isEmpty()) {
|
||||
QFile tmpFile(m_tempCoreName);
|
||||
@@ -126,6 +128,8 @@ void GdbCoreEngine::continueSetupEngine()
|
||||
isCore = m_coreUnpackProcess->exitCode() == 0;
|
||||
m_coreUnpackProcess->deleteLater();
|
||||
m_coreUnpackProcess = 0;
|
||||
if (m_tempCoreFile.isOpen())
|
||||
m_tempCoreFile.close();
|
||||
}
|
||||
if (isCore && m_executable.isEmpty()) {
|
||||
// Read executable from core.
|
||||
@@ -156,6 +160,11 @@ void GdbCoreEngine::continueSetupEngine()
|
||||
}
|
||||
}
|
||||
|
||||
void GdbCoreEngine::writeCoreChunk()
|
||||
{
|
||||
m_tempCoreFile.write(m_coreUnpackProcess->readAll());
|
||||
}
|
||||
|
||||
void GdbCoreEngine::setupInferior()
|
||||
{
|
||||
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
||||
@@ -233,26 +242,40 @@ void GdbCoreEngine::shutdownEngine()
|
||||
notifyAdapterShutdownOk();
|
||||
}
|
||||
|
||||
static QString tempCoreFilename()
|
||||
{
|
||||
QString pattern = QDir::tempPath() + QLatin1String("/tmpcore-XXXXXX");
|
||||
QTemporaryFile tmp(pattern);
|
||||
tmp.open();
|
||||
return tmp.fileName();
|
||||
}
|
||||
|
||||
void GdbCoreEngine::unpackCoreIfNeeded()
|
||||
{
|
||||
if (!m_coreName.endsWith(QLatin1String(".lzo"))) {
|
||||
continueSetupEngine();
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
QString pattern = QDir::tempPath() + QLatin1String("/tmpcore-XXXXXX");
|
||||
QTemporaryFile tmp(pattern, this);
|
||||
tmp.open();
|
||||
m_tempCoreName = tmp.fileName();
|
||||
}
|
||||
|
||||
QStringList arguments;
|
||||
arguments << QLatin1String("-o") << m_tempCoreName << QLatin1String("-x") << m_coreName;
|
||||
m_coreUnpackProcess = new QProcess(this);
|
||||
m_coreUnpackProcess->setWorkingDirectory(QDir::tempPath());
|
||||
m_coreUnpackProcess->start(QLatin1String("lzop"), arguments);
|
||||
connect(m_coreUnpackProcess, SIGNAL(finished(int)), SLOT(continueSetupEngine()));
|
||||
const QString msg = _("Unpacking core file to %1");
|
||||
if (m_coreName.endsWith(QLatin1String(".lzo"))) {
|
||||
m_tempCoreName = tempCoreFilename();
|
||||
showMessage(msg.arg(m_tempCoreName));
|
||||
arguments << QLatin1String("-o") << m_tempCoreName << QLatin1String("-x") << m_coreName;
|
||||
m_coreUnpackProcess = new QProcess(this);
|
||||
m_coreUnpackProcess->setWorkingDirectory(QDir::tempPath());
|
||||
m_coreUnpackProcess->start(QLatin1String("lzop"), arguments);
|
||||
connect(m_coreUnpackProcess, SIGNAL(finished(int)), SLOT(continueSetupEngine()));
|
||||
} else if (m_coreName.endsWith(QLatin1String(".gz"))) {
|
||||
m_tempCoreName = tempCoreFilename();
|
||||
showMessage(msg.arg(m_tempCoreName));
|
||||
m_tempCoreFile.setFileName(m_tempCoreName);
|
||||
m_tempCoreFile.open(QFile::WriteOnly);
|
||||
arguments << QLatin1String("-c") << QLatin1String("-d") << m_coreName;
|
||||
m_coreUnpackProcess = new QProcess(this);
|
||||
m_coreUnpackProcess->setWorkingDirectory(QDir::tempPath());
|
||||
m_coreUnpackProcess->start(QLatin1String("gzip"), arguments);
|
||||
connect(m_coreUnpackProcess, SIGNAL(readyRead()), SLOT(writeCoreChunk()));
|
||||
connect(m_coreUnpackProcess, SIGNAL(finished(int)), SLOT(continueSetupEngine()));
|
||||
} else {
|
||||
continueSetupEngine();
|
||||
}
|
||||
}
|
||||
|
||||
QString GdbCoreEngine::coreFileName() const
|
||||
|
@@ -33,6 +33,8 @@
|
||||
#include "gdbengine.h"
|
||||
#include "localgdbprocess.h"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
@@ -66,15 +68,20 @@ private:
|
||||
void handleRoundTrip(const GdbResponse &response);
|
||||
void unpackCoreIfNeeded();
|
||||
QString coreFileName() const;
|
||||
Q_SLOT void continueSetupEngine();
|
||||
QString readExecutableNameFromCore(bool *isCore);
|
||||
QString coreName() const;
|
||||
|
||||
private slots:
|
||||
void continueSetupEngine();
|
||||
void writeCoreChunk();
|
||||
|
||||
private:
|
||||
QString m_executable;
|
||||
QString m_coreName;
|
||||
LocalGdbProcess m_gdbProc;
|
||||
QString m_tempCoreName;
|
||||
QProcess *m_coreUnpackProcess;
|
||||
QFile m_tempCoreFile;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user