Skip to content

Conversation

@alt-romes
Copy link
Collaborator

To implement OutputEvents we may need to capture the stdout and stderr of the debuggee. However, if the DAP server is also outputting to stdout and stderr its messages will be mixed up with the debuggee's.

This commit introduces a logging action to ensure it is possible to redirect all of the DAP server's output to a particular handle, thereby separating it from the debuggee.

Fixes #9

To implement OutputEvents we may need to capture the stdout and stderr
of the debuggee. However, if the DAP server is also outputting to stdout
and stderr its messages will be mixed up with the debuggee's.

This commit introduces a logging action to ensure it is possible to
redirect all of the DAP server's output to a particular handle, thereby
separating it from the debuggee.

Fixes haskell-debugger#9
@dmjio
Copy link
Contributor

dmjio commented May 2, 2025

Yea I think this is fine. Curious did you have an issue with the global lock?

I think the intention was to allow both the debugger and server to log to the same Handle, so the server could observe output, and not have it be interleaved. So whoever grabs the lock will always append a message with a newline \n, so from the user's perspective they might see something like this on the server

[DEBUGGER] Breakpoint set
[SERVER] Sending Breakpoint message
[DEBUGEE] Received breakpoint
[SERVER] Received event
[SERVER] Sending message

But we also want to forward the debugger output bytes to VSCode so people can see what the debugger is up to. I don't think we made it that far with the dap-estgi-server.

@alt-romes
Copy link
Collaborator Author

I didn't observe any problems with the lock.

Indeed, with this we implemented support for logging the debugger's output to vscode!

FWIW we chose the same logging library as HLS, and Matthew was already familiar with it IIRC

@alt-romes
Copy link
Collaborator Author

Please land it if you think it's ready.

@dmjio
Copy link
Contributor

dmjio commented May 3, 2025

That is awesome the debugger output is visible in VSCode now 😎

@dmjio dmjio merged commit 8727be8 into haskell-debugger:master May 3, 2025
1 check passed
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.

Debuggee output is mixed with DAP output

3 participants