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:
Robert Löhning
2024-03-21 16:49:04 +01:00
parent 2f32461d32
commit 0cca4b283b
4 changed files with 6 additions and 6 deletions

View File

@@ -772,7 +772,7 @@ class Dumper(DumperBase):
def makeStdString(init): def makeStdString(init):
# Works only for small allocators, but they are usually empty. # 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 + gdb.execute('call($d->basic_string("' + init +
'",*(std::allocator<char>*)(1+$d)))') '",*(std::allocator<char>*)(1+$d)))')
value = gdb.parse_and_eval('$d').dereference() value = gdb.parse_and_eval('$d').dereference()
@@ -787,7 +787,7 @@ class Dumper(DumperBase):
h = self.hexencode(data) h = self.hexencode(data)
#DumperBase.warn('DATA: %s' % h) #DumperBase.warn('DATA: %s' % h)
string = ''.join('\\x' + h[2 * i:2 * i + 2] for i in range(size)) 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) % (value.type.name, size, string, size)
#DumperBase.warn('EXP: %s' % exp) #DumperBase.warn('EXP: %s' % exp)
res = gdb.parse_and_eval(exp) res = gdb.parse_and_eval(exp)

View File

@@ -772,7 +772,7 @@ class Dumper(DumperBase):
def makeStdString(init): def makeStdString(init):
# Works only for small allocators, but they are usually empty. # 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 + gdb.execute('call($d->basic_string("' + init +
'",*(std::allocator<char>*)(1+$d)))') '",*(std::allocator<char>*)(1+$d)))')
value = gdb.parse_and_eval('$d').dereference() value = gdb.parse_and_eval('$d').dereference()
@@ -787,7 +787,7 @@ class Dumper(DumperBase):
h = self.hexencode(data) h = self.hexencode(data)
#DumperBase.warn('DATA: %s' % h) #DumperBase.warn('DATA: %s' % h)
string = ''.join('\\x' + h[2 * i:2 * i + 2] for i in range(size)) 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) % (value.type.name, size, string, size)
#DumperBase.warn('EXP: %s' % exp) #DumperBase.warn('EXP: %s' % exp)
res = gdb.parse_and_eval(exp) res = gdb.parse_and_eval(exp)

View File

@@ -850,7 +850,7 @@ def qedit__std__vector(d, value, data):
values = data.split(',') values = data.split(',')
n = len(values) n = len(values)
innerType = value.type[0].name 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) 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) gdb.execute(cmd)

View File

@@ -909,7 +909,7 @@ def qedit__std__vector(d, value, data):
values = data.split(',') values = data.split(',')
n = len(values) n = len(values)
innerType = value.type[0].name 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) 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) gdb.execute(cmd)