OSDN Git Service

debugger: make "threadspec" an int instead of a bytearray
authorhjk <qtc-committer@nokia.com>
Tue, 30 Nov 2010 12:39:01 +0000 (13:39 +0100)
committerhjk <qtc-committer@nokia.com>
Tue, 30 Nov 2010 12:40:23 +0000 (13:40 +0100)
src/plugins/debugger/breakhandler.cpp
src/plugins/debugger/breakhandler.h
src/plugins/debugger/breakpoint.cpp
src/plugins/debugger/breakpoint.h
src/plugins/debugger/breakwindow.cpp
src/plugins/debugger/cdb/cdbbreakpoint.cpp
src/plugins/debugger/cdb2/cdbparsehelpers.cpp
src/plugins/debugger/gdb/gdbengine.cpp

index 751a57e..eff89e5 100644 (file)
@@ -255,7 +255,7 @@ void BreakHandler::saveBreakpoints()
             map.insert(_("condition"), data.condition);
         if (data.ignoreCount)
             map.insert(_("ignorecount"), data.ignoreCount);
-        if (!data.threadSpec.isEmpty())
+        if (data.threadSpec)
             map.insert(_("threadspec"), data.threadSpec);
         if (!data.enabled)
             map.insert(_("disabled"), _("1"));
@@ -294,7 +294,7 @@ void BreakHandler::loadBreakpoints()
             data.ignoreCount = v.toString().toInt();
         v = map.value(_("threadspec"));
         if (v.isValid())
-            data.threadSpec = v.toString().toLatin1();
+            data.threadSpec = v.toString().toInt();
         v = map.value(_("funcname"));
         if (v.isValid())
             data.functionName = v.toString();
@@ -375,6 +375,11 @@ Qt::ItemFlags BreakHandler::flags(const QModelIndex &index) const
 //    }
 }
 
+static QString threadString(int spec)
+{
+    return spec == 0 ? BreakHandler::tr("(all)") : QString::number(spec);
+}
+
 QVariant BreakHandler::data(const QModelIndex &mi, int role) const
 {
     static const QString empty = QString(QLatin1Char('-'));
@@ -488,11 +493,8 @@ QVariant BreakHandler::data(const QModelIndex &mi, int role) const
                 return data.ignoreCount;
             break;
         case 7:
-            if (role == Qt::DisplayRole) {
-                if (orig)
-                    return !data.threadSpec.isEmpty() ? data.threadSpec : tr("(all)");
-                return !response.threadSpec.isEmpty() ? response.threadSpec : tr("(all)");
-            }
+            if (role == Qt::DisplayRole)
+                return threadString(orig ? data.threadSpec : response.threadSpec);
             if (role == Qt::ToolTipRole)
                 return tr("Breakpoint will only be hit in the specified thread(s).");
             if (role == Qt::UserRole + 1)
@@ -538,7 +540,7 @@ PROPERTY(bool, useFullPath, setUseFullPath)
 PROPERTY(QString, fileName, setFileName)
 PROPERTY(QString, functionName, setFunctionName)
 PROPERTY(BreakpointType, type, setType)
-PROPERTY(QByteArray, threadSpec, setThreadSpec)
+PROPERTY(int, threadSpec, setThreadSpec)
 PROPERTY(QByteArray, condition, setCondition)
 GETTER(int, lineNumber)
 PROPERTY(quint64, address, setAddress)
@@ -745,10 +747,10 @@ void BreakHandler::notifyBreakpointAdjusted(BreakpointId id,
 
 void BreakHandler::notifyBreakpointNeedsReinsertion(BreakpointId id)
 {
-    QTC_ASSERT(state(id) == BreakpointInserted, qDebug() << state(id));
+    QTC_ASSERT(state(id) == BreakpointChangeProceeding, qDebug() << state(id));
     Iterator it = m_storage.find(id);
     QTC_ASSERT(it != m_storage.end(), return);
-    it->state = BreakpointNew;
+    it->state = BreakpointInsertRequested;
 }
 
 void BreakHandler::removeBreakpoint(BreakpointId id)
index 36d78c8..383e8b0 100644 (file)
@@ -107,8 +107,8 @@ public:
     void setCondition(BreakpointId, const QByteArray &condition);
     int ignoreCount(BreakpointId id) const;
     void setIgnoreCount(BreakpointId, const int &count);
-    QByteArray threadSpec(BreakpointId id) const;
-    void setThreadSpec(BreakpointId, const QByteArray &spec);
+    int threadSpec(BreakpointId id) const;
+    void setThreadSpec(BreakpointId, const int&spec);
     QString fileName(BreakpointId id) const;
     void setFileName(BreakpointId, const QString &fileName);
     QString functionName(BreakpointId id) const;
index e92721b..0d510c0 100644 (file)
@@ -43,7 +43,7 @@ namespace Internal {
 
 BreakpointParameters::BreakpointParameters(BreakpointType t)
   : type(t), enabled(true), useFullPath(false),
-    ignoreCount(0), lineNumber(0), address(0)
+    ignoreCount(0), lineNumber(0), address(0), threadSpec(0)
 {}
 
 bool BreakpointParameters::equals(const BreakpointParameters &rhs) const
index 6f17f44..7db0e01 100644 (file)
@@ -91,7 +91,7 @@ public:
     int ignoreCount;         // Ignore count associated with breakpoint.
     int lineNumber;          // Line in source file.
     quint64 address;         // Address for watchpoints.
-    QByteArray threadSpec;   // Thread specification.
+    int threadSpec;          // Thread specification.
     QString functionName;
 };
 
index 4904175..310578d 100644 (file)
@@ -141,7 +141,7 @@ void BreakpointDialog::setParameters(const BreakpointParameters &data)
     setParts(AllParts, data);
     m_ui.lineEditCondition->setText(QString::fromUtf8(data.condition));
     m_ui.lineEditIgnoreCount->setText(QString::number(data.ignoreCount));
-    m_ui.lineEditThreadSpec->setText(data.threadSpec);
+    m_ui.lineEditThreadSpec->setText(QString::number(data.threadSpec));
 }
 
 BreakpointParameters BreakpointDialog::parameters() const
@@ -150,7 +150,7 @@ BreakpointParameters BreakpointDialog::parameters() const
     getParts(AllParts, &data);
     data.condition = m_ui.lineEditCondition->text().toUtf8();
     data.ignoreCount = m_ui.lineEditIgnoreCount->text().toInt();
-    data.threadSpec = m_ui.lineEditThreadSpec->text().toUtf8();
+    data.threadSpec = m_ui.lineEditThreadSpec->text().toInt();
     return data;
 }
 
