From bf1f351f29e65ff39baf65f4475d01efc72fd313 Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Thu, 18 Nov 2010 12:30:56 +0100 Subject: [PATCH] debugger: first step to re-enable breakpoint location update. --- src/plugins/debugger/breakhandler.cpp | 8 ++++- src/plugins/debugger/breakpoint.cpp | 4 ++- src/plugins/debugger/breakpoint.h | 1 + src/plugins/debugger/gdb/gdbengine.cpp | 50 ++++++++++++++++---------- 4 files changed, 43 insertions(+), 20 deletions(-) diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index a2f09490321..5c2102a09aa 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -529,9 +529,14 @@ void BreakHandler::setMarkerFileAndLine(BreakpointId id, { Iterator it = m_storage.find(id); QTC_ASSERT(it != m_storage.end(), return); + if (it->markerFileName == fileName && it->markerLineNumber == lineNumber) + return; it->markerFileName = fileName; it->markerLineNumber = lineNumber; + it->response.fileName = fileName; + it->response.lineNumber = lineNumber; updateMarker(id); + scheduleSynchronization(); } BreakpointState BreakHandler::state(BreakpointId id) const @@ -569,7 +574,8 @@ static bool isAllowedTransition(BreakpointState from, BreakpointState to) return to == BreakpointInsertProceeding; case BreakpointInsertProceeding: return to == BreakpointInserted - || to == BreakpointDead; + || to == BreakpointDead + || to == BreakpointChangeRequested; case BreakpointChangeRequested: return to == BreakpointChangeProceeding; case BreakpointChangeProceeding: diff --git a/src/plugins/debugger/breakpoint.cpp b/src/plugins/debugger/breakpoint.cpp index c79fde07880..0215d975ec3 100644 --- a/src/plugins/debugger/breakpoint.cpp +++ b/src/plugins/debugger/breakpoint.cpp @@ -92,7 +92,7 @@ QString BreakpointParameters::toString() const ////////////////////////////////////////////////////////////////// BreakpointResponse::BreakpointResponse() - : number(0), pending(true), multiple(false) + : number(0), pending(true), multiple(false), correctedLineNumber(0) {} QString BreakpointResponse::toString() const @@ -104,6 +104,7 @@ QString BreakpointResponse::toString() const ts << fullName; ts << multiple; ts << extra; + ts << correctedLineNumber; return result + BreakpointParameters::toString(); } @@ -114,6 +115,7 @@ void BreakpointResponse::fromParameters(const BreakpointParameters &p) fullName.clear(); multiple = false; extra.clear(); + correctedLineNumber = 0; } } // namespace Internal diff --git a/src/plugins/debugger/breakpoint.h b/src/plugins/debugger/breakpoint.h index 85b2f25de6f..e2d4b66f74f 100644 --- a/src/plugins/debugger/breakpoint.h +++ b/src/plugins/debugger/breakpoint.h @@ -113,6 +113,7 @@ public: QString fullName; // Full file name acknowledged by the debugger engine. bool multiple; // Happens in constructors/gdb. QByteArray extra; // gdb: <PENDING>, <MULTIPLE> + int correctedLineNumber; }; typedef QList<BreakpointId> BreakpointIds; diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 04f02d6fb34..0573ffaef8f 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -1163,6 +1163,22 @@ void GdbEngine::handleStopResponse(const GdbMi &data) return; } + const int bkptno = data.findChild("bkptno").data().toInt(); + const GdbMi frame = data.findChild("frame"); + + if (bkptno && frame.isValid()) { + // Use opportunity to update the marker position. + const QString fileName = + QString::fromUtf8(frame.findChild("fullname").data()); + const int lineNumber = frame.findChild("line").data().toInt(); + qDebug() << "HIT " << fileName << lineNumber; + if (!fileName.isEmpty()) { + BreakHandler *handler = breakHandler(); + BreakpointId id = handler->findBreakpointByNumber(bkptno); + handler->setMarkerFileAndLine(id, fileName, lineNumber); + } + } + if (!m_commandsToRunOnTemporaryBreak.isEmpty()) { QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state()) notifyInferiorStopOk(); @@ -1226,8 +1242,7 @@ void GdbEngine::handleStopResponse(const GdbMi &data) // FIXME: Replace the #ifdef by the "target" architecture #ifdef Q_OS_LINUX if (!m_entryPoint.isEmpty()) { - GdbMi frameData = data.findChild("frame"); - if (frameData.findChild("addr").data() == m_entryPoint) { + if (frame.findChild("addr").data() == m_entryPoint) { // There are two expected reasons for getting here: // 1) For some reason, attaching to a stopped process causes *two* SIGSTOPs // when trying to continue (kernel i386 2.6.24-23-ubuntu, gdb 6.8). @@ -2170,6 +2185,7 @@ void GdbEngine::handleBreakInsert1(const GdbResponse &response) // Interesting only on Mac? GdbMi bkpt = response.data.findChild("bkpt"); updateBreakpointDataFromOutput(id, bkpt); + //attempAdjustBreakpointLocation(id); } else { // Some versions of gdb like "GNU gdb (GDB) SUSE (6.8.91.20090930-2.4)" // know how to do pending breakpoints using CLI but not MI. So try @@ -2608,31 +2624,29 @@ void GdbEngine::changeBreakpoint(BreakpointId id) NeedsStop | RebuildBreakpointModel, CB(handleBreakEnable), id); } -/* - if (data.threadSpec() != response.bpThreadSpec) + + if (data.threadSpec != response.threadSpec) { // The only way to change this seems to be to re-set the bp completely. - //qDebug() << "FIXME: THREAD: " << data.threadSpec << response.bpThreadSpec; - FIXME - data.setThreadSpec.clear(); - postCommand("-break-delete " + bpnr, - NeedsStop | RebuildBreakpointModel); - sendInsertBreakpoint(index); - continue; + qDebug() << "FIXME: THREAD: " << data.threadSpec << response.threadSpec; + //response.threadSpec.clear(); + //postCommand("-break-delete " + bpnr, + // NeedsStop | RebuildBreakpointModel); + //sendInsertBreakpoint(index); + //continue; } -*/ -/* - if (data->bpAddress && data->bpCorrectedLineNumber == 0) { + if (response.address && response.correctedLineNumber == 0) { // Prevent endless loop. - data->bpCorrectedLineNumber = -1; + BreakpointResponse r = response; + r.correctedLineNumber = -1; + breakHandler()->setResponse(id, r); if (debuggerCore()->boolSetting(AdjustBreakpointLocations)) { postCommand( - "info line *0x" + QByteArray::number(data->bpAddress, 16), + "info line *0x" + QByteArray::number(response.address, 16), NeedsStop | RebuildBreakpointModel, - CB(handleInfoLine), id) + CB(handleInfoLine), id); } } -*/ } void GdbEngine::removeBreakpoint(BreakpointId id) -- GitLab