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

feat/#2338: support debug multi goroutine #2463

Merged
merged 10 commits into from
Sep 17, 2019

Conversation

xbsura
Copy link

@xbsura xbsura commented Aug 27, 2019

Now vim-go support multi goroutine debug

Add two command: GoDebugGoroutines to show all goroutines running, GoDebugGoroutine + goroutineId to switch between goroutines

with this request: #2338

@xbsura xbsura changed the title feat: support debug multi goroutine feat-#2338: support debug multi goroutine Aug 27, 2019
@xbsura xbsura changed the title feat-#2338: support debug multi goroutine feat/#2338: support debug multi goroutine Aug 29, 2019
@bhcleek bhcleek added this to the vim-go 1.22 milestone Sep 2, 2019
Copy link
Collaborator

@bhcleek bhcleek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing!. This is good work, and I look forward to integrating it.

I think, though, that probably makes sense to replace the new :GoDebugGoroutines with a window that lists all the goroutines. It should clearly indicate the active goroutine with a preceding *.

What do you think?

let l:res = s:call_jsonrpc('RPCServer.ListGoroutines')
let l:goroutines = l:res.result.Goroutines
if len(l:goroutines) == 0
echom "No Goroutines Running Now..."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change echom here to go#util#EchoWarning?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

try
let l:currentGoroutineId = s:groutineID()
catch
echom "current goroutineId not found..."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change echom here to go#util#EchoWarning?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

try
let l:res = s:call_jsonrpc('RPCServer.Command', {'Name': 'switchGoroutine', 'GoroutineID': str2nr(l:goroutineId)})
call s:stack_cb(l:res)
echom "Switched Goroutine to: " . l:goroutineId
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change echom here to go#util#EchoInfo?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

for l:idx in range(len(l:goroutines))
let l:goroutine = l:goroutines[l:idx]
if l:goroutine.id == l:currentGoroutineId
echom "* Goroutine " . l:goroutine.id . " - " . l:goroutine.userCurrentLoc.file . ":" . l:goroutine.userCurrentLoc.line . " " l:goroutine.userCurrentLoc.function.name . " " . " (thread: " . l:goroutine.threadID . ")"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change echom here to go#util#EchoInfo?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

if l:goroutine.id == l:currentGoroutineId
echom "* Goroutine " . l:goroutine.id . " - " . l:goroutine.userCurrentLoc.file . ":" . l:goroutine.userCurrentLoc.line . " " l:goroutine.userCurrentLoc.function.name . " " . " (thread: " . l:goroutine.threadID . ")"
else
echom " Goroutine " . l:goroutine.id . " - " . l:goroutine.userCurrentLoc.file . ":" . l:goroutine.userCurrentLoc.line . " " l:goroutine.userCurrentLoc.function.name . " " . " (thread: " . l:goroutine.threadID . ")"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change echom here to go#util#EchoInfo?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@xbsura
Copy link
Author

xbsura commented Sep 3, 2019

Thank you for contributing!. This is good work, and I look forward to integrating it.

I think, though, that probably makes sense to replace the new :GoDebugGoroutines with a window that lists all the goroutines. It should clearly indicate the active goroutine with a preceding *.

What do you think?

yes, current goroutine has a * now

ok, I know what do you mean, now when starting godebug, it has four window, I will see where to add one, thanks!

@xbsura
Copy link
Author

xbsura commented Sep 5, 2019

HI:

Now a new window is created when running debug, and I resize some window to make it more resonable, and type enter on goroutine can switch between goroutines just like that:

image

Copy link
Collaborator

@bhcleek bhcleek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking really great. Thank you for the contribution. There's a couple of changes that I'd like to see, but they're nitpicks, so I can do them later if you'd prefer to be done with this. I would appreciate it, though, if you could explain the rationale for why the windows are resized in s:start_cb.

\ 'out': 'botright 10new',
\ 'vars': 'leftabove 30vnew',
\ 'goroutines': 'split 60vnew',
\ 'out': 'botright 100new',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you mean to change this from 10 to 100?

if l:goroutine_win_id != 0
call win_gotoid(l:goroutine_win_id)
exe "resize +6"
endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this resize windows?

endif

