forked from qt-creator/qt-creator
debugger: make QVector and std::vector writable
This commit is contained in:
@@ -1078,16 +1078,20 @@ def bbsetup():
|
|||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
def bbedit(args):
|
def bbedit(args):
|
||||||
(type, expr, value) = args.split(" ")
|
(type, expr, value) = args.split(",")
|
||||||
type = base64.b64decode(type)
|
type = base64.b16decode(type, True)
|
||||||
ns = qtNamespace()
|
ns = qtNamespace()
|
||||||
type = type[len(ns):]
|
if type.startswith(ns):
|
||||||
|
type = type[len(ns):]
|
||||||
type = type.replace("::", "__")
|
type = type.replace("::", "__")
|
||||||
expr = base64.b64decode(expr)
|
pos = type.find('<')
|
||||||
value = base64.b64decode(value)
|
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):
|
if qqEditable.has_key(type):
|
||||||
qqEditable[type](expr, value)
|
qqEditable[type](expr, value)
|
||||||
warn("EDIT: %s %s %s: " % (type, expr, value))
|
|
||||||
|
|
||||||
class EditCommand(gdb.Command):
|
class EditCommand(gdb.Command):
|
||||||
"""QtCreator Data Edit Support"""
|
"""QtCreator Data Edit Support"""
|
||||||
|
@@ -1645,6 +1645,17 @@ def qdump__QVariant(d, item):
|
|||||||
return tdata.type
|
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):
|
def qdump__QVector(d, item):
|
||||||
d_ptr = item.value["d"]
|
d_ptr = item.value["d"]
|
||||||
p_ptr = item.value["p"]
|
p_ptr = item.value["p"]
|
||||||
@@ -1896,6 +1907,18 @@ def qdump__std__string(d, item):
|
|||||||
d.putNumChild(0)
|
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):
|
def qdump__std__vector(d, item):
|
||||||
impl = item.value["_M_impl"]
|
impl = item.value["_M_impl"]
|
||||||
type = templateArgument(item.value.type, 0)
|
type = templateArgument(item.value.type, 0)
|
||||||
|
@@ -3905,9 +3905,9 @@ void GdbEngine::assignValueInDebugger(const WatchData *data,
|
|||||||
{
|
{
|
||||||
if (hasPython()) {
|
if (hasPython()) {
|
||||||
QByteArray cmd = "bbedit "
|
QByteArray cmd = "bbedit "
|
||||||
+ data->type.toBase64() + ' '
|
+ data->type.toHex() + ','
|
||||||
+ expression.toUtf8().toBase64() + ' '
|
+ expression.toUtf8().toHex() + ','
|
||||||
+ value.toString().toUtf8().toBase64();
|
+ value.toString().toUtf8().toHex();
|
||||||
postCommand(cmd, Discardable, CB(handleVarAssign));
|
postCommand(cmd, Discardable, CB(handleVarAssign));
|
||||||
} else {
|
} else {
|
||||||
postCommand("-var-delete assign");
|
postCommand("-var-delete assign");
|
||||||
|
@@ -2604,6 +2604,12 @@ int main(int argc, char *argv[])
|
|||||||
testQHash1();
|
testQHash1();
|
||||||
testSignalSlot(argc, argv);
|
testSignalSlot(argc, argv);
|
||||||
|
|
||||||
|
QVector<int> qv;
|
||||||
|
qv.push_back(2);
|
||||||
|
|
||||||
|
std::vector<int> v;
|
||||||
|
v.push_back(2);
|
||||||
|
|
||||||
QString hallo = "hallo\nwelt";
|
QString hallo = "hallo\nwelt";
|
||||||
QStringList list;
|
QStringList list;
|
||||||
list << "aaa" << "bbb" << "cc";
|
list << "aaa" << "bbb" << "cc";
|
||||||
|
Reference in New Issue
Block a user