*debug.txt* Nvim
VIM REFERENCE MANUAL by Bram Moolenaar
Debugging Vim *debug-vim*
This is for debugging Vim itself, when it doesn't work properly.
For debugging Vim scripts, functions, etc. see |debug-scripts|
Type |gO| to see the table of contents.
==============================================================================
1. Location of a crash, using gcc and gdb *debug-gcc* *gdb*
When Vim crashes in one of the test files, and you are using gcc for
compilation, here is what you can do to find out exactly where Vim crashes.
This also applies when using the MingW tools.
1. Compile Vim with the "-g" option (there is a line in the src/Makefile for
this, which you can uncomment). Also make sure "strip" is disabled (do not
install it, or use the line "STRIP = /bin/true").
2. Execute these commands (replace "11" with the test that fails): >
cd testdir
gdb ../vim
run -u unix.vim -U NONE -s dotest.in test11.in
3. Check where Vim crashes, gdb should give a message for this.
4. Get a stack trace from gdb with this command: >
where
< You can check out different places in the stack trace with: >
frame 3
< Replace "3" with one of the numbers in the stack trace.
==============================================================================
2. Locating memory leaks *debug-leaks* *valgrind*
If you suspect Vim is leaking memory and you are using Linux, the valgrind
tool is very useful to pinpoint memory leaks.
First of all, build Vim with EXITFREE defined. Search for this in MAKEFILE
and uncomment the line.
Use this command to start Vim:
>
valgrind --log-file=valgrind.log --leak-check=full ./vim
Note: Vim will run much slower. If your vimrc is big or you have several
plugins you need to be patient for startup, or run with the "-u NONE"
argument.
There are often a few leaks from libraries, such as getpwuid() and
XtVaAppCreateShell(). Those are unavoidable. The number of bytes should be
very small a Kbyte or less.
==============================================================================
3. Windows Bug Reporting *debug-win32*
If the Windows version of Vim crashes in a reproducible manner, you can take
some steps to provide a useful bug report.
3.1 GENERIC ~
You must obtain the debugger symbols (PDB) file for your executable: gvim.pdb
for gvim.exe, or vim.pdb for vim.exe. The PDB should be available from the
same place that you obtained the executable. Be sure to use the PDB that
matches the EXE (same date).
If you built the executable yourself with the Microsoft Visual C++ compiler,
then the PDB was built with the EXE.
If you have Visual Studio, use that instead of the VC Toolkit and WinDbg.
For other compilers, you should always use the corresponding debugger: gdb
(see above |debug-gcc|) for the Cygwin and MinGW compilers.
*debug-vs2005*
3.2 Debugging Vim crashes with Visual Studio 2005/Visual C++ 2005 Express ~
First launch vim.exe or gvim.exe and then launch Visual Studio. (If you don't
have Visual Studio, follow the instructions at |get-ms-debuggers| to obtain a
free copy of Visual C++ 2005 Express Edition.)
On the Tools menu, click Attach to Process. Choose the Vim process.
In Vim, reproduce the