let l:cur_win = bufwinnr('')
exe l:var_win 'wincmd w'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use win_gotoid instead of normal mode commands.

call setline(1, v)
finally
setlocal nomodifiable
exe l:cur_win 'wincmd w'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use win_gotoid

@xbsura
Copy link
Author

xbsura commented Sep 6, 2019

This is looking really great. Thank you for the contribution. There's a couple of changes that I'd like to see, but they're nitpicks, so I can do them later if you'd prefer to be done with this. I would appreciate it, though, if you could explain the rationale for why the windows are resized in s:start_cb.

be free to make any change

the default size of window make code window too small, so I make the code window bigger and make goroutine window smaller

@bhcleek
Copy link
Collaborator

bhcleek commented Sep 11, 2019

I have a local branch that fixes the tests, cleans up some code, and make some other simple changes, too. Do you mind if I push to your branch?

@xbsura
Copy link
Author

xbsura commented Sep 11, 2019

be free to make any change, just push your code

Call s:logger directly instead of calling it through call()
Refactor debug window placement so that the windows are sized and place
properly simply by creating the splits so that windows don't have to be
resized after the splits are created.

Factor the showing of goroutines into its own method for readability and
consistency with how other windows are handled.

Return early without trying to change the goroutine when the user
presses enter on a line that doesn't list a goroutine or when the chosen
goroutine is already current.

Use window management functions instead of normal mode commands.

Use 'ID' consistently instead of 'Id'.
Now there's a new window in play, the expected buffer number is
different. Update the debug tests to be less fragile in the face of
changes.
@bhcleek bhcleek merged commit 75fa6fe into fatih:master Sep 17, 2019
bhcleek added a commit that referenced this pull request Sep 17, 2019
Update CHANGELOG.md for #2458, #2463, #2494, and #2495.
clrpackages pushed a commit to clearlinux-pkgs/vim-go that referenced this pull request Feb 1, 2020
v1.22 - (January 30, 2020)

