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 specify build-flags #25

Open
JensAc opened this issue Mar 9, 2022 · 5 comments
Open

How to specify build-flags #25

JensAc opened this issue Mar 9, 2022 · 5 comments

Comments

@JensAc
Copy link

JensAc commented Mar 9, 2022

Hi,

first of all, thank you for providing go-dlv. I was able to get up and running quire quickly with it.
However, I have an issue debugging an application with a more sophisticated command line call.
For instance, I have a call like this:

dlv debug SOME_FOLDER --build-flags="-mod=vendor -ldflags='-X k8s.io/component-base/version.gitMajor=1'" -- FURTHER_APP_OPTIONS

This works just fine, when executed from a shell but when I paste this to the minibuffer opened by thedlv emacs function, I get

Error: unknown shorthand flag: 'm' in -mod=vendor -ldflags='-X k8s.io/component-base/version.gitMajor=1

Do you have any idea, what am I doing wrong?

@benma
Copy link
Owner

benma commented Mar 10, 2022

If I run this in a shell, I get the same error:

$ dlv debug -mod=vendor
  Error: unknown shorthand flag: 'm' in -mod=vendor

So it seems this flag is not supported by dlv in general.

@JensAc
Copy link
Author

JensAc commented Mar 10, 2022

Indeed, you need to run it as part of the --build-flags arguments of dlv. Then, dlv should start as usual.
I think there is something going wrong how the actual debugger command line is constructed in gud.

@benma
Copy link
Owner

benma commented Mar 10, 2022

I'm afraid you'll need to file this bug report at Emacs. in gud-common-init, split-string-and-unquote is used on the command:

https://github.com/emacs-mirror/emacs/blob/c6e079ae15002268d90869a43f66d962175e4cdb/lisp/progmodes/gud.el#L2766

(split-string-and-unquote "dlv debug --build-flags=\"-mod=vendor\"") e.g. yields ("dlv" "debug" "--build-flags=" "-mod=vendor"). I am not sure what the rest of gud-common-init is doing to these words, but the result seems wrong.

@JensAc
Copy link
Author

JensAc commented Mar 10, 2022

Alright, that was also the point where I stopped investigating. I will have another look at this, when I find time. Thank you for the quick response!

@JensAc
Copy link
Author

JensAc commented Mar 11, 2022

Actually, a workaround seems to be:

dlv debug SOME_FOLDER --build-flags "-mod=vendor"

(omitting the equal sign).
However, I did not find a way to specify ldflags also, but I think in debugging scenarios this is not that important.

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

2 participants