From b26400e8efc5a582e92ff6ad3226bf22eab5f7c2 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 14 Nov 2016 16:22:42 +0100 Subject: [PATCH] Debugger: Workaround gdb.lookup_symbol ignoring QArrayData::shared_null There have been cases observed where 'p QArrayData::shared_null' finds valid symbols that are not found using gdb.lookup_symbols. The cause for that is unknown. Apply an expensive workaround by checking for (the equivalent of) a working 'p QArrayData::shared_null' but execute it only when a libQt5Core was found. This keeps the overhead for non-Qt setups at a bearable (unsuccessful) iteration over known shared object names. Change-Id: Id398673b938d3c3a72c24317abdbefbe793e54df Reviewed-by: Christian Stenger --- share/qtcreator/debugger/gdbbridge.py | 44 +++++++++++++++------------ 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/share/qtcreator/debugger/gdbbridge.py b/share/qtcreator/debugger/gdbbridge.py index 9877c54c290..3612dcdb4fb 100644 --- a/share/qtcreator/debugger/gdbbridge.py +++ b/share/qtcreator/debugger/gdbbridge.py @@ -1014,30 +1014,34 @@ class Dumper(DumperBase): if not self.currentQtNamespaceGuess is None: return self.currentQtNamespaceGuess - # This only works when called from a valid frame. - try: - cand = 'QArrayData::shared_null' - symbol = gdb.lookup_symbol(cand)[0] - if symbol: - ns = symbol.name[:-len(cand)] - self.qtNamespaceToReport = ns - self.qtNamespace = lambda: ns - return ns - except: - pass + for objfile in gdb.objfiles(): + name = objfile.filename + if name.find('/libQt5Core') >= 0: + ns = '' - try: - # This is Qt, but not 5.x. - cand = 'QByteArray::shared_null' - symbol = gdb.lookup_symbol(cand)[0] - if symbol: - ns = symbol.name[:-len(cand)] + # This only works when called from a valid frame. + try: + cand = 'QArrayData::shared_null' + symbol = gdb.lookup_symbol(cand)[0] + if symbol: + ns = symbol.name[:-len(cand)] + except: + try: + # Some GDB 7.11.1 on Arch Linux. + cand = 'QArrayData::shared_null[0]' + val = gdb.parse_and_eval(cand) + if val.type is not None: + typeobj = val.type.unqualified() + ns = typeobj.name[:-len('QArrayData')] + except: + pass + + # This might be wrong, but we can't do better: We found + # a libQt5Core and could not extract a namespace. + # The best guess is that there isn't any. self.qtNamespaceToReport = ns self.qtNamespace = lambda: ns - self.fallbackQtVersion = 0x40800 return ns - except: - pass self.currentQtNamespaceGuess = '' return ''