[Lldb-commits] [PATCH] D68962: update ScriptInterpreterPython to use File, not FILE*

Lawrence D'Anna via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 14 16:40:20 PDT 2019


lawrence_danna created this revision.
lawrence_danna added reviewers: JDevlieghere, jasonmolenda, labath.
Herald added a project: LLDB.

ScriptInterpreterPython needs to save and restore sys.stdout and 
friends when LLDB runs a python script.

It currently does this using FILE*, which is not optimal.  If 
whatever was in sys.stdout can not be represented as a FILE*, then 
it will not be restored correctly when the script is finished.

It also means that if the debugger's own output stream is not 
representable as a file, ScriptInterpreterPython will not be able 
to redirect python's  output correctly.

This patch updates ScriptInterpreterPython to represent files with 
lldb_private::File, and to represent whatever the user had in 
sys.stdout as simply a PythonObject.

This will make lldb interoperate better with other scripts or programs
that need to manipulate sys.stdout.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68962

Files:
  lldb/packages/Python/lldbsuite/test/python_api/file_handle/TestFileHandle.py
  lldb/source/Core/Debugger.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68962.224934.patch
Type: text/x-patch
Size: 10952 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191014/10d1f5d0/attachment-0001.bin>


More information about the lldb-commits mailing list