DIVISION OF ENGINEERING AND APPLIED
SCIENCES
HARVARD UNIVERSITY
CS 161. Operating SystemsSpring 2006 Using ctags(1) for Code Navigation
By Philip Zeyliger |
The idea of tags is to navigate around the kernel source by following symbols. This way you don't have to remember which file a given symbol is defined in.
For example, I might be in uio.c, looking at uiomove(). I could go over to the symbol uio (part of struct uio), type Ctrl-] and be moved over to uio.h, where struct uio is defined. I press Ctrl-t to go back.
Directions:
set tagstack
set tags=./tags,tags,$HOME/cs161/src/kern/tags
The useage is similar, except if the cursor is on a tag, you jump to the definition with 'M-.'. The first time you try this it will ask you where the tag file is; if you have followed the instructions below there will be a file named TAGS in ~/cs161/src/kern so you can just select that directory and emacs will use the correct tags table.
In order to jump forward in the tag stack (go back from whence you came), use 'M-*'. If you have typed the first few characters of a symbol, M-tab will complete it from the tabs table, if there is a unique completion. This is only occasionally useful to me.
Directions:You may notice that ctags is installed on nice and want to use it. However, it is not so exuberent so you must use it along with find(1). The command below worked for me to generate an emacs tag file. Just use 'ctags' for vim tags, and run it in ~/cs161/src/kern.
find \( -name '*.h' -or -name '*.c' \) -print | xargs etags