diff --git a/src/plugins/debugger/gdb/coregdbadapter.cpp b/src/plugins/debugger/gdb/coregdbadapter.cpp index 90f77262b80..00ff8628398 100644 --- a/src/plugins/debugger/gdb/coregdbadapter.cpp +++ b/src/plugins/debugger/gdb/coregdbadapter.cpp @@ -88,13 +88,44 @@ void GdbCoreEngine::setupEngine() unpackCoreIfNeeded(); } +QString GdbCoreEngine::readExecutableNameFromCore(bool *isCore) +{ +#if 0 + ElfReader reader(coreFileName()); + return QString::fromLocal8Bit(reader.readCoreName(isCore)); +#else + const DebuggerStartParameters &sp = startParameters(); + QStringList args; + args.append(QLatin1String("-nx")); + args.append(QLatin1String("-batch")); + args.append(QLatin1String("-c")); + args.append(coreFileName()); + QProcess proc; + proc.start(sp.debuggerCommand, args); + if (proc.waitForFinished()) { + QByteArray ba = proc.readAllStandardOutput(); + // Core was generated by `/data/dev/creator-2.6/bin/qtcreator'. + // Program terminated with signal 11, Segmentation fault. + int pos1 = ba.indexOf("Core was generated by"); + if (pos1 != -1) { + pos1 += 23; + int pos2 = ba.indexOf('\'', pos1); + if (pos2 != -1) { + *isCore = true; + return QString::fromLocal8Bit(ba.mid(pos1, pos2 - pos1)); + } + } + } + return QString(); +#endif +} + void GdbCoreEngine::continueSetupEngine() { if (m_executable.isEmpty()) { // Read executable from core. - ElfReader reader(coreFileName()); bool isCore = false; - m_executable = QString::fromLocal8Bit(reader.readCoreName(&isCore)); + m_executable = readExecutableNameFromCore(&isCore); if (!isCore) { showMessageBox(QMessageBox::Warning, diff --git a/src/plugins/debugger/gdb/coregdbadapter.h b/src/plugins/debugger/gdb/coregdbadapter.h index 1027fffbbf4..269d7857e14 100644 --- a/src/plugins/debugger/gdb/coregdbadapter.h +++ b/src/plugins/debugger/gdb/coregdbadapter.h @@ -68,6 +68,7 @@ private: void unpackCoreIfNeeded(); QString coreFileName() const; Q_SLOT void continueSetupEngine(); + QString readExecutableNameFromCore(bool *isCore); QString coreName() const; QString m_executable;