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
- Repository
- rG LLVM Github Monorepo
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 | This instance didn't seem to be used at all. | |
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h | ||
464–465 | 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 | ||
---|---|---|
15–16 | I don't think we need this forward declaration anymore. |
lldb/include/lldb/Host/Terminal.h | ||
---|---|---|
15–16 | 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 | ||
---|---|---|
15–16 | 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. | |
47–49 | I guess it would be good to delete the copy operations as well. |
lldb/include/lldb/Host/Terminal.h | ||
---|---|---|
47–49 | 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 | ||
---|---|---|
47–49 | implicit is fine | |
130 | Maybe call the class Data as well? | |
lldb/source/Host/common/Terminal.cpp | ||
92 | Could we make Save private now? Or even inline it into the constructor ? |
Yes, Debugger::SaveInputTerminalState() does.
lldb/source/Host/common/Terminal.cpp | ||
---|---|---|
92 | Unfortunately, no. Debugger still manually saves/restores. |
I don't think we need this forward declaration anymore.