Cotix/cReddit — pull request #46 by DSMan195276 (2013-10-19 19:20:09+00:00)
Title: creddit: libreddit: Add debug options

This change is pretty simple, it simply adds options to the Makefile for easing debugging, adds a script to make it easier to run creddit without running 'make install' first, and adds some code into global.c and global.h for adding simple debug statements into the code.

If the 'REDDIT_DEBUG' environment variable is set to 'y', then debugging will be used. That turns off optimization and sets a macro for the C preprocessor. The C code simply contains #ifdef lines for that preprocessor macro, and has a DEBUG_PRINT macro which expands to either an fwprintf if debugging is on, or a NOP statement if debugging is off. (Currently the debug messages are directed to /tmp/reddit_error.log, but changing this just requires changing the DEBUG_FILE macro in global.h)

'run.sh' is just a bash script which runs creddit using LD_PRELOAD so you don't have to install libreddit.so to make sure the newest compiled version is used. 'run.sh' also runs creddit inside of valgrind if debugging is turned on.