From 0cca4b283b4a6daa1cad05b3dddd0010437f998c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20L=C3=B6hning?= Date: Thu, 21 Mar 2024 16:49:04 +0100 Subject: [PATCH] Debugger: Fix calls to calloc Change-Id: Id1ba0c4656eb611b6ac4269ebf9d141feb08d632 Reviewed-by: hjk Reviewed-by: Qt CI Bot Reviewed-by: --- share/qtcreator/debugger/gdbbridge.py | 4 ++-- share/qtcreator/debugger/python2/gdbbridge.py | 4 ++-- share/qtcreator/debugger/python2/stdtypes.py | 2 +- share/qtcreator/debugger/stdtypes.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/share/qtcreator/debugger/gdbbridge.py b/share/qtcreator/debugger/gdbbridge.py index d61160eed3b..9699e518fe3 100644 --- a/share/qtcreator/debugger/gdbbridge.py +++ b/share/qtcreator/debugger/gdbbridge.py @@ -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*)(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) diff --git a/share/qtcreator/debugger/python2/gdbbridge.py b/share/qtcreator/debugger/python2/gdbbridge.py index d61160eed3b..9699e518fe3 100644 --- a/share/qtcreator/debugger/python2/gdbbridge.py +++ b/share/qtcreator/debugger/python2/gdbbridge.py @@ -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*)(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) diff --git a/share/qtcreator/debugger/python2/stdtypes.py b/share/qtcreator/debugger/python2/stdtypes.py index c14812dee1d..8bc86671c69 100644 --- a/share/qtcreator/debugger/python2/stdtypes.py +++ b/share/qtcreator/debugger/python2/stdtypes.py @@ -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) diff --git a/share/qtcreator/debugger/stdtypes.py b/share/qtcreator/debugger/stdtypes.py index bc4bb84dcbb..dbe663ef631 100644 --- a/share/qtcreator/debugger/stdtypes.py +++ b/share/qtcreator/debugger/stdtypes.py @@ -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)