BACKWARDS INCOMPATIBILITIES:
* Drop support for Vim 7.4. The minimum required version of Vim is now 8.0.1453.
  [[GH-2495]](fatih/vim-go#2495)
  [[GH-2497]](fatih/vim-go#2497)
* Drop support for `gometalinter`
  [[GH-2494]](fatih/vim-go#2494)

IMPROVEMENTS:
* Highlight the `go` keyword in go.mod files.
  [[GH-2473]](fatih/vim-go#2473)
* Use echo functions consistently.
  [[GH-2458]](fatih/vim-go#2458)
* Add support for managing goroutines in debugger.
  [[GH-2463]](fatih/vim-go#2463)
  [[GH-2527]](fatih/vim-go#2527)
* Document `g:go_doc_popup_window`.
  [[GH-2506]](fatih/vim-go#2506)
* Make `g:go_doc_popup_window=1` work for Neovim, too.
  [[GH-2451]](fatih/vim-go#2451)
  [[GH-2512]](fatih/vim-go#2512)
* Handle errors jumping to a definition in a file open in another Vim process
  better.
  [[GH-2518]](fatih/vim-go#2518)
* Improve the UX when the gopls binary is missing.
  [[GH-2522]](fatih/vim-go#2522)
* Use gopls instead of guru for `:GoSameIds`.
  [[GH-2519]](fatih/vim-go#2519)
* Use gopls instead of guru for `:GoReferrers`.
  [[GH-2535]](fatih/vim-go#2535)
* Update documentation for `g:go_addtags_transform`.
  [[GH-2541]](fatih/vim-go#2541)
* Install most helper tools in module aware mode.
  [[GH-2545]](fatih/vim-go#2545)
* Add a new option, `g:go_referrers_mode` to allow the user to choose whether
  to use gopls or guru for finding references.
  [[GH-2566]](fatih/vim-go#2566)
* Add options to control how gopls responds to completion requests.
  [[GH-2567]](fatih/vim-go#2567)
  [[GH-2568]](fatih/vim-go#2568)
* Add syntax highlighting for binary literals.
  [[GH-2557]](fatih/vim-go#2557)
* Improve highlighting of invalid numeric literals.
  [[GH-2571]](fatih/vim-go#2571)
  [[GH-2587]](fatih/vim-go#2587)
  [[GH-2589]](fatih/vim-go#2589)
  [[GH-2584]](fatih/vim-go#2584)
  [[GH-2597]](fatih/vim-go#2597)
  [[GH-2599]](fatih/vim-go#2599)
* Add highlighting of sections reported by gopls diagnostics' errors
  and warnings.
  [[GH-2569]](fatih/vim-go#2569)
  [[GH-2643]](fatih/vim-go#2643)
* Make the highlighting of fzf decls configurable.
  [[GH-2572]](fatih/vim-go#2572)
  [[GH-2579]](fatih/vim-go#2579)
* Support renaming with gopls.
  [[GH-2577]](fatih/vim-go#2577)
  [[GH-2618]](fatih/vim-go#2618)
* Add an option, `g:go_gopls_enabled`, to allow gopls integration to be
  disabled.
  [[GH-2605]](fatih/vim-go#2605)
  [[GH-2609]](fatih/vim-go#2609)
  [[GH-2638]](fatih/vim-go#2638)
  [[GH-2640]](fatih/vim-go#2640)
* Add a buffer level option, `b:go_fmt_options`, to control formatting options
  per buffer.
  [[GH-2613]](fatih/vim-go#2613)
* Use build tags when running `:GoVet`.
  [[GH-2615]](fatih/vim-go#2615)
* Add new snippets for UltiSnips.
  [[GH-2623]](fatih/vim-go#2623)
  [[GH-2627]](fatih/vim-go#2627)
* Expand completions as snippets when `g:go_gopls_use_placeholders` is set.
  [[GH-2624]](fatih/vim-go#2624)
* Add a new function, `:GoDiagnostics` and an associated mapping for seeing
  `gopls` diagnostics. Because of the performance implications on large
  projects, `g:go_diagnostics_enabled` controls whether all diagnostics are
  processed or only the diagnostics for the current buffer.
  [[GH-2612]](fatih/vim-go#2612)
* Explain how to find and detect multiple copies of vim-go in the FAQ.
  [[GH-2632]](fatih/vim-go#2632)
* Update the issue template to ask for the gopls version and
  `:GoReportGitHubIssue` to provide it.
  [[GH-2630]](fatih/vim-go#2630)
* Use text properties when possible for some highlighting cases.
  [[GH-2652]](fatih/vim-go#2652)
  [[GH-2662]](fatih/vim-go#2662)
  [[GH-2663]](fatih/vim-go#2663)
  [[GH-2672]](fatih/vim-go#2672)
  [[GH-2678]](fatih/vim-go#2678)

BUG FIXES:
* Fix removal of missing directories from gopls workspaces.
  [[GH-2507]](fatih/vim-go#2507)
* Change to original window before trying to change directories when term job
  ends.
  [[GH-2508]](fatih/vim-go#2508)
* Swallow errors when the hover info cannot be determined.
  [[GH-2515]](fatih/vim-go#2515)
* Fix errors when trying to debug lsp and hover.
  [[GH-2516]](fatih/vim-go#2516)
* Reset environment variables on Vim <= 8.0.1831 .
  [[GH-2523]](fatih/vim-go#2523)
* Handle empty results from delve.
  [[GH-2526]](fatih/vim-go#2526)
* Do not overwrite `updatetime` when `g:go_auto_sameids` or
  `g:go_auto_type_info` is set.
  [[GH-2529]](fatih/vim-go#2529)
* Fix example for `g:go_debug_log_output` in docs.
  [[GH-2547]](fatih/vim-go#2547)
* Use FileChangedShellPost instead of FileChangedShell so that reload messages
  are not hidden.
  [[GH-2549]](fatih/vim-go#2549)
* Restore cwd after `:GoTest` when `g:go_term_enabled` is set.
  [[GH-2556]](fatih/vim-go#2556)
* Expand struct variable correctly in the variables debug window.
  [[GH-2574]](fatih/vim-go#2574)
* Show output from errcheck when there are failures other than problems it can
  report.
  [[GH-2667]](fatih/vim-go#2667)

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
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

Successfully merging this pull request may close these issues.

2 participants