[lldb-dev] Returning multiple values in Python API function

Francis Ricci via lldb-dev lldb-dev at lists.llvm.org
Fri Oct 21 13:03:13 PDT 2016


Hi all,

I'm looking to add Platform::LaunchGDBServer() to the SBPlatform API,
but it requires two return values - an lldb::pid_t and a string url.
Internally, we just pass by reference, but we can't do that in the
API. Any suggestions on how to do this, since we can't pass primitives
by reference from Python?

My current thinking was to use the pid_t as the return value, and then
figure out a way to communicate the string information as an "out"
function parameter. Ideas there included using an SBStream&, as the
GetDescription() functions do, but that doesn't seem optimal.

In standard Python, we'd just use a tuple return value, but I don't
see any way to do that using the swig interface.

The reasoning behind adding this API function is to prevent the
platform-mode GdbRemote tests from launching the gdbserver using an
'A' packet instead of the standard 'qLaunchGDBServer' packet.

Thanks,
Francis


More information about the lldb-dev mailing list