go-prompt
go-prompt copied to clipboard
Panic while debugging using VSCODE linux
Bug reports
When placing a breakpoint is my code, the program is panicking
Expected Behavior
Debugging go-prompt application should not make the program panicking
Current Behavior and Steps to Reproduce
Place a break point into some of provided examples, let say in completer function When the breakpoint is reached, the debug console shows:
API server listening at: 127.0.0.1:24621
]2;sql-prompt
panic: inappropriate ioctl for device
goroutine 1 [running]:
github.com/c-bata/go-prompt.(*PosixParser).GetWinSize(0xc4200220a0, 0x0)
/home/simulot/go/src/github.com/c-bata/go-prompt/posix_input.go:113 +0x16e
github.com/c-bata/go-prompt.(*Prompt).setUp(0xc42008a060)
/home/simulot/go/src/github.com/c-bata/go-prompt/prompt.go:264 +0x69
github.com/c-bata/go-prompt.(*Prompt).Run(0xc42008a060)
/home/simulot/go/src/github.com/c-bata/go-prompt/prompt.go:49 +0x9e
main.main()
/home/simulot/go/src/github.com/c-bata/go-prompt/_example/echo/main.go:30 +0x120
...
Context
-
Operating System: ubuntu mint 18.3
go version go1.10.1 linux/amd64 -
Terminal Emulator: (i.e. iTerm2) vscode 1.23.1 integrated terminal
-
tag of go-prompt or commit revision: I have used go get command.
(this is just a memo for me)
A current commit revision is 2f3ee57 . This panic is raised at https://github.com/c-bata/go-prompt/blob/2f3ee57cf5d006ef778e5fab923ed0022eba2168/posix_input.go#L106-L114
And maybe retCode was 25
Let me know if I can help.
I don't know why this panic is raised but ptrace system call that is used by GDB for tracing processes may disturb ioctl execution.
I found a similar issue, but this issue is not resolved. https://github.com/quarnster/SublimeGDB/issues/38
In fact, the problem is not in your code, but somewhere in between vs-code and dlv. It seems that stdin is not available in the debuging context. Someone has suggested to use dlv headless feature... and this works.
First, add a launch configuration for remote in launch.json
{
"name": "Remote",
"type": "go",
"request": "launch",
"mode": "remote",
"remotePath": "${workspaceRoot}",
"port": 2345,
"host": "127.0.0.1",
"program": "${workspaceRoot}",
"env": {}
}
In the terminal windows, in the package folder, launch dlv:
dlv debug --headless --listen=:2345
Then launch the debug session using the remote configuration.