2017-09-02 172 views
1

我在努力寻找这一良好的文档,而我还没有能够证实LLDB是否应该与Python 3工作或没有(见LLDB-Python reference在Mac上导入Python 3中的LLDB?

当试图将其加载为如下:

import sys 
sys.path.append('/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python') 
import lldb 

这适用于蟒2(2.7是精确的),但是在Python 3(3.6是精确的),我得到一个错误(见结束全STRACK跟踪):

ImportError: dynamic module does not define module export function (PyInit__lldb) 

有什么我可以做的,能够在Python 3中导入lldb


完整的堆栈:

ImportError        Traceback (most recent call last) 
<ipython-input-3-2a8839b33e40> in <module>() 
----> 1 import lldb 

/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python/lldb/__init__.py in <module>() 
    48     fp.close() 
    49    return _mod 
---> 50  _lldb = swig_import_helper() 
    51  del swig_import_helper 
    52 else: 

/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python/lldb/__init__.py in swig_import_helper() 
    44   if fp is not None: 
    45    try: 
---> 46     _mod = imp.load_module('_lldb', fp, pathname, description) 
    47    finally: 
    48     fp.close() 

~/Virtualenvs/py36/lib/python3.6/imp.py in load_module(name, file, filename, details) 
    240     return load_dynamic(name, filename, opened_file) 
    241   else: 
--> 242    return load_dynamic(name, filename, file) 
    243  elif type_ == PKG_DIRECTORY: 
    244   return load_package(name, filename) 

~/Virtualenvs/py36/lib/python3.6/imp.py in load_dynamic(name, path, file) 
    340   spec = importlib.machinery.ModuleSpec(
    341    name=name, loader=loader, origin=path) 
--> 342   return _load(spec) 
    343 
    344 else: 

ImportError: dynamic module does not define module export function (PyInit__lldb) 

回答

1

据我了解,这是行不通的。 LLDB是针对Python 2.7构建的,无法将Python 2.x模块导入Python 3.x.

可以根据Python 3.x库构建您自己的lldb副本 - 我们需要为Windows执行此操作,以便将源设置为使用任一版本进行构建。

我从来没有在Mac上试过它,而且Xcode项目目前还没有成立,所以它不应该那么难。如果您对此感兴趣并有更多疑问,请通过lldb-dev邮件列表询问他们:

http://lists.llvm.org/mailman/listinfo/lldb-dev