diff --git a/src/plugins/debugger/cdb/cdbdebugengine.cpp b/src/plugins/debugger/cdb/cdbdebugengine.cpp index 157fd66b2ae..e9f4967b397 100644 --- a/src/plugins/debugger/cdb/cdbdebugengine.cpp +++ b/src/plugins/debugger/cdb/cdbdebugengine.cpp @@ -307,6 +307,7 @@ CdbDebugEnginePrivate::CdbDebugEnginePrivate(DebuggerManager *manager, m_currentThreadId(-1), m_eventThreadId(-1), m_interruptArticifialThreadId(-1), + m_ignoreInitialBreakPoint(false), m_interrupted(false), m_watchTimer(-1), m_debugEventCallBack(engine), @@ -661,6 +662,7 @@ void CdbDebugEngine::startDebugger(const QSharedPointer bool needWatchTimer = false; m_d->clearForRun(); m_d->setCodeLevel(); + m_d->m_ignoreInitialBreakPoint = false; switch (mode) { case AttachExternal: case AttachCrashedExternal: @@ -670,6 +672,8 @@ void CdbDebugEngine::startDebugger(const QSharedPointer case StartInternal: case StartExternal: if (sp->useTerminal) { + // Attaching to console processes triggers an initial breakpoint, which we do not want + m_d->m_ignoreInitialBreakPoint = true; // Launch console stub and wait for its startup m_d->m_consoleStubProc.stop(); // We leave the console open, so recycle it now. m_d->m_consoleStubProc.setWorkingDirectory(sp->workingDir); @@ -704,6 +708,8 @@ bool CdbDebugEngine::startAttachDebugger(qint64 pid, DebuggerStartMode sm, QStri // Need to attrach invasively, otherwise, no notification signals // for for CreateProcess/ExitProcess occur. // As of version 6.11, the initial breakpoint suppression has no effect (see notifyException). + // when attaching to a console process starting up. However, there is no initial breakpoint + // (and no startup trap), when attaching to a running GUI process. const ULONG flags = DEBUG_ATTACH_INVASIVE_RESUME_PROCESS|DEBUG_ATTACH_INVASIVE_NO_INITIAL_BREAK; const HRESULT hr = m_d->m_cif.debugClient->AttachProcess(NULL, pid, flags); if (debugCDB) @@ -1669,14 +1675,14 @@ void CdbDebugEnginePrivate::notifyException(long code, bool fatal) if (debugCDBExecution) qDebug() << "notifyException code" << code << " fatal=" << fatal; // Suppress the initial breakpoint that occurs when - // attaching (If a breakpoint is encountered before startup - // is complete). + // attaching to a console (If a breakpoint is encountered before startup + // is complete, see startAttachDebugger()). switch (code) { case winExceptionStartupCompleteTrap: m_inferiorStartupComplete = true; break; case EXCEPTION_BREAKPOINT: - if (!m_inferiorStartupComplete && m_breakEventMode == BreakEventHandle) { + if (m_ignoreInitialBreakPoint && !m_inferiorStartupComplete && m_breakEventMode == BreakEventHandle) { manager()->showDebuggerOutput(LogMisc, CdbDebugEngine::tr("Ignoring initial breakpoint...")); m_breakEventMode = BreakEventIgnoreOnce; } diff --git a/src/plugins/debugger/cdb/cdbdebugengine_p.h b/src/plugins/debugger/cdb/cdbdebugengine_p.h index e52ddadef5c..31df174b072 100644 --- a/src/plugins/debugger/cdb/cdbdebugengine_p.h +++ b/src/plugins/debugger/cdb/cdbdebugengine_p.h @@ -161,6 +161,7 @@ struct CdbDebugEnginePrivate int m_currentThreadId; int m_eventThreadId; int m_interruptArticifialThreadId; + bool m_ignoreInitialBreakPoint; HandleBreakEventMode m_breakEventMode; int m_watchTimer;