8from distutils.version
import LooseVersion
12debug =
print if 'QT_LLDB_SUMMARY_PROVIDER_DEBUG' in os.environ \
13 else lambda *a, **k:
None
16 if not reload_module
and MODULE_NAME
in sys.modules:
17 del sys.modules[MODULE_NAME]
19 if sys.version_info[0] >= 3:
20 sys.path.append(os.path.dirname(path))
21 debug(f
"Loading source of Qt Creator bridge from '{path}'")
22 bridge = imp.load_source(MODULE_NAME, path)
24 if not hasattr(bridge,
'__lldb_init_module'):
25 print(
"Could not find '__lldb_init_module'. Ignoring.")
30 session_dict[MODULE_NAME] = bridge
33 debug(f
"Initializing Qt Creator bridge by calling __lldb_init_module(): {bridge}")
34 bridge.__lldb_init_module(debugger, session_dict)
36 if not debugger.GetCategory(
'Qt'):
37 debug(
"Could not find Qt debugger category. Qt Creator summary providers not loaded.")
39 del session_dict[MODULE_NAME]
42 debug(
"Bridge loaded successfully")
45def __lldb_init_module(debugger, session_dict):
46 qtc_env_vars = [
'QTC_DEBUGGER_PROCESS',
'QT_CREATOR_LLDB_PROCESS']
47 if any(v
in os.environ
for v
in qtc_env_vars)
and \
48 not 'QT_FORCE_LOAD_LLDB_SUMMARY_PROVIDER' in os.environ:
49 debug(
"Qt Creator lldb bridge not loaded because we're already in a debugging session.")
55 if MODULE_NAME
in sys.modules:
56 module = sys.modules[MODULE_NAME]
57 debug(f
"Module '{module.__file__}' already imported. Reloading for this session.")
59 bridge =
import_bridge(module.__file__, debugger, session_dict,
62 debug(
"Qt summary providers successfully reloaded.")
65 print(
"Bridge reload failed. Trying to find other Qt Creator bridges.")
68 for path
in os.popen(
'mdfind kMDItemCFBundleIdentifier=org.qt-project.qtcreator'):
70 file =
open(os.path.join(path,
'Contents',
'Info.plist'),
"rb")
73 plist = plistlib.load(file)
76 for key
in [
"CFBundleVersion",
"CFBundleShortVersionString"]:
82 print(f
"Could not resolve version for '{path}'. Ignoring.")
85 versions[version] = path
88 print(
"Could not find Qt Creator installation. No Qt summary providers installed.")
91 for version
in sorted(versions, key=LooseVersion, reverse=
True):
92 path = versions[version]
93 debug(f
"Loading Qt summary providers from Creator Qt {version} in '{path}'")
94 bridge_path =
'{}/Contents/Resources/debugger/lldbbridge.py'.format(path)
97 debug(f
"Qt summary providers successfully loaded.")
100 if 'QT_LLDB_SUMMARY_PROVIDER_DEBUG' not in os.environ:
101 print(
"Could not find any valid Qt Creator bridges with summary providers. "
102 "Launch lldb or Qt Creator with the QT_LLDB_SUMMARY_PROVIDER_DEBUG environment "
103 "variable to debug.")
import_bridge(path, debugger, session_dict, reload_module=False)
QDebug print(QDebug debug, QSslError::SslError error)
file open(QIODevice::ReadOnly)