Agents are automatically started by the Akonadi server and thus are not debugable from the start on by the usual methods. A similar problem is known from KIO slaves, the solution is similar as well.

## Attaching gdb at startup

Export the environment variable AKONADI_DEBUG_WAIT and put a list of agent types in there you want to debug.

When starting an agent of one of these types, you'll see the following debug output by the Akonadi server which is pretty much self-explanatory.

```============================================================