Pintos Projects: Development Tools

F. Development Tools

Here are some tools that you might find useful while developing code.


F.1 Tags

Tags are an index to the functions and global variables declared in a program. Many editors, including Vim and Emacs, can use them. The Makefile in pintos/src produces Emacs-style tags with the command make TAGS or vi-style tags with make tags. Or you can just type in ctags -r * to generate a recursive tags file.

Also for vim you need to add set tags=./tags,tags; to your vimrc for this to work

In vim use Ctrl + [ to follow a tag. If your cursor is on a symbol name for any of those commands, it becomes the default target. If a tag name has multiple definitions, :tags will list all the tag hits To jump back to where you were before you followed the last tag, use Ctrl + t .

In Emacs, use M-. to follow a tag in the current window, C-x 4 . in a new window, or C-x 5 . in a new frame. If your cursor is on a symbol name for any of those commands, it becomes the default target. If a tag name has multiple definitions, M-0 M-. jumps to the next one. To jump back to where you were before you followed the last tag, use M-*.


F.2 cscope

The cscope program also provides an index to functions and variables declared in a program. It has some features that tag facilities lack. Most notably, it can find all the points in a program at which a given function is called.

The Makefile in pintos/src produces cscope indexes when it is invoked as make cscope. Once the index has been generated, run cscope from a shell command line; no command-line arguments are normally necessary. Then use the arrow keys to choose one of the search criteria listed near the bottom of the terminal, type in an identifier, and hit Enter. cscope will then display the matches in the upper part of the terminal. You may use the arrow keys to choose a particular match; if you then hit Enter, cscope will invoke the default system editor(10) and position the cursor on that match. To start a new search, type Tab. To exit cscope, type Ctrl-d.

Emacs and some versions of vi have their own interfaces to cscope. For information on how to use these interface, visit http://cscope.sourceforge.net, the cscope home page.


F.3 Git

Git is a (relatively new) version control software that helps keep track of your code. Think of it on Dropbox (but optimized for code) on steroids. GitHub is one of the many only services that provide a place to HOST your code, git is just a program on your computer but GitHub provides a place to ”push” your code.

If you have gotten through hw0, you have already successfully used git, but understanding some of the inner-workings will really help you on your hacking. If you have never used git or want a fresh start, we recommend you start here If you sort of understand git this presentation we made and this website are useful in understanding the inner workings a bit more.

Note all homework and project submission in this course is handled via git, so you'll ned to figure it out at some point


F.4 Make

Make is a utility that automatically builds executable programs and libraries from source code by reading files called Makefiles, which specify how to derive the target program. How it does this is pretty cool: you list dependencies in your Makefile and make simply traverses the dependency graph to install everything. Unfortunately, make has very awkward syntax that is, at times, very confusing if you are not properly equipped to understand what is actually going on. A few good tutorials are here and here. And of course the official GNU documentation (though it may be a bit dense) here


F.4 Gdb

Debugging C programs is hard. Simply put, it doesn’t give you nice exceptions or stack traces. Fortunately that’s where gdb comes. If you compile your programs with a special flag -g then the binary will have debug symbols, which will allow gdb to do its magic, if your run your C program inside gdb it will allow you to not only look at a stack trace, but inspect variables, change variables, pause code and much more! Normal gdb has a very plain interface, Thus, we have installed cgdb for you to use on the virtual machines, which has syntax highlighting and few other nice features. gdb can also attach to running programs (which will be useful when debugging your OS) This is an excellent read on understanding not only how to use gdb but how your programs work. Again official documentation is also good if not a bit verbose


F.4 Tmux

Tmux is a terminal multiplexer, it basically simulates having multiple terminal tabs but in one terminal session. It saves having to have multiple tabs of sshing into your virtual machine. You can start a new session with tmux new -s [session_name] After which you are in a regular terminal but pressing ctrl-a + c will create a new window. ctrl-a + n will jump to the nth window. ctrl-a + d will ”detach” your tmux session which you can re-attach using tmux attach -t [session_name] The best part is this works even if you quit your original ssh session, and connect using a new one. It helps keeping your environment persistent. Here is a good tmux tutorial to help you get started. This is the tmux config we set up in the VM, so the key-mappings in the VM will correspond to this. Note: By default tmux commands begin with ctrl-b but we remapped it to ctrl-a in the virtual machine, if you want to try out tmux else where you will need to do that yourself


F.4 Vim

Vim is a nice text editor to use in the terminal. It’s well worth learning. Here is a good series to get better at vim. Others may prefer emacs. You will need to get proficient and a editor that is well suited for writing code.