[lldb-dev] RFC: full support for python files, and avoid using FILE* internally

Larry D'Anna via lldb-dev lldb-dev at lists.llvm.org
Fri Sep 20 08:35:50 PDT 2019

Hi lldb-dev.

I want to be able to use LLDB inside of iPython, so I can have mixed python and LLDB debug session.   

To this end, I’d like to update LLDB to have full support for python file objects, so the outputs of debugger commands can be redirected into iPython’s own streams.

This however, is difficult to do, because LLDB makes use of FILE* streams in a number of places.   This presents two problems.  The first is that there is no really
correct way to create SWIG typemaps that handle conversion to FILE* and get the ownership semantics correct.   The second problem is that there is not a portable 
way to make a FILE* with arbitrary callbacks for reading and writing.   On Darwin and BSD there’s funopen, and on linux there’s something else, and I don’t know if 
there’s any way on windows.

I made an attempt at this a while ago using funopen a while ago, here:

https://reviews.llvm.org/D38829 <https://reviews.llvm.org/D38829>

Zachary Turner suggested a more thorough approach. where instead of trying to use funopen to paper over all the use of FILE* streams, we should make 
lldb_private::File capable of doing the dynamic dispatch and excise all the unnecessary FILE* stuff in favor of lldb_private::File.   

That’s what I’ve done here:  https://github.com/smoofra/llvm-project/tree/files <https://github.com/smoofra/llvm-project/tree/files>

I’ve posted the first few patches to phabricator for review.

https://reviews.llvm.org/D67793 <https://reviews.llvm.org/D67793>
https://reviews.llvm.org/D67792 <https://reviews.llvm.org/D67792>
https://reviews.llvm.org/D67789 <https://reviews.llvm.org/D67789>

What do you think?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20190920/80e31bd6/attachment.html>

More information about the lldb-dev mailing list