Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lldb-dap] Implement runInTerminal for Windows #121269

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SuibianP
Copy link

Currently, the named pipe is passed by name and a transient ofstream is constructed at each I/O request. This assumes,

  • Blocking semantics: FIFO I/O waits for the other side to connect.
  • Buffered semantics: Closing one side does not discard existing data.

The former can be replaced by WaitNamedPipe/ConnectNamedPipe on Win32, but the second cannot be easily worked around. It is also impossible to have another "keep-alive" pipe server instance, as server-client pairs are fixed on connection on Win32 and the client may get connected to it instead of the real one.

Refactor FifoFile[IO] to use an open file handles rather than file name.

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@SuibianP
Copy link
Author

SuibianP commented Dec 28, 2024

The patch currently suffers from a critical issue that I cannot diagnose. Help is much appreciated.

When the debug adapter attempts to attach to the launcher,

dap.target.Attach(attach_info, error);

it blocks at

if (::WaitForSingleObject(m_session_data->m_initial_stop_event, INFINITE) ==
WAIT_OBJECT_0) {

although adding the following snippet at the front of RunInTerminalLauncherCommChannel::WaitUntilDebugAdaptorAttaches indicates that the launcher process does get paused and never resumed.

for (int i = 0; !::IsDebuggerPresent(); ++i)
  LLVM_LOGV(log, "Waiting to be attached... {0}", i);
LLVM_LOGV(log, "Attached");

CC @JDevlieghere

Currently, the named pipe is passed by name and a transient ofstream is
constructed at each I/O request. This assumes,
  - Blocking semantics: FIFO I/O waits for the other side to connect.
  - Buffered semantics: Closing one side does not discard existing data.

The former can be replaced by WaitNamedPipe/ConnectNamedPipe on Win32,
but the second cannot be easily worked around. It is also impossible to
have another "keep-alive" pipe server instance, as server-client pairs
are fixed on connection on Win32 and the client may get connected to it
instead of the real one.

Refactor FifoFile[IO] to use an open file handles rather than file name.
@SuibianP SuibianP force-pushed the lldb-dap-runinterminal-windows branch from 4c8c18c to b980d11 Compare December 28, 2024 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant