-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
add GoDebug #1390
add GoDebug #1390
Conversation
Maybe, there are not enough commands, features, behaviors. |
A previous PR: #1198 |
@mattn so happy that you working on this. I'm on road to NYC, but hopefully gonna take a look more in detail. I think this is possible now that vim-8 has term support. Do you know which patch version should be cap it? I think we should add something like this:
or better if you have the patch version that would be better. I think people should use an updated Vim version otherwise we have to deal with problems that are already fixed on HEAD in vim-dev. |
Ultimately, I did not use vim8 terminal feature for this debugger. Just used |
I haven't had time to look at this before, but I just tested it and this is great stuff! It already works very well. I made a PR on your fork with a bunch of minor changes: mattn#1; that was easier than adding comments :-) See the commit messages for details on that. I also did some work on improving and expanding the documentation a bit but didn't commit that yet; I'll finish that up later. Some further comments (Vim 8.0.1066, Go 1.9):
|
Did some more testing, and found a few more small problems:
|
autoload/go/debug.vim
Outdated
@@ -381,6 +381,7 @@ function! go#debug#Start(...) abort | |||
try | |||
echohl SpecialKey | echomsg 'Starting GoDebug...' | echohl None | |||
let s:state['message'] = [] | |||
exe 'lcd' fnamemodify(bufname(''), ':p:h') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this cause the current working directory to change? :pwd
gives me /home/martin/go/src/a
when starting vim dbg/debug.go
, but it's /home/martin/go/src/a/debug
after running :GoDebugStart
.
Also, I get an error using :GoDebugStart
with the latest changes?
can't load package: package ['--']: cannot find package "['--']" in any of:
/usr/lib/go/src/['--'] (from $GOROOT)
/home/martin/go/src/['--'] (from $GOPATH)
/home/martin/work/src/['--']
exit status 1
Maybe it's worth adding some tests for this? I never really looked in to testing Vimscript stuff so I don't know how hard that is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed for ["--"]
.
lcd
change current directory for current window.
What are your plans for supporting Neovim btw @mattn? It currently errors out with |
Go debugger uses JSON-RPC to communicate with dlv debugger. neovim support TCP connection? |
I don't know; never looked in to Neovim's implementation in detail. Personally I'm fine with not adding support for that in this PR if it's hard, but then we should add a clear error message for that similar to the Vim 7.4 error ( |
We should not add NeoVim now. First, let finish making the UX and usability right. And then fix bugs and co. once it's in master. Neovim can wait as Vim-go aims to be a Vim first class plugin rather than supporting both nvim and vim. |
As it's not yet supported; otherwise it will give a confusing error. fatih#1390 (comment)
As it's not yet supported; otherwise it will give a confusing error. fatih#1390 (comment)
There are some areas that might need some further improving – there always are – but overall it works well and I don't expect any further major changes to the It's currently a bit slow for larger packages because Aside from the See |
I want to test it before we merge it. Please don't merge it until then. I appreciate all the hard work btw, I think this is going to be one of the biggest addition in 2018 :) |
I think this command makes more sense, as it "prints the result from an expression". It's also the command that the dlv commandline uses (`p` or `print`).
I'm not sure when this is useful? Remove for now.
- Delve needs `stepOut`, not `stepout`. This took me an insane amount of time to track down :-/ - Add `debugger-commands` to `g:go_debug`; useful to track down the above. - Remove stepin, as Delve doesn't seem to support that. The current implementation doesn't do anything, and it's not listed as one of the constants in `service/api/types.go` (around like 265).
Much better UX, I think. Especially since starting dlv can take a bit; this will reduce the time people will need spend fiddling their thumbs.
Need to remove the BufWipe events, as that would cause problems with them stopping the newly created async job. Not sure if that was a good idea in the first place to be honest, why shouldn't I be allowed to remove one of the windows from the layout?
Otherwise hovering over a string and lots of other stuff will show errors.
@@ -28,7 +29,6 @@ This plugin adds Go language support for Vim, with the following main features: | |||
errors, or make sure errors are checked with `:GoErrCheck`. | |||
* Advanced source analysis tools utilizing `guru`, such as `:GoImplements`, | |||
`:GoCallees`, and `:GoReferrers`. | |||
* Precise type-safe renaming of identifiers with `:GoRename`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this removed accidentally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember correctly, at some point it was decided to keep the top 10 or 15 points from the help file here instead of all. So I removed the bottom one after I added the debug feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove the automatic gopath
detection line and keep this? I think the GOPATH one can change as it's less relevant nowadays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, sounds good
doc/vim-go.txt
Outdated
DEBUGGER COMMANDS~ | ||
|
||
Only |:GoDebugStart| and |:GoDebugBreakpoint| are available by default; the | ||
rest of the commands become available after starting debug mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commands and mappings...
Worth noting that we also create default mappings
doc/vim-go.txt
Outdated
in with |:GoDebugStep| (<F11>). | ||
|
||
Struct values are displayed as `{...}`, array/slices as `[4]`. Use <CR> on the | ||
variable name to expand the values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, but I didn't know I had to go to the GODEBUG_VARIABLES
window. Worth adding this little piece. Actually we should document more each window. We just mentioned them briefly above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I rephrased it a bit and added some more info.
doc/vim-go.txt
Outdated
variable name to expand the values. | ||
|
||
When you're done use |:GoDebugStop| to close the debugging windows and halt | ||
the `dlv` process, or |:GoDebugRestart| to recompile the code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can I clear previously set breakpoints? Even though I've stopped or restarted the server, the breakpoints are still intact. Is this something we can provide to the user? Seems like there is no way to remove all breakpoints right now and you have to manually remove them one by one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh it seems like restarting Vim does remove all breakpoints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add a :GoDebugReset
command maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeap definitely, I think this is much needed otherwise one has to close and restart Vim (which is not something we want to do). Also another thing that I've just seen is, when you change or remove the lines, the breakpoint lines will be invalid. Not %100 related to this, but worth adding as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when you change or remove the lines, the breakpoint lines will be invalid. Not %100 related to this, but worth adding as well.
How do other debuggers handle this? Move the breakpoint, or just clear it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In VSCode it moves when you add newlines. So it's dynamic to the content of the line. But not sure if it's worth adding that kind of complexity. But one thing I appreciate is the way to disable/enable breakpoints. This allows to temporary run the whole stack without getting blocked. And they also have something to reset all the breakpoints. So I think we need the following commands:
:GoDebugToggleBreakpoint (current :GoDebugBreakpoint, we can keep this)
:GoDebugDisableBreakpoints
:GoDebugEnableBreakpoints
:GoDebugRemoveBreakpoints
Also I think :GoDebugReset
would be confusing with :GoDebugRestart
. So don't let us use :GoDebugReset
(Instead let's use :GoDebugRemoveBreakpoints
), instead let's have the above dedicated commands. We can add :GoDisableBreakpoints
and :GoEnableBreakpoints
later if it's to much work. Wdyt?
(Here is the Debug menu from VSCode)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not so sure of adding four new commands, I find it more annoying to use as e.g. :GoDebug<Tab>
now has many more commands that are pretty much the same.
I think a better way is to use e.g.:
:GoDebugBreakpoint 42 " Toggle breakpoint for a line (add/remove)
:GoDebugBreakpoint toggle " Toggle all
:GoDebugBreakpoint disable " Disable all
:GoDebugBreakpoint enable " Enable all
:GoDebugBreakpoint remove " Remove all
That being said, I think we should make an issue for this after merging this. It definitely should be done one way or the other, but I don't think it's a critical feature to add right now.
Same applies to the other issue with the wrong line. It's definitely something that needs to be improved, but not necessarily in this PR. It's already a large PR, and tracking all comments on GitHub is kind of hard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with that. Let's talk about the UI changes later (command and co).
Thanks a lot for the hard work. There are couple of things that I think needs clarification, otherwise it looks good. |
Codecov Report
@@ Coverage Diff @@
## master #1390 +/- ##
=========================================
- Coverage 22.2% 19.7% -2.51%
=========================================
Files 53 57 +4
Lines 4197 4735 +538
=========================================
+ Hits 932 933 +1
- Misses 3265 3802 +537
Continue to review full report at Codecov.
|
@mattn @Carpetsmoker lgtm. This is ready to be merged. let's merge this and then open new PR's upon feedback and things we see later (such as the breakpoint improvements). Thanks again for all the hard work, much appreciated. |
Great. Thank you! |
See fatih/vim-go#1390 Change-Id: I5d79ce162d466351ca54e435183e4e2e3151ad2c GitHub-Last-Rev: 4ec9a16 GitHub-Pull-Request: golang#21
See fatih/vim-go#1390 Change-Id: I59a45a207b68d08c53d4f16ff4240a28d145c1a1 Reviewed-on: https://go-review.googlesource.com/c/blog/+/169537 Reviewed-by: Austin Clements <austin@google.com>
See fatih/vim-go#1390 Change-Id: I59a45a207b68d08c53d4f16ff4240a28d145c1a1 Reviewed-on: https://go-review.googlesource.com/c/blog/+/169537 Reviewed-by: Austin Clements <austin@google.com> X-Blog-Commit: 6bedf551f6d7d21cf7f656a0748ca65bf387b884
See fatih/vim-go#1390 Change-Id: I59a45a207b68d08c53d4f16ff4240a28d145c1a1 Reviewed-on: https://go-review.googlesource.com/c/blog/+/169537 Reviewed-by: Austin Clements <austin@google.com> X-Blog-Commit: 6bedf551f6d7d21cf7f656a0748ca65bf387b884
Hi, I added debugger. Do you have interesting this?