OSDN Git Service

debugger: disable address related breakpoints on debugger exit
authorhjk <qtc-committer@nokia.com>
Wed, 11 May 2011 13:24:50 +0000 (15:24 +0200)
committerhjk <qtc-committer@nokia.com>
Wed, 11 May 2011 13:24:50 +0000 (15:24 +0200)
src/plugins/debugger/breakhandler.cpp
src/plugins/debugger/breakhandler.h
src/plugins/debugger/gdb/gdbengine.cpp
src/plugins/debugger/gdb/gdbmi.cpp
src/plugins/debugger/watchdata.cpp

index 0e73359..e6418cf 100644 (file)
@@ -303,9 +303,6 @@ void BreakHandler::saveBreakpoints()
     for ( ; it != et; ++it) {
         const BreakpointParameters &data = it->data;
         QMap<QString, QVariant> map;
-        // Do not persist Watchpoints.
-        if (data.isWatchpoint())
-            continue;
         if (data.type != BreakpointByFileAndLine)
             map.insert(_("type"), data.type);
         if (!data.fileName.isEmpty())
@@ -332,6 +329,8 @@ void BreakHandler::saveBreakpoints()
             map.insert(_("module"), data.module);
         if (!data.command.isEmpty())
             map.insert(_("command"), data.command);
+        if (!data.expression.isEmpty())
+            map.insert(_("expression"), data.expression);
         list.append(map);
     }
     debuggerCore()->setSessionValue("Breakpoints", list);
@@ -387,6 +386,9 @@ void BreakHandler::loadBreakpoints()
         v = map.value(_("command"));
         if (v.isValid())
             data.command = v.toString();
+        v = map.value(_("expression"));
+        if (v.isValid())
+            data.expression = v.toString();
         appendBreakpoint(data);
     }
     //qDebug() << "LOADED BREAKPOINTS" << this << list.size();
@@ -521,9 +523,9 @@ QVariant BreakHandler::data(const QModelIndex &mi, int role) const
                         || data.type == BreakpointAtSysCall)
                     return typeToString(data.type);
                 if (data.type == WatchpointAtAddress)
-                    return tr("Data breakpoint at 0x%1").arg(data.address, 0, 16);
+                    return tr("Data at 0x%1").arg(data.address, 0, 16);
                 if (data.type == WatchpointAtExpression)
-                    return tr("Data breakpoint at %1").arg(data.expression);
+                    return tr("Data at %1").arg(data.expression);
                 return empty;
             }
             break;
@@ -882,6 +884,10 @@ void BreakHandler::notifyBreakpointReleased(BreakpointId id)
     it->response = BreakpointResponse();
     delete it->marker;
     it->marker = 0;
+    if (it->data.type == WatchpointAtAddress
+            || it->data.type == WatchpointAtExpression
+            || it->data.type == BreakpointByAddress)
+        it->data.enabled = false;
     updateMarker(id);
     layoutChanged();
 }
