diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 1606f5c098611b2b9b6f58787a7090f31b6e3728..d0ea4ba83abd4bddb9eda1a363805fcea33e7603 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -2264,7 +2264,26 @@ bool CdbEngine::stateAcceptsBreakpointChanges() const bool CdbEngine::acceptsBreakpoint(BreakpointId id) const { - return DebuggerEngine::isCppBreakpoint(breakHandler()->breakpointData(id)); + const BreakpointParameters &data = breakHandler()->breakpointData(id); + if (!DebuggerEngine::isCppBreakpoint(data)) + return false; + switch (data.type) { + case UnknownType: + case BreakpointAtFork: + case BreakpointAtVFork: + case BreakpointAtSysCall: + return false; + case Watchpoint: + case BreakpointByFileAndLine: + case BreakpointByFunction: + case BreakpointByAddress: + case BreakpointAtThrow: + case BreakpointAtCatch: + case BreakpointAtMain: + case BreakpointAtExec: + break; + } + return true; } void CdbEngine::attemptBreakpointSynchronization() diff --git a/src/plugins/debugger/cdb/cdbparsehelpers.cpp b/src/plugins/debugger/cdb/cdbparsehelpers.cpp index 94776e3b39a6fbceb3f8bdab37fdc94260317534..09b20f0b4759e2661d1d907e6b28f5b8a9e47dd0 100644 --- a/src/plugins/debugger/cdb/cdbparsehelpers.cpp +++ b/src/plugins/debugger/cdb/cdbparsehelpers.cpp @@ -94,18 +94,49 @@ static inline QString cdbBreakPointFileName(const BreakpointParameters &bp, return cdbSourcePathMapping(QDir::toNativeSeparators(bp.fileName), sourcePathMapping, SourceToDebugger); } -// Convert breakpoint in CDB syntax. (applying source path mappings using native paths). +static BreakpointParameters fixWinMSVCBreakpoint(const BreakpointParameters &p) +{ + switch (p.type) { + case UnknownType: + case BreakpointByFileAndLine: + case BreakpointByFunction: + case BreakpointByAddress: + case BreakpointAtFork: + case BreakpointAtVFork: + case BreakpointAtSysCall: + case Watchpoint: + break; + case BreakpointAtExec: { // Emulate by breaking on CreateProcessW(). + BreakpointParameters rc(BreakpointByFunction); + rc.module = QLatin1String("kernel32"); + rc.functionName = QLatin1String("CreateProcessW"); + return rc; + } + case BreakpointAtThrow: { + BreakpointParameters rc(BreakpointByFunction); + rc.functionName = QLatin1String("CxxThrowException"); // MSVC runtime. Potentially ambiguous. + return rc; + } + case BreakpointAtCatch: { + BreakpointParameters rc(BreakpointByFunction); + rc.functionName = QLatin1String("__CxxCallCatchBlock"); // MSVC runtime. Potentially ambiguous. + return rc; + } + case BreakpointAtMain: { + BreakpointParameters rc(BreakpointByFunction); + rc.functionName = QLatin1String("main"); + return rc; + } + } // switch + return p; +} + QByteArray cdbAddBreakpointCommand(const BreakpointParameters &bpIn, const QList<QPair<QString, QString> > &sourcePathMapping, BreakpointId id /* = BreakpointId(-1) */, bool oneshot) { -#ifdef Q_OS_WIN const BreakpointParameters bp = fixWinMSVCBreakpoint(bpIn); -#else - const BreakpointParameters bp = bpIn; -#endif - QByteArray rc; ByteArrayInputStream str(rc); @@ -121,6 +152,10 @@ QByteArray cdbAddBreakpointCommand(const BreakpointParameters &bpIn, if (oneshot) str << "/1 "; switch (bp.type) { + case BreakpointAtFork: + case BreakpointAtExec: + case BreakpointAtVFork: + case BreakpointAtSysCall: case UnknownType: case BreakpointAtCatch: case BreakpointAtThrow: @@ -141,7 +176,7 @@ QByteArray cdbAddBreakpointCommand(const BreakpointParameters &bpIn, str << bp.module << '!'; str << cdbBreakPointFileName(bp, sourcePathMapping) << ':' << bp.lineNumber << '`'; break; - case Watchpoint: + case Watchpoint: // Read/write 1 byte str << "rw 1 " << hex << hexPrefixOn << bp.address << hexPrefixOff << dec; break; } diff --git a/src/plugins/debugger/shared/dbgwinutils.cpp b/src/plugins/debugger/shared/dbgwinutils.cpp index 42e557fde516ef2767dd1f3146567822d5927b77..50d7f4d786a08f7e02906a7e643b58226fc14245 100644 --- a/src/plugins/debugger/shared/dbgwinutils.cpp +++ b/src/plugins/debugger/shared/dbgwinutils.cpp @@ -389,29 +389,5 @@ bool isFatalWinException(long code) return true; } -// Special function names in MSVC runtime -const char *winMSVCThrowFunction = "CxxThrowException"; -const char *winMSVCCatchFunction = "__CxxCallCatchBlock"; - -BreakpointParameters fixWinMSVCBreakpoint(const BreakpointParameters &p) -{ - if (p.type == BreakpointAtThrow) { - BreakpointParameters rc(BreakpointByFunction); - rc.functionName = QLatin1String(winMSVCThrowFunction); - return rc; - } - if (p.type == BreakpointAtCatch) { - BreakpointParameters rc(BreakpointByFunction); - rc.functionName = QLatin1String(winMSVCCatchFunction); - return rc; - } - if (p.type == BreakpointAtMain) { - BreakpointParameters rc(BreakpointByFunction); - rc.functionName = QLatin1String("main"); - return rc; - } - return p; -} - } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/shared/dbgwinutils.h b/src/plugins/debugger/shared/dbgwinutils.h index 7b4f3ba5b205f5f03674b636d7507d3dfa5ccdba..ce22035d98e4e905de9ac59a8078fc39e45f3909 100644 --- a/src/plugins/debugger/shared/dbgwinutils.h +++ b/src/plugins/debugger/shared/dbgwinutils.h @@ -42,8 +42,6 @@ QT_FORWARD_DECLARE_CLASS(QTextStream) namespace Debugger { namespace Internal { -class BreakpointParameters; - struct ProcData; // debuggerdialogs, used by the process listing dialogs QList<ProcData> winProcessList(); @@ -92,13 +90,6 @@ bool isFatalWinException(long code); // Check for EXCEPTION_BREAKPOINT, EXCEPTION_SINGLE_STEP bool isDebuggerWinException(long code); -// fix up breakpoints (catch/throw, etc). -BreakpointParameters fixWinMSVCBreakpoint(const BreakpointParameters &p); - -// Special function names in MSVC runtime -extern const char *winMSVCThrowFunction; -extern const char *winMSVCCatchFunction; - } // namespace Internal } // namespace Debugger