[vim/vim] Can I use termdebug.vim on Windows ?? (#2882)

212 views
Skip to first unread message

Linwei

unread,
May 7, 2018, 10:04:40 AM5/7/18
to vim/vim, Subscribed

Tried it on linux, and want to use it on windows. but there is an

E492: Not an editor command: Termdebug

on windows gvim.

The command is still unusable after :packadd termdebug


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

Christian Brabandt

unread,
May 7, 2018, 10:25:38 AM5/7/18
to vim/vim, Subscribed

when exactly do you encounter that? You started with vim --clean? do you have termdebug in your local $VIMRUNTIME?

Linwei

unread,
May 9, 2018, 5:17:01 AM5/9/18
to vim/vim, Subscribed

I encountered this after packadd termdebug and :Termdebug. Weird, termdebug.vim is not included in gvim_8.0.1806_x86.exe, but included in gvim_8.0.1806_x86.

Linwei

unread,
May 9, 2018, 5:19:33 AM5/9/18
to vim/vim, Subscribed

If you decompress gvim_8.0.1806_x86.zip, there is a termdebug.vim located in:

vim80\pack\dist\opt\termdebug

But if vim is installed from the win32 installer, you can't find the termdebug package.

K.Takata

unread,
May 9, 2018, 5:34:16 AM5/9/18
to vim/vim, Subscribed

We need to update the filelist in gvim.nsi.
If we can use File /r, the list can be made simpler.

mattn

unread,
May 9, 2018, 5:37:31 AM5/9/18
to vim/vim, Subscribed

Vim on Windows support communicating via pty But gdb command provided for Windows doesn't support "new-ui mi" command with pipe. So TermDebug not to work on Windows correctly.

Linwei

unread,
May 9, 2018, 5:51:33 AM5/9/18
to vim/vim, Subscribed

But why does https://github.com/cpiger/NeoDebug work on windows while termdebug not ?


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub, or mute the thread.

mattn

unread,
May 9, 2018, 5:57:03 AM5/9/18
to vim/vim, Subscribed

Because it just use "set new-console on" command. not communicating via tty.

Christian Brabandt

unread,
May 10, 2018, 3:03:16 AM5/10/18
to vim/vim, Subscribed

so could we make the termdebug workable on Windows? I don't understand gdb good enough to guess what needs to be changed or what set new-console on does differently.

mattn

unread,
May 10, 2018, 3:05:45 AM5/10/18
to vim/vim, Subscribed

set new-console on create new cmd.exe for the target process. This behavior mean that termdebug can't communicate to mi2 interface. it should communicate to gdb prompt directly. I guess.

Linwei

unread,
May 10, 2018, 5:48:22 AM5/10/18
to vim/vim, Subscribed

So, Termdebug has three windows: the source window, the gdb console window and the output window. Can we just disable output window on Windows, and redirect the stdout/stdin of debugging process to the gdb console window ?

The output window of gdb-mode in emacs doesn't work on Windows too. But gdb-mode is still useable on window and the program output will be displayed in the gdb console window directly.

Bram Moolenaar

unread,
May 10, 2018, 8:41:38 AM5/10/18
to vim/vim, Subscribed

> `set new-console on` create new cmd.exe for the target process. This

> behavior mean that termdebug can't communicate to mi2 interface. it
> should communicate to gdb prompt directly. I guess.

I used this with an older tool. It sort-of works, but it is a bit hacky.
Still, better than not working at all.

Alternatively, perhaps a gdb can be built with the mi2 interface?

--
There can't be a crisis today, my schedule is already full.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Bram Moolenaar

unread,
May 10, 2018, 8:41:42 AM5/10/18
to vim/vim, Subscribed


> So, Termdebug has three windows: the source window, the gdb console
> window and the output window. Can we just disable output window on
> Windows, and redirect the stdout/stdin of debugging process to the gdb
> console window ?
>
> The output window of `gdb-mode` in emacs doesn't work on Windows too.
> But `gdb-mode` is still useable on window and the program output will
> be displayed in the gdb console window directly.

This can work for some debugging. But won't work well for debugging
Vim, since it uses cursor positioning.

--
Did you ever stop to think... and forget to start again?
-- Steven Wright


/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Linwei

unread,
May 10, 2018, 8:52:21 AM5/10/18
to vim/vim, Subscribed

And can we use a standalone cmd.exe window for the process which is been debugging, just like debugging console applications in visual studio ??

Linwei

unread,
May 18, 2018, 9:03:19 AM5/18/18
to vim/vim, Subscribed

NeoDebug can also have a separate console window on Windows:

neodebug

Is this an alternative way to debug TUI programs on windows ??

Bram Moolenaar

unread,
May 18, 2018, 10:03:14 AM5/18/18
to vim/vim, Subscribed

> NeoDebug can also have a separate console window on Windows:
>
> ![neodebug](https://user-images.githubusercontent.com/3035071/40235965-84612f9a-5ade-11e8-8196-e7a0c5b9da31.png)

>
> Is this an alternative way to debug TUI programs on windows ??

Ah, so it uses an actual console window, instead of a terminal window
(with winpty). I wonder how to start that from gdb on Windows.

AFAIK NeoDebug only uses jobs and channels, not a terminal window.
It's a little bit limited, but it does work on MS-Windows, which the
Terminal debugger can't do (yet).

--
The MS-Windows registry is no more hostile than any other bunch of state
information... that is held in a binary format... a format that nobody
understands... and is replicated and cached in a complex and largely
undocumented way... and contains large amounts of duplicate and obfuscated
information... (Ben Peterson)


/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Linwei

unread,
May 18, 2018, 10:26:27 AM5/18/18
to vim/vim, Subscribed

GDB has a set new-console on windows, similar to tty command on linux:

set new-console on

In this mode GDB will start the debugged program in a new console. The output of the program will be shown in a separate window that will be closed after the program exits.

see the documentation:

http://visualgdb.com/gdbreference/commands/set_new-console

Linwei

unread,
May 18, 2018, 10:48:13 AM5/18/18
to vim/vim, Subscribed

And I can use tty command to specify a terminal for NeoDebug:

  1. start NeoDebug and open a new terminal in vim.
  2. use bash command tty to display the current tty file name.
  3. use tty /dev/pts/0 in NeoDebug
  4. run the process.

neodebug2

See, I can debug my program in a vim terminal.

for more information about tty command in gdb:
https://sourceware.org/gdb/onlinedocs/gdb/Input_002fOutput.html

The only side effect is that I can't find a easy way to fetch tty filename of a terminal buffer. have to type tty command in the terminal.

Linwei

unread,
May 18, 2018, 11:00:52 AM5/18/18
to vim/vim, Subscribed

update: tty doesn't work in a vim terminal buffer if the program reads data from stdin.

Linwei

unread,
May 18, 2018, 11:04:30 AM5/18/18
to vim/vim, Subscribed

And neodebug is a little bit unstable now, could termdebug.vim emit a set new-console on command automatically on windows, and at least we can debug TUI programs in a separate console window on windows ??

Bram Moolenaar

unread,
May 18, 2018, 11:27:25 AM5/18/18
to vim/vim, Subscribed

> And neodebug is a little bit unstable now, could termdebug.vim emit a
> `set new-console on` command automatically on windows, and at least we
> can debug TUI programs in a separate console window on windows ??

Opening a console window would be easy to do, but the "new-ui" command
is still missing in MS-Windows gdb builds, right? Not sure if it would
be possible, since it also requires a tty.
NeoDebug uses another UI mode, which is much more complicated to use.

--
Corn oil comes from corn and olive oil comes from olives, so where
does baby oil come from?


/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

mattn

unread,
May 18, 2018, 11:52:13 AM5/18/18
to vim/vim, Subscribed

but the "new-ui" command is still missing in MS-Windows gdb builds, right?

Yes, it doesn't work on Windows. also passing named pipe also not work. new-ui mi con or new-ui mi CONOUT$ are not work too.

Linwei

unread,
May 18, 2018, 11:53:52 AM5/18/18
to vim/vim, Subscribed

I have tested set new-console on with termdebug.vim on windows, in spite of some error messages, it seems work:

termdebug

And of course, the "program window" cannot be used, but since we have a separate console window, do we still need "new-ui" and the "program window" on windows ??

Yegappan Lakshmanan

unread,
May 18, 2018, 1:22:33 PM5/18/18
to vim_dev, reply+00b1d198a90e544177d263ef8375823ec2d5f07...@reply.github.com, vim/vim, Subscribed
Hi,

On Fri, May 18, 2018 at 7:48 AM, Linwei <vim-dev...@256bit.org> wrote:

And I can use tty command to specify a terminal for NeoDebug:

  1. start NeoDebug and open a new terminal in vim.
  2. use bash command tty to display the current tty file name.
  3. use tty /dev/pts/0 in NeoDebug
  4. run the process.

neodebug2

See, I can debug my program in a vim terminal.

for more information about tty command in gdb:
https://sourceware.org/gdb/onlinedocs/gdb/Input_002fOutput.html

The only side effect is that I can't find a easy way to fetch tty filename of a terminal buffer. have to type tty command in the terminal.



You can use term_start("NONE") to start a terminal without a process running
in the terminal. You can use term_gettty(bufnr("%")) to get the tty for this
terminal. You can then pass this terminal to GDB.

- Yegappan
 

vim-dev ML

unread,
May 18, 2018, 1:23:04 PM5/18/18
to vim/vim, vim-dev ML, Your activity
Hi,

On Fri, May 18, 2018 at 7:48 AM, Linwei <vim-dev...@256bit.org> wrote:

> And I can use tty command to specify a terminal for NeoDebug:
>
> 1. start NeoDebug and open a new terminal in vim.
> 2. use bash command tty to display the current tty file name.
> 3. use tty /dev/pts/0 in NeoDebug
> 4. run the process.
>
> [image: neodebug2]
> <https://user-images.githubusercontent.com/3035071/40241153-d996d61e-5aec-11e8-8f8d-a2ff99f85622.png>

>
> See, I can debug my program in a vim terminal.
>
> for more information about tty command in gdb:
> https://sourceware.org/gdb/onlinedocs/gdb/Input_002fOutput.html
>
> The only side effect is that I can't find a easy way to fetch tty filename
> of a terminal buffer. have to type tty command in the terminal.
>
>
>
You can use term_start("NONE") to start a terminal without a process running
in the terminal. You can use term_gettty(bufnr("%")) to get the tty for this
terminal. You can then pass this terminal to GDB.

- Yegappan

Bram Moolenaar

unread,
May 18, 2018, 2:46:34 PM5/18/18
to vim/vim, vim-dev ML, Comment

> I have tested `set new-console on` with termdebug.vim on windows, in spite of some error messages, it seems work:
>
> ![termdebug](https://user-images.githubusercontent.com/3035071/40244598-d31f88cc-5af5-11e8-91d8-a5c68420debf.png)

>
> And of course, the "program window" cannot be used, but since we have
> a separate console window, do we still need "new-ui" and the "program
> window" on windows ??

But can you do anything with the source code window, such as set a
breakpoint, display the current location, etc? I expect not.

I believe what NeoDebug does is run gdb using a channel, and piping the
I/O using a Vim window. Perhaps it's possible to do something similar
in the Terminal debugger, thus not opening a separate (hidden)
communication window, but setting the interpreter to mi2 and converting
commands to/from it. That's a lot of converting though...

--
FATAL ERROR! SYSTEM HALTED! - Press any key to continue doing nothing.


/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///


You are receiving this because you commented.

Linwei

unread,
May 18, 2018, 4:43:28 PM5/18/18
to vim/vim, vim-dev ML, Comment

That’s a reasonable point. And a little pity.

Linwei

unread,
Jan 26, 2019, 12:22:32 PM1/26/19
to vim/vim, vim-dev ML, Comment

Closed #2882.

Reply all
Reply to author
Forward
0 new messages