lldb: Add summary providers using consistent module name

When the lldbbridge is imported from the debug_script.py in qtbase,
it's imported using the module name 'qt', to distinguish it from
when Qt Creator imports the bridge.

So when we add the synthetic child provider, we need to use the
'qt' module name. This fixes the warning:

  The provided class does not exist - please define
  it before attempting to use this synthetic provider

If for some reason the lldbbridge.py is imported into a LLDB session
directly, we mirror the 'lldbbrdige' module name to 'qt' as well,
so that the class reference still holds.

Change-Id: I531b10fd5e10eb0c2acd6014169a02ba3157c704
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Tor Arne Vestbø
2023-09-19 23:55:12 +02:00
parent 8af902b5b7
commit 4b29b43a2a

View File

@@ -2437,6 +2437,12 @@ class SyntheticChildrenProvider(SummaryProvider):
def __lldb_init_module(debugger, internal_dict):
# Module is being imported in an LLDB session
if not __name__ == 'qt':
# Make available under global 'qt' name for consistency,
# and so we can refer to SyntheticChildrenProvider below.
internal_dict['qt'] = internal_dict[__name__]
dumper = SummaryDumper.initialize()
type_category = 'Qt'
@@ -2462,14 +2468,10 @@ def __lldb_init_module(debugger, internal_dict):
# Synthetic children
debugger.HandleCommand("type synthetic add -x '^Q.*$' -l %s -w %s"
% ("lldbbridge.SyntheticChildrenProvider", type_category))
% ("qt.SyntheticChildrenProvider", type_category))
debugger.HandleCommand('type category enable %s' % type_category)
if not __name__ == 'qt':
# Make available under global 'qt' name for consistency
internal_dict['qt'] = internal_dict[__name__]
if __name__ == "lldbbridge":
try: