Debugger: Improve core unpacking

* Delete process when finished
* Handle unpack failure
* Support lzop on Windows (if available)

Change-Id: I8d95b77922c8b22b5874dffd8f935ff184902e12
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Orgad Shaneh
2013-06-09 09:05:47 +03:00
committed by Orgad Shaneh
parent 46171f5470
commit 5b115fe9ae
2 changed files with 42 additions and 27 deletions

View File

@@ -56,12 +56,19 @@ namespace Internal {
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
GdbCoreEngine::GdbCoreEngine(const DebuggerStartParameters &startParameters) GdbCoreEngine::GdbCoreEngine(const DebuggerStartParameters &startParameters)
: GdbEngine(startParameters) : GdbEngine(startParameters),
m_coreUnpackProcess(0)
{} {}
GdbCoreEngine::~GdbCoreEngine() GdbCoreEngine::~GdbCoreEngine()
{ {
if (false && !m_tempCoreName.isEmpty()) { if (m_coreUnpackProcess) {
m_coreUnpackProcess->blockSignals(true);
m_coreUnpackProcess->terminate();
m_coreUnpackProcess->deleteLater();
m_coreUnpackProcess = 0;
}
if (!m_tempCoreName.isEmpty()) {
QFile tmpFile(m_tempCoreName); QFile tmpFile(m_tempCoreName);
tmpFile.remove(); tmpFile.remove();
} }
@@ -114,32 +121,39 @@ QString GdbCoreEngine::readExecutableNameFromCore(bool *isCore)
void GdbCoreEngine::continueSetupEngine() void GdbCoreEngine::continueSetupEngine()
{ {
if (m_executable.isEmpty()) { bool isCore = true;
if (m_coreUnpackProcess) {
isCore = m_coreUnpackProcess->exitCode() == 0;
m_coreUnpackProcess->deleteLater();
m_coreUnpackProcess = 0;
}
if (isCore && m_executable.isEmpty()) {
// Read executable from core. // Read executable from core.
bool isCore = false; isCore = false;
m_executable = readExecutableNameFromCore(&isCore); m_executable = readExecutableNameFromCore(&isCore);
if (!isCore) { if (isCore) {
showMessageBox(QMessageBox::Warning, // Strip off command line arguments. FIXME: make robust.
tr("Error Loading Core File"), int idx = m_executable.indexOf(QLatin1Char(' '));
tr("The specified file does not appear to be a core file.")); if (idx >= 0)
notifyEngineSetupFailed(); m_executable.truncate(idx);
return; if (m_executable.isEmpty()) {
} showMessageBox(QMessageBox::Warning,
tr("Error Loading Symbols"),
// Strip off command line arguments. FIXME: make robust. tr("No executable to load symbols from specified core."));
int idx = m_executable.indexOf(QLatin1Char(' ')); notifyEngineSetupFailed();
if (idx >= 0) return;
m_executable.truncate(idx); }
if (m_executable.isEmpty()) {
showMessageBox(QMessageBox::Warning,
tr("Error Loading Symbols"),
tr("No executable to load symbols from specified core."));
notifyEngineSetupFailed();
return;
} }
} }
startGdb(); if (isCore)
startGdb();
else {
showMessageBox(QMessageBox::Warning,
tr("Error Loading Core File"),
tr("The specified file does not appear to be a core file."));
notifyEngineSetupFailed();
}
} }
void GdbCoreEngine::setupInferior() void GdbCoreEngine::setupInferior()
@@ -233,12 +247,12 @@ void GdbCoreEngine::unpackCoreIfNeeded()
m_tempCoreName = tmp.fileName(); m_tempCoreName = tmp.fileName();
} }
QProcess *process = new QProcess(this);
process->setWorkingDirectory(QDir::tempPath());
QStringList arguments; QStringList arguments;
arguments << QLatin1String("-o") << m_tempCoreName << QLatin1String("-x") << m_coreName; arguments << QLatin1String("-o") << m_tempCoreName << QLatin1String("-x") << m_coreName;
process->start(QLatin1String("/usr/bin/lzop"), arguments); m_coreUnpackProcess = new QProcess(this);
connect(process, SIGNAL(finished(int)), SLOT(continueSetupEngine())); m_coreUnpackProcess->setWorkingDirectory(QDir::tempPath());
m_coreUnpackProcess->start(QLatin1String("lzop"), arguments);
connect(m_coreUnpackProcess, SIGNAL(finished(int)), SLOT(continueSetupEngine()));
} }
QString GdbCoreEngine::coreFileName() const QString GdbCoreEngine::coreFileName() const

View File

@@ -74,6 +74,7 @@ private:
QString m_coreName; QString m_coreName;
LocalGdbProcess m_gdbProc; LocalGdbProcess m_gdbProc;
QString m_tempCoreName; QString m_tempCoreName;
QProcess *m_coreUnpackProcess;
}; };
} // namespace Internal } // namespace Internal