[lldb] Limit `nothreadallow` to Python in SWIG bindings
authorJonas Devlieghere <jonas@devlieghere.com>
Thu, 12 Jan 2023 18:15:51 +0000 (10:15 -0800)
committerJonas Devlieghere <jonas@devlieghere.com>
Thu, 12 Jan 2023 18:19:30 +0000 (10:19 -0800)
SWIG allows you to partially disable thread support for a given function
in Python with `nothreadallow`. This functionality is limited to Python,
but until SWIG 4.1, it would silently ignore this for other languages,
such as Lua. New versions of SWIG are more strict and therefore we need
to guard this with `SWIGPYTHON`.

For more details on the functionality, I recommend reading the commit
message from 070a1d562b30.

lldb/bindings/interface/SBValueList.i

index 32543af..e03b5c6 100644 (file)
@@ -105,7 +105,9 @@ public:
     lldb::SBError GetError();
 
     %extend {
+#ifdef SWIGPYTHON
        %nothreadallow;
+#endif
        std::string lldb::SBValueList::__str__ (){
            lldb::SBStream description;
            const size_t n = $self->GetSize();
@@ -124,7 +126,9 @@ public:
                --desc_len;
            return std::string(desc, desc_len);
        }
+#ifdef SWIGPYTHON
        %clearnothreadallow;
+#endif
     }
 
 #ifdef SWIGPYTHON