aboutsummaryrefslogtreecommitdiffstats
path: root/share/qtcreator
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2020-09-24 12:02:06 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2020-09-24 13:11:47 +0000
commitd86cf5e2358adc22feaa3cca24d4f6df9b9c457c (patch)
tree1996c320896b62fd208a8cc7f6ea27988b14894e /share/qtcreator
parent4327ddf6c5e6c5b3d79722a9f1672769c5ee3a61 (diff)
Debugger: Retrieve and remember int from native GDB value
When adding expressions for bitfield members in the debugger's expression view, their corresponding 'gdb.Value' does not expose the fact that those are actually bitfields, so e.g. an 'int : 3' is exposed like a "normal" 'int'. Previously, this would result in wrong values being retrieved in the 'DumperBase::Value::integer()' function, when trying to read the value from the corresponding memory address. To avoid this, retrieve the actual int representation for numeric values from the corresponding native 'gdb.Value', remember them and return that one, similar to how it is already done for known bitfield members (s. 'Dumper::memberFromNativeFieldAndValue'). The conversion from the 'gdb.Value' does not work for integers of a size larger than 64 bits (like '__int128' used in the "Int128" dumper test). Therefore, just ignore conversion failures and don't remember any value explicitly for those cases, so the same handling as previously used is applied. (At a quick glance, the reason seems to be that this is because GDB's corresponding functions use 'int64' as a return value of the relevant functions [1] [2], but I did not look closer into what GDB does internally.) Corresponding tests will be added in a separate commit. [1] https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdbsupport/common-types.h;h=f5b2f3d249177acea77231c21c5601f959c18d2f;hb=f3034e25fa98d44b775970f40c9ec85eeae096e6#l33 [2] https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/python/py-value.c;h=6e29284aad11ff344789152a4f601b3474d86bb5;hb=f3034e25fa98d44b775970f40c9ec85eeae096e6#l1706 Fixes: QTCREATORBUG-24693 Change-Id: Idfc3390115e8796f3c778070c23424c3dbdfeddd Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'share/qtcreator')
-rw-r--r--share/qtcreator/debugger/dumper.py3
-rw-r--r--share/qtcreator/debugger/gdbbridge.py7
2 files changed, 9 insertions, 1 deletions
diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py
index 7f0cda6623..68cafc5209 100644
--- a/share/qtcreator/debugger/dumper.py
+++ b/share/qtcreator/debugger/dumper.py
@@ -2851,6 +2851,7 @@ class DumperBase():
self.type = None
self.ldata = None # Target address in case of references and pointers.
self.laddress = None # Own address.
+ self.lvalue = None
self.lIsInScope = True
self.ldisplay = None
self.summary = None # Always hexencoded UTF-8.
@@ -2924,7 +2925,7 @@ class DumperBase():
def integer(self, bitsize=None):
if self.type.code == TypeCode.Typedef:
return self.detypedef().integer()
- elif self.type.code == TypeCode.Bitfield:
+ elif isinstance(self.lvalue, int):
return self.lvalue
# Could be something like 'short unsigned int'
unsigned = self.type.name == 'unsigned' \
diff --git a/share/qtcreator/debugger/gdbbridge.py b/share/qtcreator/debugger/gdbbridge.py
index 824f4c50f7..5d32f8426c 100644
--- a/share/qtcreator/debugger/gdbbridge.py
+++ b/share/qtcreator/debugger/gdbbridge.py
@@ -307,6 +307,13 @@ class Dumper(DumperBase):
val.ldisplay += ' (%s)' % intval
elif code == gdb.TYPE_CODE_COMPLEX:
val.ldisplay = str(nativeValue)
+ elif code in [gdb.TYPE_CODE_BOOL, gdb.TYPE_CODE_INT]:
+ try:
+ # extract int presentation from native value and remember it
+ val.lvalue = int(nativeValue)
+ except:
+ # GDB only support converting integers of max. 64 bits to Python int as of now
+ pass
#elif code == gdb.TYPE_CODE_ARRAY:
# val.type.ltarget = nativeValue[0].type.unqualified()
return val