Add support for toggling debug mode and accessor function for debug mode status flag.

Change list:
a) a C++ API function for checking whether the debugger is enabled
b) functionality to stop the debugger.