Advanced - Debugging Fall 2026

Submission Instructions

This assignment is an “online assignment” on Gradescope, where you will attach your files and answer some questions.

Presentation/Checkoff

In addition to submitting this assignment, you will need to attend a lab session after the deadline to discuss your work with the course staff. Refer to the course schedule for the window for doing so for this assignment.

As part of the discussion, be prepared to do the following:

I suggest keeping these in mind while doing the assignment, and writing down your thoughts so that you can review them before the checkoff.

Your overall score for the assignment will be a combination of your submission score and the presentation/checkoff score. Refer to the syllabus for the details.

Preface

In this assignment you’ll be provided yet another zipped archive containing some starter files.

https://www.eecs.umich.edu/courses/eecs201/fa2026/files/assignments/adv-debug.tar.gz

Attaching to a running process (5)

This part may or may not work on macOS: try it on the course server. Occasionally you may want to debug an already running process with GDB or LLDB. Perhaps it’s some sort of daemon process that you want to catch in the act or maybe it’s some interesting setup that you have concocted cough cough*. Regardless, GDB and LLDB have the ability to attach to already running processes when provided with the process ID (“PID”) of a process you want to debug (and in the case of LLDB, it can also even attach to a process via the program’s name!).

In adv-debug/attach there is a program called revd that will reverse strings provided to it and log them. It is intended to run in the background, using a special type of file called a named pipe or FIFO (like a pipe used to string commands together, but accessible as a file) as input. It uses the FIFO as a form of inter-process communication (IPC): a process that wants to communicate will write to the FIFO file and revd will read from it.

The Makefile has targets for building and running the application. test-producer.sh is a sample script that communicates with revd, forever providing it with a random word every second (until you C). Try running the run target and then run test-producer.sh. In another terminal run $ tail -f revd.log to continuously print out updates to the log file. You should see that the revd process is chugging along (for extra fun, run some more instances of test-producer.sh or write another program/script that produces more input for revd).

Now onto the debugging part: the goal of this exercise is to attach GDB or LLDB to this running process. There’s multiple ways of going about this: I’ll leave it up to you to review the GDB/LLDB manual or manpage or other random resources on the internet.

Notes:

Bisecting a Regression (5)

Sometimes a program that used to work just stops working, and you’re left staring at a pile of commits with no idea which one is responsible. The commit messages won’t save you (they never advertise the bug they introduced), and reading every diff by hand is slow and easy to get wrong. The good news: as long as you have one commit where things worked and one where they don’t, Git can binary-search the history in between and pin down the exact commit that broke things for you, using git bisect.

In adv-debug/bisect there is mini-calc, a small C++ program that evaluates integer arithmetic expressions (+ - * / %, parentheses, and unary minus). It’s a real Git repository with history: it shipped a known-good release, tagged v1.0, where everything worked. Many commits later something is off, and the project’s own tests (make test) still pass, so nobody noticed when it slipped in.

Build it and take it for a spin:

make
./eval "2 + 3 * 4" (should print 14)

The folder also contains test.sh, a script that checks for the regression. Keep it in the repository root and don’t commit it: it’s listed in .gitignore on purpose so that it stays put while git bisect swaps the tracked files around underneath you.

Now onto the actual hunt: figure out the exact commit that introduced the bug, and then fix it.

Notes: