[vim/vim] Termdebug remote mode switch (PR #12522)

68 views
Skip to first unread message

Boyang Du

unread,
Jun 11, 2023, 11:44:45 AM6/11/23
to vim/vim, Subscribed

To add a switch to allow Termdebug to send continue instead of run when doing :Termdebug!.

Use case: when need to connect to a remote gdb server automatically though command line to launch Termdebug, it is possible to start Termdebug and manually do target remote ..., but it is annoying to do that especially if it needs to be repeated for several times.
So, this can be put to a vim file, e.g. remote_termdebug.vim, then can launch vim as vim -c 'source remote_termdebug.vim' -c 'exe :Termdebug!'

let Termdebug_remote={cmd, pty -> [join(cmd), "-q", 
\ "-tty", pty,
\ "-l", 120,
\ '-iex', "set pagination off", 
\ '-iex', "set mi-async on",
\ '-iex', "set sysroot /",
\ '-iex', "set tcp auto-retry on",
\ '-iex', "set tcp connect-timeout 120",
\ '-ex', "echo Waiting for gdbserver connection ".g:gdb_port." (2mins) ...\n",
\ '-ex', "target remote localhost:".g:gdb_port,
\ g:gdb_x_opt, g:gdb_x_opt_value,
\ '-ex', "echo startupdone\n"]}

let g:termdebug_config={
\ "command": 'gdb',
\ "command_add_args": Termdebug_remote,
\ "remotemode": 1,
\ "wide": 320}

Use command_add_args to "hijack" Termdebug gdb launch commands. This does not work with use_prompt: 1 though.
g:gdb_x_opt, g:gdb_x_opt_value can be used to load extra file containing gdb command such as set up breakpoints etc.

It would be much nicer if all can be done with :Termdebug <host>:<port>, but that probbaly requries much more changes and it is over my current capability.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/12522

Commit Summary

  • 782b6e9 add a switch for termdebug to use continue instead of run when debugging remote target
  • 086c5d1 Merge branch 'vim:master' into termdebug_remote

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12522@github.com>

Boyang Du

unread,
Jun 11, 2023, 11:46:22 AM6/11/23
to vim/vim, Subscribed

I may created the pull requests including a merge commit by mistake, don't know how to remove that, sorry.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12522/c1586219544@github.com>

codecov[bot]

unread,
Jun 17, 2023, 5:17:30 PM6/17/23
to vim/vim, Subscribed

Codecov Report

Merging #12522 (086c5d1) into master (10e8ff9) will increase coverage by 0.62%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master   #12522      +/-   ##
==========================================
+ Coverage   82.09%   82.71%   +0.62%     
==========================================
  Files         160      150      -10     
  Lines      193625   180512   -13113     
  Branches    43475    40571    -2904     
==========================================
- Hits       158950   149315    -9635     
+ Misses      21835    18243    -3592     
- Partials    12840    12954     +114     
Flag Coverage Δ
huge-clang-none 82.71% <ø> (-0.03%) ⬇️
linux 82.71% <ø> (-0.03%) ⬇️
mingw-x64-HUGE ?
mingw-x86-HUGE ?
windows ?

Flags with carried forward coverage won't be shown. Click here to find out more.

see 142 files with indirect coverage changes


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12522/c1595862804@github.com>

Bram Moolenaar

unread,
Jun 17, 2023, 5:36:44 PM6/17/23
to vim/vim, Subscribed


> I may created the pull requests including a merge commit by mistake,
> don't know how to remove that, sorry.

Don't worry, individual commits rarely matter, I usually just look at
the final result.

--
hundred-and-one symptoms of being an internet addict:
192. Your boss asks you to "go fer" coffee and you come up with 235 FTP sites.

/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12522/c1595867156@github.com>

Bram Moolenaar

unread,
Jun 17, 2023, 5:36:47 PM6/17/23
to vim/vim, Subscribed


> To add a switch to allow Termdebug to send `continue` instead of `run`
> when doing `:Termdebug!`.

This sounds like a useful addition. I do have a few remarks.

Please also update the help. Otherwise it will be hard to understand
how this works. Or that the support even exists. The examples you have
given here are a good start.

There is no need for "g:termdebug_remotemode". The other
"g:termdebug_..." variables exist for backwards compatibility before
g:termdebug_config was added. All new config options should go into
g:termdebug_config to avoid polluting the global namespace.

For using "=" in an assignment, please surround it with spaces, so that
it is easier to spot the separation between LHS and RHS.

Can "continue" be send with s:SendResumingCommand() ? Then s:stopped
will be updated properly. And it will work with a prompt buffer.

> Use `command_add_args` to "hijack" Termdebug gdb launch commands. This
> does not work with `use_prompt: 1` though.

It also makes it difficult to add more arguments.

> `g:gdb_x_opt, g:gdb_x_opt_value` can be used to load extra file
> containing gdb command such as set up breakpoints etc.

This should be explained in the help. When used in an example, there
should be a check if the variables exist.

> It would be much nicer if all can be done with `:Termdebug
> <host>:<port>`, but that probbaly requries much more changes and it is
> over my current capability.

It also conflicts with the current use of the argument, such as "core"
or "processID". Adding a new command avoids confusion:

TermdebugRemote {host}:{port}

Would that work?

--
hundred-and-one symptoms of being an internet addict:
191. You rate eating establishments not by the quality of the food,
but by the availability of electrical outlets for your PowerBook.

/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12522/c1595867158@github.com>

Boyang Du

unread,
Jun 19, 2023, 5:07:05 AM6/19/23
to vim/vim, Subscribed

Wow, thank you very much for the feedback.
At my work, I needed this because we have distributed computing infra, for which can't easily modify the protocol but can provide a wrapper. I thought to use gdbserver, then Vim Termdebug to conntect to the gdbserver, but it turned out gdbserver + gdb "target remote" have some issues that I don't know how to resolve.

So now, I'm directly launching the gdb with the executable in Vim in the wrapper, then I don't need to deal with gdbserver anymore.

But anyway I think this "remote debug" mode can be useful, also for embedded debugging, then the "TermdebugRemote {host}:{port}" is the correct way to go.

Hope you don't mind, I will close this pull request, and work on "TermdebugRemote {host}:{port}" to send another pull request when it is ready for reviewing.

Thank you again.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12522/c1596802010@github.com>

Boyang Du

unread,
Jun 19, 2023, 5:07:08 AM6/19/23
to vim/vim, Subscribed

Closed #12522.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12522/issue_event/9565704776@github.com>

Reply all
Reply to author
Forward
0 new messages