Commit 1e9adb22 authored by hjk's avatar hjk

Debugger: Fix editing of std::{string,vector} values

Change-Id: I3ff3f032af9ca54f2c48fe6e611fee73691e5ea2
Reviewed-by: default avatarUlf Hermann <ulf.hermann@digia.com>
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 7458a823
......@@ -420,7 +420,7 @@ class LocalItem:
#######################################################################
def bbedit(args):
theDumper.bbedit(args.split(","))
theDumper.bbedit(args)
registerCommand("bbedit", bbedit)
......@@ -706,7 +706,8 @@ class Dumper(DumperBase):
if type.find(":") >= 0:
type = "'" + type + "'"
# 'class' is needed, see http://sourceware.org/bugzilla/show_bug.cgi?id=11912
exp = "((class %s*)%s)->%s(%s)" % (type, value.address, func, arg)
#exp = "((class %s*)%s)->%s(%s)" % (type, value.address, func, arg)
exp = "((%s*)%s)->%s(%s)" % (type, value.address, func, arg)
#warn("CALL: %s" % exp)
result = None
try:
......@@ -903,6 +904,15 @@ class Dumper(DumperBase):
# Try _some_ fallback (good enough for the std::complex dumper)
return gdb.parse_and_eval("{%s}%s" % (referencedType, address))
def setValue(self, address, type, value):
cmd = "set {%s}%s=%s" % (type, address, value)
gdb.execute(cmd)
def setValues(self, address, type, values):
cmd = "set {%s[%s]}%s={%s}" \
% (type, len(values), address, ','.join(map(str, values)))
gdb.execute(cmd)
def selectedInferior(self):
try:
# gdb.Inferior is new in gdb 7.2
......@@ -1659,22 +1669,25 @@ class Dumper(DumperBase):
return namespace
def bbedit(self, type, expr, value):
type = b16decode(type)
def bbedit(self, args):
(typeName, expr, data) = args.split(',')
typeName = b16decode(typeName)
ns = self.qtNamespace()
if type.startswith(ns):
type = type[len(ns):]
type = type.replace("::", "__")
pos = type.find('<')
if typeName.startswith(ns):
typeName = typeName[len(ns):]
typeName = typeName.replace("::", "__")
pos = typeName.find('<')
if pos != -1:
type = type[0:pos]
typeName = typeName[0:pos]
expr = b16decode(expr)
value = b16decode(value)
#warn("EDIT: %s %s %s %s: " % (pos, type, expr, value))
if self.qqEditable.has_key(type):
self.qqEditable[type](expr, value)
data = b16decode(data)
if typeName in self.qqEditable:
#self.qqEditable[typeName](self, expr, data)
value = gdb.parse_and_eval(expr)
self.qqEditable[typeName](self, value, data)
else:
gdb.execute("set (%s)=%s" % (expr, value))
cmd = "set variable (%s)=%s" % (expr, data)
gdb.execute(cmd)
def hasVTable(self, type):
fields = type.fields()
......
......@@ -1640,17 +1640,10 @@ def qdump__QStandardItem(d, value):
d.putPlainChildren(value)
def qedit__QString(expr, value):
cmd = "call (%s).resize(%d)" % (expr, len(value))
gdb.execute(cmd)
d = gdb.parse_and_eval(expr)["d"]["data"]
cmd = "set {short[%d]}%s={" % (len(value), d.pointerValue(d))
for i in range(len(value)):
if i != 0:
cmd += ','
cmd += str(ord(value[i]))
cmd += '}'
gdb.execute(cmd)
def qedit__QString(d, value, data):
d.call(value, "resize", str(len(data)))
(base, size, alloc) = d.stringData(value)
d.setValues(base, "short", [ord(c) for c in data])
def qform__QString():
return "Inline,Separate Window"
......@@ -1976,15 +1969,19 @@ def qdump__QVariant(d, value):
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 = d.templateArgument(ob.type, 0)
ptr = ob["p"]["array"].cast(d.voidPtrType())
cmd = "set {%s[%d]}%s={%s}" % (innerType, len(values), d.pointerValue(ptr), value)
gdb.execute(cmd)
def qedit__QVector(d, value, data):
values = data.split(',')
size = len(values)
d.call(value, "resize", str(size))
innerType = d.templateArgument(value.type, 0)
try:
# Qt 5. Will fail on Qt 4 due to the missing 'offset' member.
offset = value["d"]["offset"]
base = d.pointerValue(value["d"].cast(d.charPtrType()) + offset)
except:
# Qt 4.
base = d.pointerValue(value["p"]["array"])
d.setValues(base, innerType, values)
def qform__QVector():
......
......@@ -497,16 +497,16 @@ def qdump__std____debug__unordered_set(d, value):
qdump__std__unordered_set(d, value)
def qedit__std__vector(expr, value):
values = value.split(',')
def qedit__std__vector(d, value, data):
import gdb
values = data.split(',')
n = len(values)
ob = gdb.parse_and_eval(expr)
innerType = d.templateArgument(ob.type, 0)
innerType = d.templateArgument(value.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)
cmd = "set {void*[3]}%s = {$d, $d+%s, $d+%s}" % (value.address, n, n)
gdb.execute(cmd)
cmd = "set (%s[%d])*$d={%s}" % (innerType, n, value)
cmd = "set (%s[%d])*$d={%s}" % (innerType, n, data)
gdb.execute(cmd)
def qdump__std__vector(d, value):
......@@ -566,12 +566,11 @@ def qdump__std____1__vector(d, value):
def qdump__std____debug__vector(d, value):
qdump__std__vector(d, value)
def qedit__std__string(expr, value):
cmd = "print (%s).assign(\"%s\")" % (expr, value)
gdb.execute(cmd)
def qedit__std__string(d, value, data):
d.call(value, "assign", '"%s"' % data.replace('"', '\\"'))
def qedit__string(expr, value):
qedit__std__string(expr, value)
def qedit__string(d, expr, value):
qedit__std__string(d, expr, value)
def qdump__string(d, value):
qdump__std__string(d, value)
......
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