Debugger: Support gz core unpacking

Change-Id: If69b890484ea27c8c35c77936186d183b8b47b98
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Orgad Shaneh
2013-06-09 09:27:38 +03:00
committed by Orgad Shaneh
parent 7fffe3cef6
commit d6da0901eb
2 changed files with 48 additions and 18 deletions

View File

@@ -67,6 +67,8 @@ GdbCoreEngine::~GdbCoreEngine()
m_coreUnpackProcess->terminate(); m_coreUnpackProcess->terminate();
m_coreUnpackProcess->deleteLater(); m_coreUnpackProcess->deleteLater();
m_coreUnpackProcess = 0; m_coreUnpackProcess = 0;
if (m_tempCoreFile.isOpen())
m_tempCoreFile.close();
} }
if (!m_tempCoreName.isEmpty()) { if (!m_tempCoreName.isEmpty()) {
QFile tmpFile(m_tempCoreName); QFile tmpFile(m_tempCoreName);
@@ -126,6 +128,8 @@ void GdbCoreEngine::continueSetupEngine()
isCore = m_coreUnpackProcess->exitCode() == 0; isCore = m_coreUnpackProcess->exitCode() == 0;
m_coreUnpackProcess->deleteLater(); m_coreUnpackProcess->deleteLater();
m_coreUnpackProcess = 0; m_coreUnpackProcess = 0;
if (m_tempCoreFile.isOpen())
m_tempCoreFile.close();
} }
if (isCore && m_executable.isEmpty()) { if (isCore && m_executable.isEmpty()) {
// Read executable from core. // Read executable from core.
@@ -156,6 +160,11 @@ void GdbCoreEngine::continueSetupEngine()
} }
} }
void GdbCoreEngine::writeCoreChunk()
{
m_tempCoreFile.write(m_coreUnpackProcess->readAll());
}
void GdbCoreEngine::setupInferior() void GdbCoreEngine::setupInferior()
{ {
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
@@ -233,26 +242,40 @@ void GdbCoreEngine::shutdownEngine()
notifyAdapterShutdownOk(); notifyAdapterShutdownOk();
} }
static QString tempCoreFilename()
{
QString pattern = QDir::tempPath() + QLatin1String("/tmpcore-XXXXXX");
QTemporaryFile tmp(pattern);
tmp.open();
return tmp.fileName();
}
void GdbCoreEngine::unpackCoreIfNeeded() 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; QStringList arguments;
arguments << QLatin1String("-o") << m_tempCoreName << QLatin1String("-x") << m_coreName; const QString msg = _("Unpacking core file to %1");
m_coreUnpackProcess = new QProcess(this); if (m_coreName.endsWith(QLatin1String(".lzo"))) {
m_coreUnpackProcess->setWorkingDirectory(QDir::tempPath()); m_tempCoreName = tempCoreFilename();
m_coreUnpackProcess->start(QLatin1String("lzop"), arguments); showMessage(msg.arg(m_tempCoreName));
connect(m_coreUnpackProcess, SIGNAL(finished(int)), SLOT(continueSetupEngine())); 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 QString GdbCoreEngine::coreFileName() const

View File

@@ -33,6 +33,8 @@
#include "gdbengine.h" #include "gdbengine.h"
#include "localgdbprocess.h" #include "localgdbprocess.h"
#include <QFile>
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
@@ -66,15 +68,20 @@ private:
void handleRoundTrip(const GdbResponse &response); void handleRoundTrip(const GdbResponse &response);
void unpackCoreIfNeeded(); void unpackCoreIfNeeded();
QString coreFileName() const; QString coreFileName() const;
Q_SLOT void continueSetupEngine();
QString readExecutableNameFromCore(bool *isCore); QString readExecutableNameFromCore(bool *isCore);
QString coreName() const; QString coreName() const;
private slots:
void continueSetupEngine();
void writeCoreChunk();
private:
QString m_executable; QString m_executable;
QString m_coreName; QString m_coreName;
LocalGdbProcess m_gdbProc; LocalGdbProcess m_gdbProc;
QString m_tempCoreName; QString m_tempCoreName;
QProcess *m_coreUnpackProcess; QProcess *m_coreUnpackProcess;
QFile m_tempCoreFile;
}; };
} // namespace Internal } // namespace Internal