diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index c77f081c9d1..4f7b722c7a0 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -201,6 +201,7 @@ GdbEngine::GdbEngine(const DebuggerStartParameters &startParameters, m_gdbVersion = 100; m_gdbBuildVersion = -1; m_isMacGdb = false; + m_hasBreakpointNotifications = false; m_hasPython = false; m_registerNamesListed = false; m_hasInferiorThreadList = false; @@ -468,10 +469,23 @@ void GdbEngine::handleResponse(const QByteArray &buff) if (!isQmlStepBreakpoint1(number) && isQmlStepBreakpoint2(number)) { BreakpointId id = breakHandler()->findBreakpointByNumber(number); updateBreakpointDataFromOutput(id, bkpt); - BreakpointResponse response = breakHandler()->response(id); - if (response.correctedLineNumber == 0) - attemptAdjustBreakpointLocation(id); + attemptAdjustBreakpointLocation(id); } + } else if (asyncClass == "breakpoint-modified") { + // New in FSF gdb since 2011-04-27. + // "{bkpt={number="2",type="breakpoint",disp="keep",enabled="y", + // addr="0x014e0e34",func="Myns::qFatal(char const*, ...)", + // file="global/qglobal.cpp",fullname="/data/dev/...cpp", + // line="2534",times="0",script={"return"}, + // original-location="'Myns::qFatal'"}}" + const GdbMi bkpt = result.findChild("bkpt"); + const int number = bkpt.findChild("number").data().toInt(); + if (!isQmlStepBreakpoint1(number) && isQmlStepBreakpoint2(number)) { + BreakpointId id = breakHandler()->findBreakpointByNumber(number); + updateBreakpointDataFromOutput(id, bkpt); + attemptAdjustBreakpointLocation(id); + } + m_hasBreakpointNotifications = true; } else { qDebug() << "IGNORED ASYNC OUTPUT" << asyncClass << result.toString(); @@ -1539,7 +1553,8 @@ void GdbEngine::handleStop1(const GdbMi &data) const quint64 bpAddress = wpt.findChild("exp").data().mid(1).toULongLong(0, 0); QString msg; if (id && breakHandler()->type(id) == WatchpointAtExpression) - msg = msgWatchpointByExpressionTriggered(id, bpNumber, breakHandler()->expression(id)); + msg = msgWatchpointByExpressionTriggered(id, bpNumber, + breakHandler()->expression(id)); if (id && breakHandler()->type(id) == WatchpointAtAddress) msg = msgWatchpointByAddressTriggered(id, bpNumber, bpAddress); GdbMi value = data.findChild("value"); @@ -1643,6 +1658,9 @@ void GdbEngine::handleShowVersion(const GdbResponse &response) showMessage(_("USING GDB VERSION: %1, BUILD: %2%3").arg(m_gdbVersion) .arg(m_gdbBuildVersion).arg(_(m_isMacGdb ? " (APPLE)" : ""))); + + if (m_gdbVersion > 70300) + m_hasBreakpointNotifications = true; } } @@ -2395,6 +2413,8 @@ void GdbEngine::handleWatchInsert(const GdbResponse &response) void GdbEngine::attemptAdjustBreakpointLocation(BreakpointId id) { + if (m_hasBreakpointNotifications) + return; if (!debuggerCore()->boolSetting(AdjustBreakpointLocations)) return; BreakpointResponse response = breakHandler()->response(id); @@ -2433,8 +2453,7 @@ void GdbEngine::handleBreakInsert1(const GdbResponse &response) handler->notifyBreakpointInsertOk(id); } BreakpointResponse bresponse = handler->response(id); - if (bresponse.correctedLineNumber == 0) - attemptAdjustBreakpointLocation(id); + attemptAdjustBreakpointLocation(id); if (bresponse.multiple && bresponse.addresses.isEmpty()) postCommand("info break " + QByteArray::number(bresponse.number), NeedsStop, CB(handleBreakListMultiple), QVariant(id)); @@ -2480,8 +2499,11 @@ void GdbEngine::handleTraceInsert2(const GdbResponse &response) void GdbEngine::reloadBreakListInternal() { - postCommand("-break-list", - NeedsStop | RebuildBreakpointModel, + if (m_hasBreakpointNotifications) { + // Assume this properly handles breakpoint notifications. + return; + } + postCommand("-break-list", NeedsStop | RebuildBreakpointModel, CB(handleBreakList)); } @@ -2531,9 +2553,8 @@ void GdbEngine::handleBreakList(const GdbMi &table) BreakpointId id = breakHandler()->findSimilarBreakpoint(needle); if (id != BreakpointId(-1)) { updateBreakpointDataFromOutput(id, bkpt); + attemptAdjustBreakpointLocation(id); BreakpointResponse response = breakHandler()->response(id); - if (response.correctedLineNumber == 0) - attemptAdjustBreakpointLocation(id); if (response.multiple && response.addresses.isEmpty()) postCommand("info break " + QByteArray::number(response.number), NeedsStop, CB(handleBreakListMultiple), QVariant(id)); @@ -2697,18 +2718,6 @@ void GdbEngine::extractDataFromInfoBreak(const QString &output, BreakpointId id) breakHandler()->setResponse(id, response); } -void GdbEngine::handleBreakInfo(const GdbResponse &response) -{ - if (response.resultClass == GdbResultDone) { - // Old-style output for multiple breakpoints, presumably in a - // constructor. - const BreakpointId id(response.cookie.toInt()); - const QString str = QString::fromLocal8Bit( - response.data.findChild("consolestreamoutput").data()); - extractDataFromInfoBreak(str, id); - } -} - void GdbEngine::handleInfoLine(const GdbResponse &response) { if (response.resultClass == GdbResultDone) { diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index cf950ad8b8b..aa97124afbf 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -442,6 +442,7 @@ private: ////////// Gdb Output, State & Capability Handling ////////// int m_gdbVersion; // 6.8.0 is 60800 int m_gdbBuildVersion; // MAC only? bool m_isMacGdb; + bool m_hasBreakpointNotifications; bool m_hasPython; bool m_hasInferiorThreadList; @@ -502,7 +503,6 @@ private: ////////// View & Data Stuff ////////// void handleBreakInsert2(const GdbResponse &response); void handleTraceInsert2(const GdbResponse &response); void handleBreakCondition(const GdbResponse &response); - void handleBreakInfo(const GdbResponse &response); void handleBreakThreadSpec(const GdbResponse &response); void handleWatchInsert(const GdbResponse &response); void handleCatchInsert(const GdbResponse &response); diff --git a/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp b/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp index 0f3b2c3a77d..0203b5d2b96 100644 --- a/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp +++ b/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp @@ -144,6 +144,8 @@ private: namespace nsX { namespace nsY { int z; +Vector vi(10); +Vector vf(10); } }