Debugging code

From PLplotWiki
Jump to: navigation, search

PLplot provides some functions to help you debug the core code or driver code. You can find these function declarations in include/pldebug.h. I'll provide a short summary on this page.

Macro definitions

  • DEBUG: If set the function pldebug() will produce output, otherwise the code in pldebug() will be skipped. In addition must run your program with the option -debug to produce output.
  • NEED_PLDEBUG: The function pldebug() is only defined if NEED_PLDEBUG is set. Otherwise this function is not known.
  • DEBUG_ENTER: The function dbug_enter( message ) will produce output.
  • DEBUGGING_MALLOC: ???

Debugging functions

  • pldebug( label, format [, arg1, arg2, ...] ) : This functions creates an output message defined by the format string format and the arguments arg1, arg2, ... (equivalent to printf()) where the string label is prepended. To enable printing of debugging output, you must #define DEBUG before including plplotP.h or specify -DDEBUG in the compile line, for each file that you want to have debug output enabled. When running the program you must in addition specify -debug. This allows debugging output to tailored to many different circumstances but otherwise be fairly unobtrusive. Note, any file that actually uses pldebug() must also define NEED_PLDEBUG before the plplotP.h include. This is to eliminate warnings caused by those files in which this is defined but never referenced.
  • dbug_enter(a) : This function will put the string
        entered a (__FILE__, line __LINE__)\n
    to stderr if the macro DEBUG_ENTER is set.