This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Restore tty attributes on disconnect
AbandonedPublic

Authored by mgorny on Oct 2 2021, 9:28 AM.

Details

Summary

When connecting to a teletype, LLDB sets baud rate and switches it to
raw mode. Restore the original attributes on disconnect.

Diff Detail

Event Timeline

mgorny requested review of this revision.Oct 2 2021, 9:28 AM
mgorny created this revision.
mgorny updated this revision to Diff 376717.Oct 2 2021, 11:58 AM

Make use of Terminal class as well.

labath added a comment.Oct 4 2021, 3:44 AM

Why is it important to restore the tty settings? (just asking, I have no clue about how this is supposed to work)

mgorny added a comment.Oct 4 2021, 4:06 AM

Why is it important to restore the tty settings? (just asking, I have no clue about how this is supposed to work)

Well, maybe my logic is wrong but the idea is that since LLDB overrides serial port parameters, it should restore them to the original state when it's done with the serial port. Roughly the principle that the program cleans up after itself.

Why is it important to restore the tty settings? (just asking, I have no clue about how this is supposed to work)

Well, maybe my logic is wrong but the idea is that since LLDB overrides serial port parameters, it should restore them to the original state when it's done with the serial port. Roughly the principle that the program cleans up after itself.

That does not sound unreasonable, though I'm not sure how much is it actually useful. Do you know if its like standard practice when working with serial ports, ttys and stuff?

TTTT, I'm not very happy that we have _any_ tty code inside the ConnectionFileDescriptorPosix class, so I'm not enthusiastic about expanding it. Let's see how the RFC goes first...

mgorny added a comment.Oct 5 2021, 3:09 AM

That does not sound unreasonable, though I'm not sure how much is it actually useful. Do you know if its like standard practice when working with serial ports, ttys and stuff?

To be honest, I don't really know. GDB doesn't seem to do it. minicom does restore the initial state.

TTTT, I'm not very happy that we have _any_ tty code inside the ConnectionFileDescriptorPosix class, so I'm not enthusiastic about expanding it. Let's see how the RFC goes first...

Do you think we should move it somewhere else? With the parameters being configurable via settings, it will probably make sense to move it into gdb-remote anyway.

mgorny abandoned this revision.Oct 7 2021, 12:05 PM

If at all, this will be part of the new serial port API.