[Lldb-commits] [PATCH] D38829: Python: SetOutputFileHandle doesn't work with IOBase

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 2 11:59:46 PDT 2017


clayborg added a comment.

In https://reviews.llvm.org/D38829#914300, @zturner wrote:

> Ok, I wasn't aware of the libedit problem.
>
> I still don't like this approach, because it causes the design of the `File` class to be influenced by a limitation of a 3rd party library.
>
> What about adding a method to `IOObject` called `FILE *GetFileStream()`.  Then the method I proposed earlier would just involve `PythonFileIo` implementing this in the proper way.  Then we can pass `SBFile` or `lldb_private::File` through all layers of the codebase, and once we're in libedit we just call `file.GetFileStream()` and pass it to libedit?


That could work. If we don't get a "FILE *" back from IOObject::GetFileStream() we need to fall back onto a simple implementation. The current IOHandler will fall back to fgets() on a FILE*, but we can easily make it just call a method on IOObject. Probably would be best to add a fgets() type call to IOObject so the underlying implementation can do this as efficiently as possible.

I mainly care that the current API continues to work with "FILE *" at least on all Unix based platforms. We can add new APIs, but we must leave the existing ones there.


Repository:
  rL LLVM

https://reviews.llvm.org/D38829





More information about the lldb-commits mailing list