OpenBSD strace equivalent

OpenBSD, I’ve loved you for a long time, but over the last few years, me and you have grown apart. Not due to choice, but due to my career path being deeply entangled with everything associated with Linux.

Thankfully, I recently had the opportunity to bring up an OpenBSD box and set it up from scratch with OpenBSD 4.6.

One of the first issues I encountered had to do with my favorite editor – vi/vim. The problem? The backspace and the arrow keys weren’t working properly and while this is a simple .vimrc fix, I wanted to place the fixes in a global vimrc. On Linux (at least RHEL based distro’s), this can be accomplished by dropping your settings into /etc/vimrc. On OpenBSD though, this is not the case – it is read from a different location.

Being used to ‘strace’ on Linux and my general laziness with looking through documentation, I much rather prefer to just skimp through a process trace to find out what it’s doing during start-up. OpenBSD doesn’t have ‘strace’ though, instead, it has ‘ktrace’ and ‘kdump’. Really, you can’t call it an equivalent either, as they are vastly different, however, they can both achieve roughly the same task, which in my case, was to find where the global vimrc was getting loaded from.

This is how I did it:

1. Run ‘ktrace -f vimtrace.out vim’
This generates a logfile with the process trace, that you can then parse with kdump.
2. Run ‘kdump -f vimtrace.out | grep vimrc’
3. Results:

[email protected] $ ktrace -f vimtrace.out vim
[email protected] $ kdump -f vimtrace.out | grep vimrc
9649 vim      NAMI  "/usr/local/share/vim/vimrc"
9649 vim      NAMI  "/usr/local/share/vim/vimrc"
9649 vim      NAMI  "/usr/local/share/vim/vimrc"
9649 vim      NAMI  "/root/.vimrc"
9649 vim      NAMI  "/root/.vimrc"
9649 vim      NAMI  "/root/_vimrc"

Voila! Unfortunately, the result didn’t really come as a surprise – OpenBSD has always been very proper about file placement / separation of distribution related files and user based additions.

And finally, if some of you are experiencing the same key problems on OpenBSD (I’m locally on an OS X terminal), this is what you place in your vimrc’s:

set nocp
set backspace=2



  1. Scott

    Does :echo $VIMRUNTIME not answer your question when run from Vim?

  2. Sort of? It displays the path of where vim loads all its runtime scripts, however it’s still not the main location where vim looks up a global vimrc from. Nevertheless, I’ve never had to use $VIMRUNTIME, so thanks 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

166 views2 comments