Commit 6ae77f7d authored by hjk's avatar hjk

Debugger: Fix editing of std::{w,}string, QString, QByteArray

... as well as std::vector and QVector

Change-Id: I7fd33be9917a17414149813c28316166b8de9be7
Task-number: QTCREATORBUG-18681
Reviewed-by: default avatarAndré Hartmann <aha_1980@gmx.de>
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
parent 2c6be25d
......@@ -733,7 +733,7 @@ class Dumper(DumperBase):
typeName = "'" + typeName + "'"
# 'class' is needed, see http://sourceware.org/bugzilla/show_bug.cgi?id=11912
#exp = '((class %s*)%s)->%s(%s)' % (typeName, value.laddress, function, arg)
addr = value.laddress
addr = value.address()
if addr is None:
addr = self.pokeValue(value)
#warn('PTR: %s -> %s(%s)' % (value, function, addr))
......@@ -742,7 +742,7 @@ class Dumper(DumperBase):
result = gdb.parse_and_eval(exp)
#warn(' -> %s' % result)
res = self.fromNativeValue(result)
if value.laddress is None:
if value.address() is None:
self.releaseValue(addr)
return res
......@@ -1048,7 +1048,7 @@ class Dumper(DumperBase):
typeName = typeName[0:pos]
if typeName in self.qqEditable and not simpleType:
#self.qqEditable[typeName](self, expr, value)
expr = gdb.parse_and_eval(expr)
expr = self.parseAndEvaluate(expr)
self.qqEditable[typeName](self, expr, value)
else:
cmd = 'set variable (%s)=%s' % (expr, value)
......
......@@ -46,6 +46,11 @@ def qform__QByteArray():
return [Latin1StringFormat, SeparateLatin1StringFormat,
Utf8StringFormat, SeparateUtf8StringFormat ]
def qedit__QByteArray(d, value, data):
d.call('void', value, 'resize', str(len(data)))
(base, size, alloc) = d.stringData(value)
d.setValues(base, 'char', [ord(c) for c in data])
def qdump__QByteArray(d, value):
data, size, alloc = d.byteArrayData(value)
d.check(alloc == 0 or (0 <= size and size <= alloc and alloc <= 100000000))
......@@ -1776,17 +1781,9 @@ def qdump__QVariant(d, value):
def qedit__QVector(d, value, data):
values = data.split(',')
size = len(values)
d.call('void', value, 'resize', str(size))
innerType = value.type[0]
try:
# Qt 5. Will fail on Qt 4 due to the missing 'offset' member.
offset = value['d']['offset']
base = value['d'].address() + offset
except:
# Qt 4.
base = value['p']['array'].pointer()
d.setValues(base, innerType, values)
d.call('void', value, 'resize', str(len(values)))
base, vsize, valloc = d.vectorDataHelper(d.extractPointer(value))
d.setValues(base, value.type[0].name, values)
def qform__QVector():
......
......@@ -888,10 +888,10 @@ def qedit__std__vector(d, value, data):
import gdb
values = data.split(',')
n = len(values)
innerType = value.type[0]
innerType = value.type[0].name
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}" % (value.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, data)
gdb.execute(cmd)
......@@ -976,11 +976,23 @@ def qdump__std____debug__vector(d, value):
def qedit__std__string(d, value, data):
d.call(value, "assign", '"%s"' % data.replace('"', '\\"'))
d.call('void', value, 'assign', '"%s"' % data.replace('"', '\\"'))
def qedit__string(d, expr, value):
qedit__std__string(d, expr, value)
def qedit__std____cxx11__string(d, expr, value):
qedit__std__string(d, expr, value)
def qedit__std__wstring(d, value, data):
d.call('void', value, 'assign', 'L"%s"' % data.replace('"', '\\"'))
def qedit__wstring(d, expr, value):
qedit__std__wstring(d, expr, value)
def qedit__std____cxx11__wstring(d, expr, value):
qedit__std__wstring(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