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

Delve doesn't attach #178

Open
pjebs opened this issue Jan 24, 2018 · 6 comments
Open

Delve doesn't attach #178

pjebs opened this issue Jan 24, 2018 · 6 comments

Comments

@pjebs
Copy link

pjebs commented Jan 24, 2018

For some reason, Delve debugger doesn't attach to programs that use this package

gdlv run *.go (gdlv is just a graphical front-end for delve)

OUTPUT error:
runtime.main_main·f: relocation target main.main not defined
runtime.main_main·f: undefined: "main.main"

exit status 2
@rationull
Copy link
Contributor

When I try to run a termbox application of mine with gdlv on macOS or Linux, I definitely hit some issues with input handling but do not see the error message you mention -- I can successfully attach to the application. Maybe there's something peculiar about your project layout that could help point to the issue?

@pjebs
Copy link
Author

pjebs commented Jan 28, 2018

That error no longer displays but it still doesn't work. Nothing happens. In fact, gdlv just appears to be frozen.

@rationull
Copy link
Contributor

rationull commented Jan 28, 2018

I have never used gdlv (or dlv itself) before testing this out, but we might be seeing the same issue. Have you tried typing "continue" in the text box at the bottom of the section of the window that has the play button in it and shows the delve console?

I can get the debuggee to run that way (it seems to start paused) but once I do that I can't get the debuggee to stop again, nor to respond correctly to keyboard/mouse input. I wonder if delve or gdlv is doing something that interferes with the terminal input modes termbox uses.

I see the same problems when I attach to an existing process and when I start the process via gdlv. You too?

@pjebs
Copy link
Author

pjebs commented Jan 28, 2018

that's exactly what happens to me. I use delve for all my other Go programs and i've never had any issues. I do the same process:

gdlv debug *.go
b <filename>:<line nu> //inside gdlv

and use to continue and step buttons. Works all the time except for this program.

@nsf
Copy link
Owner

nsf commented Jan 28, 2018

Related: #154

Sorry for not looking at it. Probably won't do it any time soon.

@teolandon
Copy link

A workaround is to run the termbox-go application, and then attach with delve from another terminal.

./tb-app
dlv attach <PID>

This allows delve to manipulate the terminal in its own terms, while termbox-go manipulates the other terminal in its own. It's a bit more tedious, especially since you need to find the PID of the app you're debugging, and you might want to block the app's execution until after you've attached, probably using a signal. But using the $! variable in bash you can easily get the PID of the last process and automate this using a small script (works especially well with a terminal multiplexer, since you can actually execute things in both terminals through the script to set everything up).

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

4 participants