@@ -564,7 +564,7 @@ void BreakWindow::editBreakpoints(const BreakpointIds &ids)
     BreakHandler *handler = breakHandler();
     const QString oldCondition = QString::fromLatin1(handler->condition(id));
     const QString oldIgnoreCount = QString::number(handler->ignoreCount(id));
-    const QString oldThreadSpec = QString::fromLatin1(handler->threadSpec(id));
+    const QString oldThreadSpec = QString::number(handler->threadSpec(id));
 
     ui.lineEditCondition->setText(oldCondition);
     ui.lineEditIgnoreCount->setText(oldIgnoreCount);
@@ -584,16 +584,15 @@ void BreakWindow::editBreakpoints(const BreakpointIds &ids)
     foreach (const BreakpointId id, ids) {
         handler->setCondition(id, newCondition.toLatin1());
         handler->setIgnoreCount(id, newIgnoreCount.toInt());
-        handler->setThreadSpec(id, newThreadSpec.toLatin1());
+        handler->setThreadSpec(id, newThreadSpec.toInt());
     }
 }
 
 void BreakWindow::associateBreakpoint(const BreakpointIds &ids, int threadId)
 {
     BreakHandler *handler = breakHandler();
-    QByteArray spec = QByteArray::number(threadId);
     foreach (const BreakpointId id, ids)
-        handler->setThreadSpec(id, spec);
+        handler->setThreadSpec(id, threadId);
 }
 
 void BreakWindow::resizeColumnsToContents()
