forked from qt-creator/qt-creator
Debugger: Fix calls to calloc
Change-Id: Id1ba0c4656eb611b6ac4269ebf9d141feb08d632 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -772,7 +772,7 @@ class Dumper(DumperBase):
|
||||
|
||||
def makeStdString(init):
|
||||
# Works only for small allocators, but they are usually empty.
|
||||
gdb.execute('set $d=(std::string*)calloc(sizeof(std::string), 2)')
|
||||
gdb.execute('set $d=(std::string*)calloc(2, sizeof(std::string))')
|
||||
gdb.execute('call($d->basic_string("' + init +
|
||||
'",*(std::allocator<char>*)(1+$d)))')
|
||||
value = gdb.parse_and_eval('$d').dereference()
|
||||
@@ -787,7 +787,7 @@ class Dumper(DumperBase):
|
||||
h = self.hexencode(data)
|
||||
#DumperBase.warn('DATA: %s' % h)
|
||||
string = ''.join('\\x' + h[2 * i:2 * i + 2] for i in range(size))
|
||||
exp = '(%s*)memcpy(calloc(%d, 1), "%s", %d)' \
|
||||
exp = '(%s*)memcpy(calloc(1, %d), "%s", %d)' \
|
||||
% (value.type.name, size, string, size)
|
||||
#DumperBase.warn('EXP: %s' % exp)
|
||||
res = gdb.parse_and_eval(exp)
|
||||
|
@@ -772,7 +772,7 @@ class Dumper(DumperBase):
|
||||
|
||||
def makeStdString(init):
|
||||
# Works only for small allocators, but they are usually empty.
|
||||
gdb.execute('set $d=(std::string*)calloc(sizeof(std::string), 2)')
|
||||
gdb.execute('set $d=(std::string*)calloc(2, sizeof(std::string))')
|
||||
gdb.execute('call($d->basic_string("' + init +
|
||||
'",*(std::allocator<char>*)(1+$d)))')
|
||||
value = gdb.parse_and_eval('$d').dereference()
|
||||
@@ -787,7 +787,7 @@ class Dumper(DumperBase):
|
||||
h = self.hexencode(data)
|
||||
#DumperBase.warn('DATA: %s' % h)
|
||||
string = ''.join('\\x' + h[2 * i:2 * i + 2] for i in range(size))
|
||||
exp = '(%s*)memcpy(calloc(%d, 1), "%s", %d)' \
|
||||
exp = '(%s*)memcpy(calloc(1, %d), "%s", %d)' \
|
||||
% (value.type.name, size, string, size)
|
||||
#DumperBase.warn('EXP: %s' % exp)
|
||||
res = gdb.parse_and_eval(exp)
|
||||
|
@@ -850,7 +850,7 @@ def qedit__std__vector(d, value, data):
|
||||
values = data.split(',')
|
||||
n = len(values)
|
||||
innerType = value.type[0].name
|
||||
cmd = "set $d = (%s*)calloc(sizeof(%s)*%s,1)" % (innerType, innerType, n)
|
||||
cmd = "set $d = (%s*)calloc(%s,sizeof(%s))" % (innerType, n, innerType)
|
||||
gdb.execute(cmd)
|
||||
cmd = "set {void*[3]}%s = {$d, $d+%s, $d+%s}" % (value.address(), n, n)
|
||||
gdb.execute(cmd)
|
||||
|
@@ -909,7 +909,7 @@ def qedit__std__vector(d, value, data):
|
||||
values = data.split(',')
|
||||
n = len(values)
|
||||
innerType = value.type[0].name
|
||||
cmd = "set $d = (%s*)calloc(sizeof(%s)*%s,1)" % (innerType, innerType, n)
|
||||
cmd = "set $d = (%s*)calloc(%s,sizeof(%s))" % (innerType, n, innerType)
|
||||
gdb.execute(cmd)
|
||||
cmd = "set {void*[3]}%s = {$d, $d+%s, $d+%s}" % (value.address(), n, n)
|
||||
gdb.execute(cmd)
|
||||
|
Reference in New Issue
Block a user