Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Unable to debug terminal user interface #2151

Closed
delaneyj opened this issue Nov 26, 2018 · 9 comments
Closed

Unable to debug terminal user interface #2151

delaneyj opened this issue Nov 26, 2018 · 9 comments
Labels

Comments

@delaneyj
Copy link

I tried bringing this up in Gopher Slack but no response.

So i have an interesting situation. Here is a super basic TUI

package main

import "github.com/rivo/tview"

func main() {
    box := tview.NewBox().SetBorder(true).SetTitle("Hello, world!")
    if err := tview.NewApplication().SetRoot(box, true).Run(); err != nil {
        panic(err)
    }
}

This runs with go run main.go from the integrated terminal with no issues but gives panic: open /dev/tty: no such device or address

Is there some special settings to have this work in the Debug Console or launch a go app in a new terminal while still attaching the debugger?

My .vscode/launch.json contains

{
            "name": "TestTUI",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "remotePath": "",
            "port": 2345,
            "host": "127.0.0.1",
            "program": "${workspaceRoot}/main.go",
            "env": {},        
}
@ramya-rao-a
Copy link
Contributor

I see the same when debugging using the editor.
I don't see the panic when using dlv directly from the terminal.

Can you see if using gdlv works?

Both gdlv and VS Code use dlv to support the debugging feature.

@delaneyj
Copy link
Author

Doesn't seem to work in gdlv, though I might have something setup incorrectly. Currently I'm launching with this config in vscode

{
            "name": "Run  Editor with external Delve",
            "type": "go",
            "request": "launch",
            "mode": "remote",
            "remotePath":"${workspaceRoot}/cmd/editor",
            "port": 2345,
            "host": "127.0.0.1",
            "program": "${workspaceRoot}/cmd/editor",
},

Using this in a external terminal

#/bin/bash
dlv debug `dirname ${BASH_SOURCE[0]}` -l 0.0.0.0:2345 --api-version=2 --headless=true -- server

Able to hit breakpoints but would obviously like it to show up directly inside of vscode's debug output. If it helps at all go run main.go runs from the integrated terminal. Is there a config flag I'm missing or is this just not possible?

@ramya-rao-a
Copy link
Contributor

Is there a config flag I'm missing or is this just not possible?

I am not sure why this doesnt work in the first place, so I cant really answer this.

The reason I asked you to check out gdlv was that if that doesnt work either, then the issue is with dlv itself and the way clients (gdlv & VS Code) talk to dlv.

Also, since the author of gdlv and dlv are the same, and that they are Go developers themselves, they would be more qualified to figure this out than me :)

@delaneyj
Copy link
Author

I changed the launch.json to

{
            "name": "Run Test",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${workspaceRoot}/cmd/editor/main.go",
},

In Debug Console get the response

API server listening at: 127.0.0.1:21076
2018/11/27 22:30:06 can't exit cleanly: can't run backing tview application: terminal entry not found

So it appears to not be directly tied to dlv, does this help narrow the issue?

@ramya-rao-a
Copy link
Contributor

can't exit cleanly: can't run backing tview application: terminal entry not found

That error is from dlv. So I would say it is related to dlv

@delaneyj
Copy link
Author

presumably, it doesn't allocate a pseudo terminal automatically either.

@ramya-rao-a
Copy link
Contributor

In that case #843 might help (I am not sure), where we are tracking the feature request to use a terminal instead of the debug console when debugging.

@delaneyj
Copy link
Author

I agree that adding terminal is probably what I'm looking for.

Could vscode-go internally launch a new terminal, run headless dlv and attached to the new terminal?
Also closing that terminal on exit as a config option would be an added bonus. Keeping things integrated in vscode would definitely keep the smooth general flow that debugging most apps has.

I'm unfamiliar with the vscode-go code base and don't know if all the right hooks are there to do what I'm proposing.

@ramya-rao-a
Copy link
Contributor

As far as I know, #843 tracks exactly that.

@vscodebot vscodebot bot locked and limited conversation to collaborators Apr 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants