int debug_enabled(void);
debug_enabled returns non-zero if the debugger is connected - you can use this to test if a debug input/output functions will work.