1.Added dbg.h for debug information, warn and error.
2.Added two test debug functions in main.c, debug is activated by default. NDEBUG can inactivate debug messages.