Operating Systems

ECE344, Spring 2019
University of Toronto

Labs and website created by: Ashvin Goel
Deadlock

Quick Links

Lab AssignmentsQuercus Website

Using ctags and etags for Code Navigation

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. The instructions described below are for the vim and the emacs editors.

vim Instructions

For example, you might be in test_thread.c, looking at the variable THREAD_NONE being passed to the function thread_yield. You can look at how this variable is defined by typing Ctrl-], which will take you to the thread.h header file. Then press Ctrl-t to go back.

Directions:

  1. Generate a file called tags in the ~/ece344 directory. This file will contain information for all 'c' source and header files for the ECE344 labs. You will need to redo this step when you add new code to update the tags file.
      % cd ~/ece344
      % find . -name "*.[chS]" | xargs ctags
    
  2. Add the following to ~/.vimrc:
    set tagstack
    set tags=./tags,tags,$HOME/ece344/tags
    
    If you don't have an existing ~/.vimrc file, you will need to create it.
  3. Use Ctrl-] to follow tags, and Ctrl-t to go back. Try ":help ctags" in vim for more info.

A few more suggestions:

emacs Instructions

The usage is similar, except when the cursor is on a tag, you jump to the definition with M-. (meta and dot pressed simultaneously). The first time you try it, emacs will ask you about the location of the tag file. If you follow the instructions below, there will be a file named TAGS in ~/ece344, so you can just select that directory and emacs will use the correct tags table.

In order to go back from where you came (upon typing M-.), 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.

Directions:

  1. Generate a file called TAGS in the current directory. This file will contain information for all 'c' source and header files, and assembly files. You will need to redo this step when you add new functions to update the TAGS file.
      % cd ~/ece344
      % find . -name "*.[chS]" | xargs etags
    
  2. Use M-. to follow tags, and M-* to go back.