aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ScriptInterpreter/Python
diff options
context:
space:
mode:
authorMichał Górny <mgorny@moritz.systems>2021-09-29 17:51:51 +0200
committerMichał Górny <mgorny@moritz.systems>2021-10-01 12:53:21 +0200
commit58b4501eeabb2728a5c48e05295f3636db0ecee1 (patch)
tree37e787ec00ff3fe3dadf19bb01229c05101b94a4 /lldb/source/Plugins/ScriptInterpreter/Python
parent512aa8485010009f6ec1b8d9deea3effe67e0106 (diff)
downloadllvm-58b4501eeabb2728a5c48e05295f3636db0ecee1.zip
llvm-58b4501eeabb2728a5c48e05295f3636db0ecee1.tar.gz
llvm-58b4501eeabb2728a5c48e05295f3636db0ecee1.tar.bz2
[lldb] [Host] Refactor TerminalState
Refactor TerminalState to make the code simpler. Move 'struct termios' to a PImpl-style subclass. Add an RAII interface to automatically store and restore the state. Differential revision: https://reviews.llvm.org/D110721
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp1
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h9
2 files changed, 2 insertions, 8 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 5bbb673..6759506 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -355,7 +355,6 @@ private:
PyEval_InitThreads();
}
- TerminalState m_stdin_tty_state;
PyGILState_STATE m_gil_state = PyGILState_UNLOCKED;
bool m_was_already_initialized = false;
};
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
index 33afd02..b6926b6 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -430,11 +430,9 @@ public:
int stdin_fd = GetInputFD();
if (stdin_fd >= 0) {
Terminal terminal(stdin_fd);
- TerminalState terminal_state;
- const bool is_a_tty = terminal.IsATerminal();
+ TerminalState terminal_state(terminal);
- if (is_a_tty) {
- terminal_state.Save(stdin_fd, false);
+ if (terminal.IsATerminal()) {
terminal.SetCanonical(false);
terminal.SetEcho(true);
}
@@ -464,9 +462,6 @@ public:
run_string.Printf("run_python_interpreter (%s)",
m_python->GetDictionaryName());
PyRun_SimpleString(run_string.GetData());
-
- if (is_a_tty)
- terminal_state.Restore();
}
}
SetIsDone(true);