diff --git a/src/plugins/debugger/debuggeragents.cpp b/src/plugins/debugger/debuggeragents.cpp index 4d5963e185dee26bb703a2bd299481e61a4a631f..36ac56f46aef4e9f5a0fe782a8aa59d9b42779bc 100644 --- a/src/plugins/debugger/debuggeragents.cpp +++ b/src/plugins/debugger/debuggeragents.cpp @@ -457,6 +457,8 @@ void DisassemblerViewAgent::updateBreakpointMarkers() if (!address) continue; const int lineNumber = contents.lineForAddress(address); + if (!lineNumber) + continue; BreakpointMarker2 *marker = new BreakpointMarker2(handler->icon(id)); d->breakpointMarks.append(marker); d->editor->markableInterface()->addMark(marker, lineNumber); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 92235c17f02f45c8d586546e70fa1057b5e33a70..eed5fba3ad91d411c6f60338343a5771460b0c6c 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -2156,25 +2156,22 @@ QByteArray GdbEngine::breakpointLocation(BreakpointId id) return "__cxa_begin_catch"; if (data.type == BreakpointAtMain) #ifdef Q_OS_WIN + // FIXME: Should be target specific. return "qMain"; #else return "main"; #endif - const QByteArray functionName = data.functionName.toUtf8(); - if (!functionName.isEmpty()) - return functionName; - if (const quint64 address = data.address) - return addressSpec(address); - // In this case, data->funcName is something like '*0xdeadbeef' - const int lineNumber = data.lineNumber; - if (lineNumber == 0) - return functionName; + if (data.type == BreakpointByFunction) + return data.functionName.toUtf8(); + if (data.type == BreakpointByAddress) + return addressSpec(data.address); + const QString fileName = data.useFullPath ? data.fileName : breakLocation(data.fileName); // The argument is simply a C-quoted version of the argument to the // non-MI "break" command, including the "original" quoting it wants. return "\"\\\"" + GdbMi::escapeCString(fileName).toLocal8Bit() + "\\\":" - + QByteArray::number(lineNumber) + '"'; + + QByteArray::number(data.lineNumber) + '"'; } void GdbEngine::handleWatchInsert(const GdbResponse &response) @@ -2211,7 +2208,7 @@ void GdbEngine::attemptAdjustBreakpointLocation(BreakpointId id) void GdbEngine::handleBreakInsert1(const GdbResponse &response) { - const int id = response.cookie.toInt(); + BreakpointId id(response.cookie.toInt()); if (response.resultClass == GdbResultDone) { // Interesting only on Mac? GdbMi bkpt = response.data.findChild("bkpt"); @@ -2695,8 +2692,8 @@ void GdbEngine::removeBreakpoint(BreakpointId id) QTC_ASSERT(handler->state(id) == BreakpointRemoveRequested, /**/); handler->notifyBreakpointRemoveProceeding(id); BreakpointResponse br = handler->response(id); - showMessage(_("DELETING BP %1 IN ").arg(br.number) - + handler->fileName(id)); + showMessage(_("DELETING BP %1 IN %2").arg(br.number) + .arg(handler->fileName(id))); postCommand("-break-delete " + QByteArray::number(br.number), NeedsStop | RebuildBreakpointModel); // Pretend it succeeds without waiting for response. Feels better. diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index 814a43e7c72861e7b3bf6481849c5b15fd443525..71bbd80a1b939d08320b0ba981a458c183115fef 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -302,7 +302,6 @@ private: ////////// Gdb Output, State & Capability Handling ////////// private: ////////// Inferior Management ////////// // This should be always the last call in a function. - //Q_SLOT virtual void attemptBreakpointSynchronization(); bool stateAcceptsBreakpointChanges() const; bool acceptsBreakpoint(BreakpointId id) const; void insertBreakpoint(BreakpointId id); diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index d64e9fde7208199231d11ffe68d89fd405be5fe5..5150a1adee1b6bce095ff8b90e99d67aa0fd9fbb 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -326,43 +326,26 @@ void PdbEngine::selectThread(int index) Q_UNUSED(index) } -void PdbEngine::attemptBreakpointSynchronization() +bool PdbEngine::acceptsBreakpoint(BreakpointId id) const +{ + const QString fileName = breakHandler()->fileName(id); + return fileName.endsWith(QLatin1String(".py")); +} + +void PdbEngine::insertBreakpoint(BreakpointId id) { BreakHandler *handler = breakHandler(); - //qDebug() << "ATTEMPT BP SYNC"; - bool updateNeeded = false; - foreach (BreakpointId id, handler->engineBreakpointIds(this)) { - if (handler->state(id) == BreakpointInsertRequested) { - handler->notifyBreakpointInsertOk(id); - updateNeeded = true; - - QByteArray loc; - if (!handler->functionName(id).isEmpty()) - loc = handler->functionName(id).toLatin1(); - // The argument is simply a C-quoted version of the argument to the - // non-MI "break" command, including the "original" quoting it wants. - //return "\"\\\"" + GdbMi::escapeCString(data->fileName).toLocal8Bit() - // + "\\\":" + data->lineNumber + '"'; - else - loc = handler->fileName(id).toLocal8Bit() + ':' - + QByteArray::number(handler->lineNumber(id)); - - postCommand("break " + loc, CB(handleBreakInsert), QVariant(id)); - } -/* - if (data->bpNumber.isEmpty()) { - data->bpNumber = QByteArray::number(index + 1); - updateNeeded = true; - } - if (!data->fileName.isEmpty() && data->markerFileName().isEmpty()) { - data->setMarkerFileName(data->fileName); - data->setMarkerLineNumber(data->lineNumber.toInt()); - updateNeeded = true; - } -*/ - } - //if (updateNeeded) - // handler->updateMarkers(); + QTC_ASSERT(handler->state(id) == BreakpointInsertRequested, /**/); + handler->notifyBreakpointInsertProceeding(id); + + QByteArray loc; + if (handler->type(id) == BreakpointByFunction) + loc = handler->functionName(id).toLatin1(); + else + loc = handler->fileName(id).toLocal8Bit() + ':' + + QByteArray::number(handler->lineNumber(id)); + + postCommand("break " + loc, CB(handleBreakInsert), QVariant(id)); } void PdbEngine::handleBreakInsert(const PdbResponse &response) @@ -385,6 +368,19 @@ void PdbEngine::handleBreakInsert(const PdbResponse &response) handler->setResponse(id, br); } +void PdbEngine::removeBreakpoint(BreakpointId id) +{ + BreakHandler *handler = breakHandler(); + QTC_ASSERT(handler->state(id) == BreakpointRemoveRequested, /**/); + handler->notifyBreakpointRemoveProceeding(id); + BreakpointResponse br = handler->response(id); + showMessage(_("DELETING BP %1 IN %2").arg(br.number) + .arg(handler->fileName(id))); + postCommand("clear " + QByteArray::number(br.number)); + // Pretend it succeeds without waiting for response. + handler->notifyBreakpointRemoveOk(id); +} + void PdbEngine::loadSymbols(const QString &moduleName) { Q_UNUSED(moduleName) diff --git a/src/plugins/debugger/pdb/pdbengine.h b/src/plugins/debugger/pdb/pdbengine.h index c65509ba6fc5d4691d82cfc30a3ff5fb20f14dce..c3acb0122891327aec5345df2e42eb1e22e6e6db 100644 --- a/src/plugins/debugger/pdb/pdbengine.h +++ b/src/plugins/debugger/pdb/pdbengine.h @@ -88,9 +88,12 @@ private: void activateFrame(int index); void selectThread(int index); - void attemptBreakpointSynchronization(); + bool acceptsBreakpoint(BreakpointId id) const; + void insertBreakpoint(BreakpointId id); + void removeBreakpoint(BreakpointId id); - void assignValueInDebugger(const Internal::WatchData *w, const QString &expr, const QVariant &value); + void assignValueInDebugger(const WatchData *data, + const QString &expr, const QVariant &value); void executeDebuggerCommand(const QString &command); void loadSymbols(const QString &moduleName); diff --git a/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp b/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp index 81a486f3ce3ba492b7eab7758d4493965f7b4413..54b3cae5470da373f2a29aa826d6e46f90041659 100644 --- a/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp +++ b/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp @@ -1539,7 +1539,9 @@ QVariant testQVariant2() *(QString*)value.data() = QString("XXX"); int i = 1; - Q_UNUSED(i); + ++i; + ++i; + ++i; #if 1 QVariant var; var.setValue(1);