This is an archive of the discontinued LLVM Phabricator instance.

[LLGS] Don't forward I/O when process is stopped
ClosedPublic

Authored by labath on Nov 26 2015, 5:15 AM.

Details

Summary

This makes sure we do not attempt to send output over the gdb-remote protocol when the client is
not expecting it (i.e., after sending the stop-reply packet). Normally, this should not happen
(the process cannot generate output when it is stopped), but due to the fact that pty
communication is asynchronous in the linux kernel (llvm.org/pr25652), we may sometimes get this
output too late. Instead, we just hold the output, and send it next time we resume. This is not
ideal, but at least it makes sure we do not violate the remote protocol. Given that this happens
extremely rarely it's not worth trying to work around it with sleeps or something like that.

I also remove the m_stdio_communication_mutex, as all of LLGS is now single-threaded anyway.

Diff Detail

Repository
rL LLVM

Event Timeline

labath updated this revision to Diff 41241.Nov 26 2015, 5:15 AM
labath retitled this revision from to [LLGS] Don't forward I/O when process is stopped.
labath updated this object.
labath added reviewers: tberghammer, ovyalov.
labath added a subscriber: lldb-commits.
tberghammer accepted this revision.Nov 26 2015, 8:21 AM
tberghammer edited edge metadata.

LGTM

source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
1014 ↗(On Diff #41241)

Can you add an assert that m_stdio_handle_up is nullptr when StartSTDIOForwarding is called?

This revision is now accepted and ready to land.Nov 26 2015, 8:21 AM
This revision was automatically updated to reflect the committed changes.
labath marked an inline comment as done.