From 01cb4ee21db0bdc9ecedc499bff94799624fed68 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 26 Feb 2015 15:04:02 +0100 Subject: [PATCH] Debugger: Fix soft assert when loading core file Task-number: QTCREATORBUG-14048 Change-Id: I20d4d8269df3bfb42259ad459b92d5cd738332f5 Reviewed-by: Christian Stenger --- src/plugins/debugger/gdb/coregdbadapter.cpp | 46 +++++++++------------ src/plugins/debugger/gdb/gdbengine.cpp | 2 +- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/plugins/debugger/gdb/coregdbadapter.cpp b/src/plugins/debugger/gdb/coregdbadapter.cpp index aeb404a06ac..4c1027a5872 100644 --- a/src/plugins/debugger/gdb/coregdbadapter.cpp +++ b/src/plugins/debugger/gdb/coregdbadapter.cpp @@ -223,27 +223,29 @@ void GdbCoreEngine::handleFileExecAndSymbols(const DebuggerResponse &response) QString core = coreFileName(); if (response.resultClass == ResultDone) { showMessage(tr("Symbols found."), StatusBar); - postCommand("target core " + core.toLocal8Bit(), NoFlags, - CB(handleTargetCore)); - return; + handleInferiorPrepared(); + } else { + QString msg = tr("No symbols found in core file %1.").arg(core) + + _(" ") + tr("This can be caused by a path length limitation " + "in the core file.") + + _(" ") + tr("Try to specify the binary using the " + "Debug->Start Debugging->Attach to Core dialog."); + notifyInferiorSetupFailed(msg); } - QString msg = tr("No symbols found in core file %1.") - .arg(core); - msg += _(" "); - msg += tr("This can be caused by a path length limitation in the " - "core file."); - msg += _(" "); - msg += tr("Try to specify the binary using the " - "Debug->Start Debugging->Attach to Core dialog."); - notifyInferiorSetupFailed(msg); +} + +void GdbCoreEngine::runEngine() +{ + QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); + postCommand("target core " + coreFileName().toLocal8Bit(), NoFlags, CB(handleTargetCore)); } void GdbCoreEngine::handleTargetCore(const DebuggerResponse &response) { - QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state()); + QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); + notifyInferiorUnrunnable(); if (response.resultClass == ResultDone) { showMessage(tr("Attached to core."), StatusBar); - handleInferiorPrepared(); // Due to the auto-solib-add off setting, we don't have any // symbols yet. Load them in order of importance. reloadStack(); @@ -251,27 +253,19 @@ void GdbCoreEngine::handleTargetCore(const DebuggerResponse &response) postCommand("p 5", NoFlags, CB(handleRoundTrip)); return; } - QString msg = tr("Attach to core \"%1\" failed:") - .arg(startParameters().coreFile) - + QLatin1Char('\n') - + QString::fromLocal8Bit(response.data["msg"].data()); - notifyInferiorSetupFailed(msg); + showStatusMessage(tr("Attach to core \"%1\" failed:").arg(startParameters().coreFile) + + QLatin1Char('\n') + QString::fromLocal8Bit(response.data["msg"].data())); + notifyEngineIll(); } void GdbCoreEngine::handleRoundTrip(const DebuggerResponse &response) { Q_UNUSED(response); loadSymbolsForStack(); + handleStop2(); QTimer::singleShot(1000, this, SLOT(loadAllSymbols())); } -void GdbCoreEngine::runEngine() -{ - QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); - notifyInferiorUnrunnable(); - updateAll(); -} - void GdbCoreEngine::interruptInferior() { // A core never runs, so this cannot be called. diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 815a003364f..38d800b48af 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -1230,7 +1230,7 @@ void GdbEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages flushCommand(cmd); } -// This is called from CoreAdapter and AttachAdapter. +// This is triggered when switching snapshots. void GdbEngine::updateAll() { //PENDING_DEBUG("UPDATING ALL\n");