Commit 07478590 authored by hjk's avatar hjk

debugger: make QVector and std::vector writable

parent d0b12f8f
......@@ -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"""
......
......@@ -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)
......
......@@ -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");
......
......@@ -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";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment