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

How to pass input to the console in vscode mode #80

Open
fenixjiang opened this issue Jan 8, 2022 · 5 comments
Open

How to pass input to the console in vscode mode #80

fenixjiang opened this issue Jan 8, 2022 · 5 comments

Comments

@fenixjiang
Copy link

start netcoredbg.exe with --interpreter=vscode --server, to debug a console app. I had add a request to pass user input to netcoredbg. but how to pass this input to the debugee?

I found there is a ManagedDebugger::ProcessStdin(), used by cliprotocol to pass data to debugee stdin, but not used by vscodeprotocol.

Does some one can give me some suggestion or guide?

@alpencolt
Copy link
Contributor

@fenixjiang you can run application in separate console and attach to it from debugger. stdin/stdout will work from application console.
Handling stdin in VSCode is much more complicated. First VSCode need to support since now it pass vscode protocol commands to application stdin and NCDB get them from it.
CLI protocol works completely different way.

@viewizard could share references to code.

@viewizard
Copy link
Member

We don't support VSCode "console" configuration parameter from VSDBG debug adapter from omnisharp.
Netcoredbg need its own debug adapter and console related host part, see dotnet/vscode-csharp#3943 for more info.

Only in this way netcoredbg could support "console" configuration parameter and provide additional socket connection (for example) to debug adapter in order to work with stdin via external console (forward stdin from debuggee application to IDE).

@6a6ai
Copy link

6a6ai commented Nov 16, 2022

Hello, thanks for the great work you're doing, this project is a lifesaver for those willing to use neovim since ms doesn't allow us to use the vscode debugger. While the lack of "console" parameter support is not a blocker by itself it'd be really great if it was supported. Do you have any plans to add it in the near future or it's not under consideration?

@alpencolt
Copy link
Contributor

@6a6ai unfortunately there is no time for this feature since it's require bug refactoring and affect Linux and windows platforms but we're open for community commits.
You can try this approach #80 (comment) or use CLI.

@jdix531
Copy link

jdix531 commented Aug 26, 2023

In case it might help someone I've been trying to figure out how to debug and get some input together. Best I've gotten looks like this so far:

# terminal a)
dotnet build
dotnet bin/Debug/net7.0/csharp-test.dll

# terminal b)
dbgpid=`ps -ef | grep csharp-test.dll | head -n 1 | xargs -L1 bash -c 'echo $1'`
/path/to/netcoredbg --attach $dbgpid --interpreter=cli
# NOTE: xargs option syntax is -l instead of -L1 for linux I believe (I'm on mac)

This has major drawbacks vs using the vscode mode with repl as it doesn't show as much information without requesting it. There's also needing to know which lines take input (and flopping between terminals) as it seems to just skip it if you step through it. I only just found this pattern and probably will avoid it since it is a bit harsh to use. If I find any other helpful info I will share. Not sure if you can setup breakpoints either so you need to find a way to pause the program and continue stepping from the debugger once attached.

Messy but can work in a pinch perhaps. Now that I got something I'm going to avoid it :).

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

No branches or pull requests

5 participants