Thursday, February 14, 2013

Debugging apps that use OSS (Ubuntu)

There are still a few legacy applications out there that rely on OSS for the sound system, and on many distributions such as Ubuntu, these programs can be invoked through the "padsp" utility to provide the needed functionality. But what do you do if you want to debug the program in gdb?

Fortunately, the "padsp" functionality can be obtained without actually invoking padsp, by providing the application with one environment setting: "LD_PRELOAD=/usr/lib/i386-linux-gnu/pulseaudio/libpulsedsp.so".

The exact path of the library may be different on your system. This same environment value can specified in gdb with the "set env" directive. What is even more useful is that it can be specified in the command line to gdb, using the gdb argument "-ex", e.g. '-ex "set env BLAH=blurb"' etc.

This becomes very useful in an IDE such as Code:Blocks, where arbitrary command line options to gdb can be specified in the "Settings:Debugger" dialog. Simply paste the entire construct into the "Argument" text box (note the double quotes):

-ex "set env LD_PRELOAD=/usr/lib/i386-linux-gnu/pulseaudio/libpulsedsp.so"

That's all folks!

Friday, February 8, 2013

Galaga C-code Translation

Video of my Galaga C-code version running in a Code:Blocks debug session: