Debugging a multi-stage system