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

Allow reading from stdin #167

Closed
Armando-CodeCafe opened this issue Mar 18, 2024 · 4 comments
Closed

Allow reading from stdin #167

Armando-CodeCafe opened this issue Mar 18, 2024 · 4 comments
Labels

Comments

@Armando-CodeCafe
Copy link

Currently it is not possible to read from STDIN while debugging an application. This makes is pretty much impossible to debug console applications as the moment a single Console.ReadLine() is met the application will throw a System.InvalidOperation Exception due to the console class not being able to read from anything.

Is there plans to implement this? shouldnt be all to hard considering almost every debugger can do this either natively or by running a seperate console to do the work from.

@viewizard
Copy link
Member

Not sure we will implement this for MI/GDB or VSCode protocols, since this mean support external console for application stdin/stdout, that not in plans.

Works fine with CLI:

viewizard@VirtualBox123:~/Desktop/projects/netcoredbg/bin$ ./netcoredbg -- dotnet '/home/viewizard/Desktop/projects_test/test_interop/bin/Debug/net6.0/test_interop.dll'
ncdb> r

thread created, id: 5595
^running

library loaded: /home/viewizard/Desktop/SDK/dotnet-sdk/shared/Microsoft.NETCore.App/6.0.22/System.Private.CoreLib.dll
no symbols loaded, base address: 0x7f4f102b0000, size: 10610176(0xa1e600)

library loaded: /home/viewizard/Desktop/projects_test/test_interop/bin/Debug/net6.0/test_interop.dll
symbols loaded, base address: 0x7f4f882b3000, size: 6144(0x1800)

library loaded: /home/viewizard/Desktop/SDK/dotnet-sdk/shared/Microsoft.NETCore.App/6.0.22/System.Runtime.dll
no symbols loaded, base address: 0x7f4f882ab000, size: 32256(0x7e00)

library loaded: /home/viewizard/Desktop/SDK/dotnet-sdk/shared/Microsoft.NETCore.App/6.0.22/System.Threading.Thread.dll
no symbols loaded, base address: 0x7f4f882a9000, size: 5632(0x1600)

library loaded: /home/viewizard/Desktop/SDK/dotnet-sdk/shared/Microsoft.NETCore.App/6.0.22/System.Console.dll
no symbols loaded, base address: 0x7f4f10e30000, size: 376832(0x5c000)

library loaded: /home/viewizard/Desktop/SDK/dotnet-sdk/shared/Microsoft.NETCore.App/6.0.22/System.Runtime.InteropServices.dll
no symbols loaded, base address: 0x7f4f10e90000, size: 238592(0x3a400)

library loaded: /home/viewizard/Desktop/SDK/dotnet-sdk/shared/Microsoft.NETCore.App/6.0.22/System.Threading.dll
no symbols loaded, base address: 0x7f4f10ed0000, size: 266752(0x41200)

library loaded: /home/viewizard/Desktop/SDK/dotnet-sdk/shared/Microsoft.NETCore.App/6.0.22/Microsoft.Win32.Primitives.dll
no symbols loaded, base address: 0x7f4f10f40000, size: 210944(0x33800)
Managed: Start

thread created, id: 5618
start thread1
mmmmm234234234
Managed: test input=mmmmm234234234
Managed: test output
Native: Start
native_method_test1

thread exited, id: 5618
werwerwer1234234234234234
Native: test input=werwerwer1234234234234234
native_method_test1
native_method_test2
test_delegate
test_delegate
Native: test output
Native: End

thread created, id: 5620

thread exited, id: 5620
Managed: End

thread created, id: 5616

stopped, reason: exited, exit-code: 0
^exit

@Armando-CodeCafe
Copy link
Author

Hmm odd, whenever running this from cli with a simple console app it always returns a System.InvalidOperation with a message saying the application is probably not ran through an interactive console or stdin is being redirected

@Armando-CodeCafe
Copy link
Author

Update: found out readline is fine but readkey returns the error. Could be due to some oddities in how console.readkey deals with terminal events?

@viewizard
Copy link
Member

I also could reproduce this issue with Console.ReadKey(). Looks like Console.ReadKey() can't work with layer we have implemented over real console for debuggee process.

@viewizard viewizard added the bug label Mar 18, 2024
@Armando-CodeCafe Armando-CodeCafe closed this as not planned Won't fix, can't repro, duplicate, stale Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants