OSDN Git Service

debugger: make QVector and std::vector writable
authorhjk <qtc-committer@nokia.com>
Tue, 10 May 2011 18:42:22 +0000 (20:42 +0200)
committerhjk <qtc-committer@nokia.com>
Wed, 11 May 2011 08:38:04 +0000 (10:38 +0200)
share/qtcreator/gdbmacros/dumper.py
share/qtcreator/gdbmacros/gdbmacros.py
src/plugins/debugger/gdb/gdbengine.cpp
tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp

index 7982bf2..7080c9b 100644 (file)
@@ -1078,16 +1078,20 @@ def bbsetup():
 #######################################################################
 
 def bbedit(args):
-    (type, expr, value) = args.split(" ")
-    type = base64.b64decode(type)
+    (type, expr, value) = args.split(",")
+    type = base64.b16decode(type, True)
     ns = qtNamespace()
-    type = type[len(ns):]
+    if type.startswith(ns):
+        type = type[len(ns):]
     type = type.replace("::", "__")
-    expr = base64.b64decode(expr)
-    value = base64.b64decode(value)
+    pos = type.find('<')
+    if pos != -1:
+        type = type[0:pos]
+    expr = base64.b16decode(expr, True)
+    value = base64.b16decode(value, True)
+    #warn("EDIT: %s %s %s %s: " % (pos, type, expr, value))
     if qqEditable.has_key(type):
         qqEditable[type](expr, value)
-    warn("EDIT: %s %s %s: " % (type, expr, value))
 
 class EditCommand(gdb.Command):
     """QtCreator Data Edit Support"""
index 0928841..9b8ff34 100644 (file)
@@ -1645,6 +1645,17 @@ def qdump__QVariant(d, item):
     return tdata.type
 
 
+def qedit__QVector(expr, value):
+    values = value.split(',')
+    ob = gdb.parse_and_eval(expr)
+    cmd = "call (%s).resize(%d)" % (expr, len(values))
+    gdb.execute(cmd)
+    innerType = templateArgument(ob.type, 0)
+    ptr = ob["p"]["array"].cast(lookupType("void").pointer())
+    cmd = "set {%s[%d]}%s={%s}" % (innerType, len(values), long(ptr), value)
+    gdb.execute(cmd)
+
+
 def qdump__QVector(d, item):
     d_ptr = item.value["d"]
     p_ptr = item.value["p"]
@@ -1896,6 +1907,18 @@ def qdump__std__string(d, item):
     d.putNumChild(0)
 
 
+def qedit__std__vector(expr, value):
+    values = value.split(',')
+    n = len(values)
+    ob = gdb.parse_and_eval(expr)
+    innerType = templateArgument(ob.type, 0)
+    cmd = "set $d = (%s*)calloc(sizeof(%s)*%s,1)" % (innerType, innerType, n)
+    gdb.execute(cmd)
+    cmd = "set {void*[3]}%s = {$d, $d+%s, $d+%s}" % (ob.address, n, n)
+    gdb.execute(cmd)
+    cmd = "set (%s[%d])*$d={%s}" % (innerType, n, value)
+    gdb.execute(cmd)
+
 def qdump__std__vector(d, item):
     impl = item.value["_M_impl"]
     type = templateArgument(item.value.type, 0)
index 2549bc8..0129999 100644 (file)
@@ -3905,9 +3905,9 @@ void GdbEngine::assignValueInDebugger(const WatchData *data,
 {
     if (hasPython()) {
         QByteArray cmd = "bbedit "
-            + data->type.toBase64() + ' '
-            + expression.toUtf8().toBase64() + ' '
-            + value.toString().toUtf8().toBase64();
+            + data->type.toHex() + ','
+            + expression.toUtf8().toHex() + ','
+            + value.toString().toUtf8().toHex();
         postCommand(cmd, Discardable, CB(handleVarAssign));
     } else {
         postCommand("-var-delete assign");
index ffa0836..e9fa918 100644 (file)
@@ -2604,6 +2604,12 @@ int main(int argc, char *argv[])
     testQHash1();
     testSignalSlot(argc, argv);
 
+    QVector<int> qv;
+    qv.push_back(2);
+
+    std::vector<int> v;
+    v.push_back(2);
+
     QString hallo = "hallo\nwelt";
     QStringList list;
     list << "aaa" << "bbb" << "cc";