index 52536c6..771791b 100644 (file)
@@ -49,12 +49,7 @@ static CdbCore::BreakPoint breakPointFromBreakPointData(const BreakpointParamete
                   CdbCore::BreakPoint::Code ;
 
     rc.address = bpd.address;
-    if (!bpd.threadSpec.isEmpty()) {
-        bool ok;
-        rc.threadId = bpd.threadSpec.toInt(&ok);
-        if (!ok)
-            qWarning("Cdb: Cannot convert breakpoint thread specification '%s'", bpd.threadSpec.constData());
-    }
+    rc.threadId = bpd.threadSpec;
     rc.fileName = QDir::toNativeSeparators(bpd.fileName);
     rc.condition = bpd.condition;
     rc.funcName = functionName.isEmpty() ? bpd.functionName : functionName;
index b69b899..d13926d 100644 (file)
@@ -62,7 +62,7 @@ QByteArray cdbAddBreakpointCommand(const Debugger::Internal::BreakpointParameter
     QByteArray rc;
     ByteArrayInputStream str(rc);
 
-    if (!bp.threadSpec.isEmpty())
+    if (bp.threadSpec > 0)
         str << '~' << bp.threadSpec << ' ';
 
     str << (bp.type == Debugger::Internal::Watchpoint ? "ba" : "bp");
index 5a04bbf..fb6e841 100644 (file)
@@ -2091,7 +2091,7 @@ void GdbEngine::updateBreakpointDataFromOutput(BreakpointId id, const GdbMi &bkp
                 ba = ba.mid(1, ba.size() - 2);
             response.functionName = _(ba);
         } else if (child.hasName("thread")) {
-            response.threadSpec = child.data();
+            response.threadSpec = child.data().toInt();
         } else if (child.hasName("type")) {
             if (!child.data().contains("reakpoint")) // "breakpoint", "hw breakpoint"
                 response.type = Watchpoint;
@@ -2337,12 +2337,11 @@ void GdbEngine::handleBreakThreadSpec(const GdbResponse &response)
     QTC_ASSERT(response.resultClass == GdbResultDone, /**/)
     const BreakpointId id = response.cookie.toInt();
     BreakHandler *handler = breakHandler();
-    handler->notifyBreakpointChangeOk(id);
-    handler->notifyBreakpointNeedsReinsertion(id);
     BreakpointResponse br = handler->response(id);
     br.threadSpec = handler->threadSpec(id);
     handler->setResponse(id, br);
-    changeBreakpoint(id); // Maybe there's more to do.
+    handler->notifyBreakpointNeedsReinsertion(id);
+    insertBreakpoint(id);
 }
 
 void GdbEngine::handleBreakIgnore(const GdbResponse &response)
@@ -2377,7 +2376,6 @@ void GdbEngine::handleBreakCondition(const GdbResponse &response)
     // Can happen at invalid condition strings.
     //QTC_ASSERT(response.resultClass == GdbResultDone, /**/)
     const BreakpointId id = response.cookie.toInt();
-    qDebug() << "CONDITION FOR" << id;
     BreakHandler *handler = breakHandler();
     // We just assume it was successful. Otherwise we had to parse
     // the output stream data.
@@ -2518,10 +2516,10 @@ void GdbEngine::insertBreakpoint(BreakpointId id)
     } else if (m_gdbAdapter->isTrkAdapter()) {
         cmd = "-break-insert -h -f ";
     } else if (m_gdbVersion >= 70000) {
-        QByteArray spec = handler->threadSpec(id);
+        int spec = handler->threadSpec(id);
         cmd = "-break-insert ";
-        if (!spec.isEmpty())
-            cmd += "-p " + spec;
+        if (spec)
+            cmd += "-p " + QByteArray::number(spec);
         cmd += " -f ";
     } else if (m_gdbVersion >= 60800) {
         // Probably some earlier version would work as well.
@@ -2551,6 +2549,13 @@ void GdbEngine::changeBreakpoint(BreakpointId id)
     const BreakpointState state2 = handler->state(id);
     QTC_ASSERT(state2 == BreakpointChangeProceeding, qDebug() << state2);
 
+    if (data.threadSpec != response.threadSpec) {
+        // The only way to change this seems to be to re-set the bp completely.
+        postCommand("-break-delete " + bpnr,
+            NeedsStop | RebuildBreakpointModel,
+            CB(handleBreakThreadSpec), id);
+        return;
+    }
     if (!data.conditionsMatch(response.condition)) {
         postCommand("condition " + bpnr + ' '  + data.condition,
             NeedsStop | RebuildBreakpointModel,
@@ -2575,14 +2580,6 @@ void GdbEngine::changeBreakpoint(BreakpointId id)
             CB(handleBreakEnable), id);
         return;
     }
-    if (data.threadSpec != response.threadSpec) {
-        // The only way to change this seems to be to re-set the bp completely.
-        postCommand("-break-delete " + bpnr,
-            NeedsStop | RebuildBreakpointModel,
-            CB(handleBreakThreadSpec), id);
-        return;
-    }
-
     handler->notifyBreakpointChangeOk(id);
     attemptAdjustBreakpointLocation(id);
 }