[lldb-dev] swig v3.0.3 breaks lldb python API (lldb.py)

Greg Clayton gclayton at apple.com
Thu Jan 22 09:38:28 PST 2015


Can you turn off default variable support in swig? You will probably need to detect the swig version first to make sure it supports an option that can disable default variable values before passing the extra option to the swig command line tool, but this would probably fix things no?

Greg

> On Jan 21, 2015, at 3:55 PM, Ilia K <ki.stfu at gmail.com> wrote:
> 
> Hello,
> 
> Today I had errors after updating the SWIG to version 3.0.3.
> 
> After rebuild I can't run any tests because I got the following errors:
> $ ./dotest.py -v --executable $BUILDDIR/bin/lldb
> ['./dotest.py', '-v', '--executable', '/Users/IliaK/p/llvm/build_ninja/bin/lldb']
> LLDB library dir: /Users/IliaK/p/llvm/build_ninja/bin
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
>   File "/Users/IliaK/p/llvm/build_ninja/lib/python2.7/site-packages/lldb/__init__.py", line 1867
>     def RemoveListener(self, listener, event_mask=4294967295U):
>                                                             ^
> SyntaxError: invalid syntax
> lldb-330.99.0
> This script requires lldb.py to be in either /Users/IliaK/p/llvm/tools/lldb/build/Debug/LLDB.framework/Resources/Python, /Users/IliaK/p/llvm/tools/lldb/build/Release/LLDB.framework/Resources/Python, or /Users/IliaK/p/llvm/tools/lldb/build/BuildAndIntegration/LLDB.framework/Resources/Python. Some tests might fail.
> Traceback (most recent call last):
>   File "./dotest.py", line 1295, in <module>
>     os.path.walk(testdir, visit, 'Test')
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 246, in walk
>     walk(name, func, arg)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 246, in walk
>     walk(name, func, arg)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 238, in walk
>     func(arg, top, names)
>   File "./dotest.py", line 1192, in visit
>     suite.addTests(unittest2.defaultTestLoader.loadTestsFromName(base))
>   File "/Users/IliaK/p/llvm/tools/lldb/test/unittest2/loader.py", line 111, in loadTestsFromName
>     module = __import__('.'.join(parts_copy))
>   File "/Users/IliaK/p/llvm/tools/lldb/test/api/check_public_api_headers/TestPublicAPIHeaders.py", line 8, in <module>
>     from lldbtest import *
>   File "/Users/IliaK/p/llvm/tools/lldb/test/lldbtest.py", line 43, in <module>
>     import lldb
> ImportError: No module named lldb
> 
> llvm/build_ninja/lib/python2.7/site-packages/lldb/__init__.py, line 1867:
> def RemoveListener(self, listener, event_mask=4294967295U):
>     """
>     RemoveListener(SBBroadcaster self, SBListener listener, uint32_t event_mask=4294967295U) -> bool
>     RemoveListener(SBBroadcaster self, SBListener listener) -> bool
>     """
>     return _lldb.SBBroadcaster_RemoveListener(self, listener, event_mask)
> 
> Previously with v3.0.2, it looks like:
> def RemoveListener(self, *args):
>     """ 
>     RemoveListener(SBBroadcaster self, SBListener listener, uint32_t event_mask=4294967295U) -> bool
>     RemoveListener(SBBroadcaster self, SBListener listener) -> bool
>     """
>     return _lldb.SBBroadcaster_RemoveListener(self, *args)
> 
> I found that "event_mask=4294967295U" is taken from interface file scripts/Python/interface/SBBroadcaster.i:
> class SBBroadcaster
> {
> ...
>     bool
>     RemoveListener (const lldb::SBListener &listener, uint32_t event_mask = UINT32_MAX);
> 
> As I understood SWIG since v3.0.3 supports default variables (unstable).
> 
> If you already had updated to v3.0.3 the following patch will help you:
> diff --git a/scripts/Python/interface/SBBroadcaster.i b/scripts/Python/interface/SBBroadcaster.i
> index b5e25b6..6fa7d2b 100644
> --- a/scripts/Python/interface/SBBroadcaster.i
> +++ b/scripts/Python/interface/SBBroadcaster.i
> @@ -56,7 +56,7 @@ public:
>      EventTypeHasListeners (uint32_t event_type);
>  
>      bool
> -    RemoveListener (const lldb::SBListener &listener, uint32_t event_mask = UINT32_MAX);
> +    RemoveListener (const lldb::SBListener &listener, uint32_t event_mask = 4294967295);
>      
>      bool
>      operator == (const lldb::SBBroadcaster &rhs) const;
> If not, don't update to this version.
> 
> Bug already has been posted in SWIG's bug tracker: https://github.com/swig/swig/issues/313
> 
> Thanks,
> Ilia
> 
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev





More information about the lldb-dev mailing list