IPod Debugging

From wikiPodLinux

When you attempt to write software to run in the iPod under iPodLinux, you will eventually need to do some debugging.

This page outlines the various options you have to debug your iPod-targeted code.

Table of contents

Considerations

The general problem with debugging is that the iPod has currently neither a keyboard nor a screen that would allow the use of a debugging tool such as gdb (http://en.wikipedia.org/wiki/Gdb) running on the iPod.

Instead the debugger would need to run on a host computer and connect to the iPod remotely. gdb can do such remote debugging, but it requires a bidirectional connection between the iPod and the host computer, of course.

Poor man's debugging (printf)

You can almost always use the printf()statement in C to insert console messages into your code. In kernel code, use printk() instead.

The output then appears in the console screen of the iPod. If you have set up a IP over Firewire or Serial connection, you might also redirect the output to those connections and have a host computer show the messages (To Do: add how-to for configuring this redirection on the iPod)

Logging to a file

Assuming your issue is not related to timing, one of the most useful methods involves logging anything and everything to a file. The file should be preferably opened as such, if you want to avoid synchronization issues.

FILE *dbgout = fdopen (open ("/path/to/file.dbg", O_WRONLY | O_CREAT | O_TRUNC | O_SYNC, 0666), "wb");
setbuf (dbgout, 0);

This method has been used to great effect in debuging TTK and podzilla. Note that writing to files opened synchronously is quite slow, so it may change timings and such; for this reason, it's infeasible when debugging race conditions.

Using gdb remotely

With older iPods (first to third gen.) it is possible to do remote debugging by using a IP connection over Firewire (see here) connection. It might also be possible to connect via a serial connection.

To do: add how-to instructions for setting up a remote debugging session

Debugging using an emulator

It is also (theoretically) possible to run your code on an ARM emulator and then use gdb to connect to the emulator.

However, no one has given specific instructions on this yet. If you know something, please add here.