summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core
diff options
context:
space:
mode:
authorLawrence D'Anna <lawrence_danna@apple.com>2019-10-16 01:58:15 +0000
committerLawrence D'Anna <lawrence_danna@apple.com>2019-10-16 01:58:15 +0000
commitb07823f3e2da9b1c6f1866bf1725cfff5eea5b48 (patch)
tree95250eceb57a07459348d7d6f3e4aa4231c7b6c7 /lldb/source/Core
parent9d10b9d99b4d93114eb5d879878fcbb70f2d5b75 (diff)
downloadbcm5719-llvm-b07823f3e2da9b1c6f1866bf1725cfff5eea5b48.tar.gz
bcm5719-llvm-b07823f3e2da9b1c6f1866bf1725cfff5eea5b48.zip
update ScriptInterpreterPython to use File, not FILE*
Summary: 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. Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68962 llvm-svn: 374964
Diffstat (limited to 'lldb/source/Core')
-rw-r--r--lldb/source/Core/Debugger.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 6a3604c098d..18397d00dca 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -973,34 +973,31 @@ void Debugger::AdoptTopIOHandlerFilesIfInvalid(FileSP &in, StreamFileSP &out,
std::lock_guard<std::recursive_mutex> guard(m_input_reader_stack.GetMutex());
IOHandlerSP top_reader_sp(m_input_reader_stack.Top());
// If no STDIN has been set, then set it appropriately
- if (!in) {
+ if (!in || !in->IsValid()) {
if (top_reader_sp)
in = top_reader_sp->GetInputFileSP();
else
in = GetInputFileSP();
-
// If there is nothing, use stdin
if (!in)
in = std::make_shared<NativeFile>(stdin, false);
}
// If no STDOUT has been set, then set it appropriately
- if (!out) {
+ if (!out || !out->GetFile().IsValid()) {
if (top_reader_sp)
out = top_reader_sp->GetOutputStreamFileSP();
else
out = GetOutputStreamSP();
-
// If there is nothing, use stdout
if (!out)
out = std::make_shared<StreamFile>(stdout, false);
}
// If no STDERR has been set, then set it appropriately
- if (!err) {
+ if (!err || !err->GetFile().IsValid()) {
if (top_reader_sp)
err = top_reader_sp->GetErrorStreamFileSP();
else
err = GetErrorStreamSP();
-
// If there is nothing, use stderr
if (!err)
err = std::make_shared<StreamFile>(stderr, false);
OpenPOWER on IntegriCloud