From 97a2cc53cfc7dcb1fa2e8ec2e50c57e4d274f0c5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@nokia.com> Date: Fri, 5 Aug 2011 17:42:32 +0200 Subject: [PATCH] Debugger[CDB]: Implement AttachCore for debugdiag dumps. Change-Id: I19c57248ed5e7c43b14b849419c9edf29bca26dc Reviewed-on: http://codereview.qt.nokia.com/2706 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> --- src/plugins/debugger/cdb/cdbengine.cpp | 43 +++++++++++++++++++------ src/plugins/debugger/cdb/cdbengine.h | 1 + src/plugins/debugger/debuggerrunner.cpp | 5 +++ 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 7daf735da24..ba13c1dc978 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -316,7 +316,6 @@ static inline bool validMode(DebuggerStartMode sm) { switch (sm) { case NoStartMode: - case AttachCore: case StartRemoteGdb: return false; default: @@ -394,6 +393,12 @@ bool checkCdbConfiguration(const DebuggerStartParameters &sp, ConfigurationCheck return false; } + if (sp.toolChainAbi.osFlavor() == Abi::WindowsMSysFlavor + && sp.startMode == AttachCore) { + check->errorDetails.push_back(CdbEngine::tr("The CDB debug engine cannot debug MSys core files.")); + return false; + } + if (cdbBinary(sp).isEmpty()) { check->errorDetails.push_back(msgNoCdbBinaryForToolChain(sp.toolChainAbi)); check->settingsCategory = QLatin1String(ProjectExplorer::Constants::TOOLCHAIN_SETTINGS_CATEGORY); @@ -479,6 +484,7 @@ void CdbEngine::init() m_pendingBreakpointMap.clear(); m_customSpecialStopData.clear(); m_symbolAddressCache.clear(); + m_coreStopReason.reset(); // Create local list of mappings in native separators m_sourcePathMappings.clear(); @@ -769,6 +775,9 @@ bool CdbEngine::launchCDB(const DebuggerStartParameters &sp, QString *errorMessa arguments << QLatin1String("-pr") << QLatin1String("-pb"); } break; + case AttachCore: + arguments << QLatin1String("-z") << sp.coreFile; + break; default: *errorMessage = QString::fromLatin1("Internal error: Unsupported start mode %1.").arg(sp.startMode); return false; @@ -845,7 +854,13 @@ void CdbEngine::runEngine() qDebug("runEngine"); foreach (const QString &breakEvent, m_options->breakEvents) postCommand(QByteArray("sxe ") + breakEvent.toAscii(), 0); - postCommand("g", 0); + if (startParameters().startMode == AttachCore) { + QTC_ASSERT(!m_coreStopReason.isNull(), return; ); + notifyInferiorUnrunnable(); + processStop(*m_coreStopReason, false); + } else { + postCommand("g", 0); + } } bool CdbEngine::commandsPending() const @@ -1766,8 +1781,10 @@ void CdbEngine::reloadFullStack() void CdbEngine::handlePid(const CdbExtensionCommandPtr &reply) { - if (reply->success) { + // Fails for core dumps. + if (reply->success) notifyInferiorPid(reply->reply.toULongLong()); + if (reply->success || startParameters().startMode == AttachCore) { STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorSetupOk") notifyInferiorSetupOk(); } else { @@ -2107,8 +2124,14 @@ void CdbEngine::handleSessionIdle(const QByteArray &messageBA) if (state() == EngineSetupRequested) { // Temporary stop at beginning STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyEngineSetupOk") notifyEngineSetupOk(); + // Store stop reason to be handled in runEngine(). + if (startParameters().startMode == AttachCore) { + m_coreStopReason.reset(new GdbMi); + m_coreStopReason->fromString(messageBA); + } return; } + GdbMi stopReason; stopReason.fromString(messageBA); processStop(stopReason, false); @@ -2136,12 +2159,14 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT } // Notify about state and send off command sequence to get stack, etc. if (stopFlags & StopNotifyStop) { - if (state() == InferiorStopRequested) { - STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorStopOk") - notifyInferiorStopOk(); - } else { - STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorSpontaneousStop") - notifyInferiorSpontaneousStop(); + if (startParameters().startMode != AttachCore) { + if (state() == InferiorStopRequested) { + STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorStopOk") + notifyInferiorStopOk(); + } else { + STATE_DEBUG(state(), Q_FUNC_INFO, __LINE__, "notifyInferiorSpontaneousStop") + notifyInferiorSpontaneousStop(); + } } // Prevent further commands from being sent if shutdown is in progress if (stopFlags & StopShutdownInProgress) { diff --git a/src/plugins/debugger/cdb/cdbengine.h b/src/plugins/debugger/cdb/cdbengine.h index 9c21dd4b0a8..7c52c7d03f3 100644 --- a/src/plugins/debugger/cdb/cdbengine.h +++ b/src/plugins/debugger/cdb/cdbengine.h @@ -282,6 +282,7 @@ private: bool m_ignoreCdbOutput; QVariantList m_customSpecialStopData; QList<SourcePathMapping> m_sourcePathMappings; + QScopedPointer<GdbMi> m_coreStopReason; }; } // namespace Internal diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index 32413966394..db00eaaa670 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -449,6 +449,11 @@ static QList<DebuggerEngineType> enginesForMode(DebuggerStartMode startMode, } break; case AttachCore: +#ifdef Q_OS_WIN + result.push_back(CdbEngineType); +#endif + result.push_back(GdbEngineType); + break; case StartRemoteGdb: result.push_back(GdbEngineType); break; -- GitLab