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.
Details
Diff Detail
Event Timeline
lldb/source/Host/common/Terminal.cpp | ||
---|---|---|
124 | I think passing 0 here was a mistake. The Restore() method passed fd instead. | |
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp | ||
358 ↗ | (On Diff #375897) | This instance didn't seem to be used at all. |
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h | ||
468 ↗ | (On Diff #375897) | I'm wondering if we could use the RAII approach here and restore state (if saved) in the destructor. I'm just not 100% sure if that's what Debugger expects. |
lldb/include/lldb/Host/Terminal.h | ||
---|---|---|
20 | I don't think we need this forward declaration anymore. |
lldb/include/lldb/Host/Terminal.h | ||
---|---|---|
20 | You are correct, thanks! |
Overall, this seems like an improvement, though the class is still quite far from what I would consider an ideal state.
lldb/include/lldb/Host/Terminal.h | ||
---|---|---|
20 | This is kind of a step backwards, as in llvm one tries to not expose system headers (https://llvm.org/docs/SupportLibrary.html#don-t-expose-system-headers). Obviously, lldb is quite far from that. I think this is actually what the this code whas trying to achieve, though forward-declaring 3rd party entities is also a somewhat questionable practice. Pimpling it is the canonical solution, although it has its (mostly mental) overhead. | |
53 | I guess it would be good to delete the copy operations as well. |
lldb/include/lldb/Host/Terminal.h | ||
---|---|---|
53 | This is now implicit via PImpl; or do you prefer explicit? |
Is anyone passing save_process_group = true now? If not, I'd really like to delete it, as the implementation is quite scary.
lldb/include/lldb/Host/Terminal.h | ||
---|---|---|
53 | implicit is fine | |
123 | Maybe call the class Data as well? | |
lldb/source/Host/common/Terminal.cpp | ||
83 | Could we make Save private now? Or even inline it into the constructor ? |
Yes, Debugger::SaveInputTerminalState() does.
lldb/source/Host/common/Terminal.cpp | ||
---|---|---|
83 | Unfortunately, no. Debugger still manually saves/restores. |
I don't think we need this forward declaration anymore.