Debugging Vim Plugins With strace or: Remembering the Past


Syntastic has several ways for you to define your classpath when using javac. The way that I’ve chosen to manage my workspaces is by using the dot config file (.syntastic_javac_config). Syntastic will look for a global Vim variable, g:syntastic_java_javac_classpath, in the config file located in the pwd . I’d previously gotten syntastic to compile correctly using my config file but when I moved to another computer it inexplicably stopped. ┬áLearning how to write or debug Vim plugins is not on the top of my to-do list. Recently a friend had linked me to some bloggings about strace. This seems like a perfect time to learn a new tool.

The following is a dry recounting of what I did to debug the issue.


There is not a way, that I know of, to running Syntastic directly, so I need to trace through Vim. In order to do this I have to trace the child processes of Vim by attaching to it’s pid.

ps -ef | grep vim

You can have strace attach to an already running process by using the p option(in the example the pid is 24452).

sudo strace -o strace_out -fp 24452 -s 2048

When I save a .java file in Vim, strace will kick off a javac process. In order to see what Syntastic is doing, all the children processes needs to be logged by using the f option.

The output has been set to strace_out. In this file we’re looking for an exe process that calls out to javac. A quick search of the file (%s/execve.*javac//gn) shows this javac process being called and most importantly the classpath being passed in (cp option). (Whitespace added for readability.)

25019 execve("/bin/bash", ["/bin/bash", "-c", "(javac -Xlint -d /tmp/vim-syntastic-javac -cp
/home/kevino/projects/component-dependency-grapher/src/main/java/com/scuilion/dependencygrapher/neo4j/node/ 2>&1) &> /tmp/vM7OMl8/21"], [/* 68 vars */]

I’ve verified the classpath in the Syntactic config file. The call that strace shows, is including all the local source folders but none of the jar files. My next thought was that the plugin was not finding my config file or that the plugin was trying to validating each file in the classpath and failing. It appeared that it does check each file but it doesn’t have a problem finding them.

24452 stat("/home/kevino/.gradle/caches/modules-2/files-2.1/org.neo4j/neo4j/2.1.2/de24992e14593667756c8042f6a26c6c6ff41271/neo4j-2.1.2.jar", {st_mode=S_IFREG|0664, st_size=24047, ...}) = 0

stat(...) = 0 means that the file was found and there was no error code returned.


So, what is going on here? I’d actually discovered and solved this problem before (hence, “remember the past”). Syntastic uses wildignore in the .vimrc to exclude certain file types. So does the Vim plugin CtrlP. When I search through a project using CtrlP I don’t want jar files to be returned in the results so I had added .jar extensions to wildignore.

Even though I had solved this issue before it was a great starter problem to experiment with strace. I’m looking forward to using┬ástrace to bolster my debugging skills.