Commit d6da0901 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

Debugger: Support gz core unpacking

Change-Id: If69b890484ea27c8c35c77936186d183b8b47b98
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 7fffe3ce
......@@ -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"))) {
QStringList arguments;
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();
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()));
}
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment