Main CS97 Page
 
Top

git, teams, etc.

Your personal CS97 git repository should be set up and accepting pushes happily. If it isn't, talk to Ben.

If you are not yet situated in a team, you should start thinking seriously about that. Milestone 0 is 2 or 3 weeks away, and you should have at least the beginnings of some project ideas by then.

Valgrind Tutorial

This week, you'll get a very quick intro to the guts of Valgrind. You should work through section 2.2.3 ("Getting started") of the following page. There are a few things you have to do a little differently, which are documented below.

http://www.valgrind.org/docs/manual/writing-tools.html

The department imposes a fairly modest quota on student accounts. In order to make a Valgrind tool, you have to download the entire Valgrind source tree, which is relatively large. In order to square this circle for the time being, you should work in the /local directory. This directory is located on a particular machine, not the department's network storage. So anything you do in there will not follow you from machine to machine. If you choose to use Valgrind for your project, we will probably have to come up with a better solution.

Here is what you should do:

cd /local
mkdir ${USER}
cd ${USER}
svn co svn://svn.valgrind.org/valgrind/trunk valgrind

Now you can mostly follow the tutorial linked above. That is for a slightly older version of Valgrind, which means that a few things are out-of-date:

  • At a few points the instructions say to replace "nl_" with "fb_". This will miss a few items. You should really replace "nl" with "fb".
  • "configure.in" should be "configure.ac"
  • "AC_OUTPUT" should be "AC_CONFIG_FILES" (the first one; there are three)

Now you know what it takes to make a brand new skeleton Valgrind tool!

Tweak lackey

Making a minimal, useful Valgrind tool takes a bit more boilerplate code than with Pin. Also its API is a bit less documented and harder to digest. To give you a quick look at how it works, I'm going to ask you to modify the existing tool "lackey". The relevant code is all in [your valgrind dir]/lackey/lk_main.c

By default, lackey reports the number of calls to "main".

  • Modify lackey so that it also reports the number of calls to some other random function name that you choose. Hint: Search for uses of "add_one_func_call" and "n_func_calls".
  • Write a tiny C program from scratch that has a function with your chosen name and run it under your modified lackey tool to show that it works.