sdlrecord

In order to debug some SDL issues, I wrote a simple LD_PRELOAD library that will record and replay SDL events. So, you can run an SDL game in record mode, make some changes, and then test it out by replaying it.

This app should build and run on any Unix system supporting LD_PRELOAD (though I have only tested Linux). In theory it should be able to be run on OS X however I have not been able to resolve the SDL linking issues caused by running with DYLD_FORCE_FLAT_NAMESPACE (a requirement of DYLD_INSERT_LIBRARIES). Mach linking gives me a headache.

What is supported

Currently, this app ONLY will emulate SDL_PollEvent and SDL_WaitEvent. That means that if you want SDL_PumpEvents, SDL_PushEvent, SDL_PeepEvents or any other event functions, things will probably break oddly. I plan to support these in future versions. It also doesn't currently keep track of the various bits of state that can be obtained (eg, SDL_GetKeyState) so again this will break. Again, at some point I'll add them.

To build:

Type "make". You may have to change the SDL_INCLUDE path in the Makefile to wherever your SDL installation is.

This will build 2 shared libs, libsdlrecord.so and libsdlreplay.so, as well as a binary, sdldump.

To record:

Set your LD_LIBRARY_PATH to the path of libsdlrecord.so and run your SDL app.

The default output file is /var/tmp/sdl_event_log You can override this by setting the SDL_RECORD_PATH environment variable.

To replay

Set your LD_LIBRARY_PATH to the path of libsdlrecord.so and run your app. Note that you will NOT be able to input anything or kill it off (since we don't propogate SDL_QUIT). Something for a future version.

A note on timing

The current approach uses a relatively naiive approach to timing, trying to play back each event at roughly the same time as it was recorded. Due to the vagueries of schedulers and the like, this can be off. In some sensitive games this means things may end up being a little off. I have been experimenting on ways to improve this.

Download sdlrecord here