How to use cscope to grok FreeBSD code

2020-04-23
1 min read
pkg install cscope 

Then we need to create the cscope database, in my case I'll create it at my homedir

find /usr/src/sys/ -name "*.[chxsS]" -print > /home/cneira/cscope.files

Then in vim/nvim if it's compiled with cscope support you need to execute the following commands

cscope -b -q -k
:cs add cscope <path to your cscope database>

That's all then just call the cscope functions to navigate through the code.

:cs find g strlen

Add this to your vimrc

set cscopeverbose cscopetag ignorecase smartcase

let db = findfile("cscope.out", ".;")
if (!empty(db))
        let path = strpart(db, 0, match(db, "/cscope.out$"))
        set nocscopeverbose " suppress 'duplicate connection' error
        exe "cs add " . db . " " . path
endif