@@ -1093,7 +1099,7 @@ bool BreakHandler::needsChange(BreakpointId id) const
 }
 
 void BreakHandler::setResponse(BreakpointId id,
-    const BreakpointResponse &response, bool takeOver)
+    const BreakpointResponse &response)
 {
     Iterator it = m_storage.find(id);
     BREAK_ASSERT(it != m_storage.end(), return);
@@ -1101,12 +1107,10 @@ void BreakHandler::setResponse(BreakpointId id,
     item.response = response;
     item.destroyMarker();
     // Take over corrected values from response.
-    if (takeOver) {
-        if ((item.data.type == BreakpointByFileAndLine
-                    || item.data.type == BreakpointByFunction)
-                && !response.module.isEmpty())
-            item.data.module = response.module;
-    }
+    if ((item.data.type == BreakpointByFileAndLine
+                || item.data.type == BreakpointByFunction)
+            && !response.module.isEmpty())
+        item.data.module = response.module;
     updateMarker(id);
 }
 
index 33f0950..09bfd60 100644 (file)
@@ -137,7 +137,7 @@ public:
     DebuggerEngine *engine(BreakpointId id) const;
     void setEngine(BreakpointId id, DebuggerEngine *engine);
     const BreakpointResponse &response(BreakpointId id) const;
-    void setResponse(BreakpointId id, const BreakpointResponse &data, bool takeOver = true);
+    void setResponse(BreakpointId id, const BreakpointResponse &data);
     bool needsChange(BreakpointId id) const;
 
     // State transitions.
index 0129999..701806e 100644 (file)
@@ -2318,7 +2318,9 @@ void GdbEngine::handleWatchInsert(const GdbResponse &response)
             // Mac yields:
             //>32^done,wpt={number="4",exp="*4355182176"}
             bresponse.number = wpt.findChild("number").data().toInt();
-            bresponse.address = wpt.findChild("exp").toAddress();
+            QByteArray exp = wpt.findChild("exp").data();
+            if (exp.startsWith('*'))
+                bresponse.address = exp.mid(1).toULongLong(0, 0);
             handler->setResponse(id, bresponse);
             QTC_ASSERT(!handler->needsChange(id), /**/);
             handler->notifyBreakpointInsertOk(id);
@@ -2327,9 +2329,10 @@ void GdbEngine::handleWatchInsert(const GdbResponse &response)
             // Non-Mac: "Hardware watchpoint 2: *0xbfffed40\n"
             const int end = ba.indexOf(':');
             const int begin = ba.lastIndexOf(' ', end) + 1;
-            const QByteArray address = ba.mid(end + 3).trimmed();
+            const QByteArray address = ba.mid(end + 2).trimmed();
             bresponse.number = ba.mid(begin, end - begin).toInt();
-            bresponse.address = address.toULongLong(0, 0);
+            if (address.startsWith('*'))
+                bresponse.address = address.mid(1).toULongLong(0, 0);
             handler->setResponse(id, bresponse);
             QTC_ASSERT(!handler->needsChange(id), /**/);
             handler->notifyBreakpointInsertOk(id);
index e93533e..17abe88 100644 (file)
@@ -380,7 +380,7 @@ qulonglong GdbMi::toAddress() const
         ba.chop(1);
     if (ba.startsWith('*') || ba.startsWith('@'))
         ba = ba.mid(1);
-    return ba.toULongLong(0, 16);
+    return ba.toULongLong(0, 0);
 }
 
 //////////////////////////////////////////////////////////////////////////////////
index c736f7e..14dee8f 100644 (file)
@@ -387,8 +387,10 @@ QString WatchData::toToolTip() const
 
 QString WatchData::msgNotInScope()
 {
-    //: Value of variable in Debugger Locals display for variables out of scope (stopped above initialization).
-    static const QString rc = QCoreApplication::translate("Debugger::Internal::WatchData", "<not in scope>");
+    //: Value of variable in Debugger Locals display for variables out
+    //: of scope (stopped above initialization).
+    static const QString rc =
+        QCoreApplication::translate("Debugger::Internal::WatchData", "<not in scope>");
     return rc;
 }
 
@@ -397,7 +399,8 @@ const QString &WatchData::shadowedNameFormat()
     //: Display of variables shadowed by variables of the same name
     //: in nested scopes: Variable %1 is the variable name, %2 is a
     //: simple count.
-    static const QString format = QCoreApplication::translate("Debugger::Internal::WatchData", "%1 <shadowed %2>");
+    static const QString format =
+        QCoreApplication::translate("Debugger::Internal::WatchData", "%1 <shadowed %2>");
     return format;
 }
 
@@ -415,12 +418,16 @@ quint64 WatchData::coreAddress() const
 
 QByteArray WatchData::hexAddress() const
 {
-    return address ? (QByteArray("0x") + QByteArray::number(address, 16)) : QByteArray();
+    if (address)
+        return QByteArray("0x") + QByteArray::number(address, 16);
+    return QByteArray();
 }
 
 QByteArray WatchData::hexReferencingAddress() const
 {
-    return referencingAddress ? (QByteArray("0x") + QByteArray::number(referencingAddress, 16)) : QByteArray();
+    if (referencingAddress)
+        return QByteArray("0x") + QByteArray::number(referencingAddress, 16);
+    return QByteArray();
 }
 
 } // namespace Internal