Bug Fixing for Everybody

(even non-programmers)

The Handout


Code is just text.

Mystery: Who, What, When, Where, Why
Where matters most; What is second


grep: search for patterns in files

  grep pattern file1 file2 file3 ...

Useful grep flags

file: find out the type of a file

  file file1 file2 file3 ...

Shell pipelines
pass output from one program into the input of another

file /usr/bin/* | grep script

Personal bin directory: $HOME/bin
Add to .bashrc: export PATH=$HOME/bin:$PATH
Then you can run anything in your personal bin just by typing it.
Make sure files there are executable: chmod ugo+x filename

Text editors:

Sample fixes:


/usr/games/wargames (sh script)
Make a copy, e.g. in your personal bin.
  ls /usr/games
in the "else" clause.
Also add ", $x" to print out the name of the game you requested.


Turn on Preview checkbox in Save as JPEG dialog, always.

Building C programs:

From Debian/Ubuntu:

apt-get source gimp
apt-get build-dep gimp
cd gimp

From tarball:

tar xvf gimp-2.6.5.tar.bz2
cd gimp-2.6.5
Optional step (might not want to do it when testing):
sudo make install

If you don't do make install, find runnable program with:

find . -name "*gimp*"
(or whatever the program name).

Special hint for gimp: if you're building a different version than the one installed with your system, add this to configure:

./configure --prefix=/usr/local/gimp-2.6
That helps the two versions coexist. See the README for more info.

Search for the right file:

$ grep -r "preview in image window" .
$ grep -r "preview in image" . | grep -v po

Edit plug-ins/jpeg/jpeg-save.c
Search for 'preview in image'
Find it in gtk_check_button_new_with_mnemonic
Next line: gtk_toggle_button_set_active
Google for gtk_toggle_button_set_active documentation
First hit: GNOME Documentation Library: verifies that gtk_toggle_button_set_active turns the checkbox on/off

  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (toggle), jsvals.preview);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (toggle), TRUE);


Have a core? gdb `which program-name` core No core? gdb `which program-name` then type: run

Search the bug system.

Use it like a google search: don't worry about those other fields.

Describe the bug


Apply an existing patch: patch [-pN] < patchfile Make a patch: diff -c file.sav file.new >mypatch.diff

Finding bugs to fix:

Bugzilla keywords