Difference between revisions of "Debugging code"

From PLplotWiki
Jump to: navigation, search
(Debugging functions)
(Debugging functions)
Line 9: Line 9:
 
=== Debugging functions ===
 
=== Debugging functions ===
 
* <tt>pldebug( label, format [, arg1, arg2, ...] )</tt> :  This functions creates an output message defined by the format string <tt>format</tt> and the arguments <tt>arg1, arg2, ...</tt> (equivalent to <tt>printf()</tt>) where the string <tt>label</tt> is prepended. To enable printing of debugging output, you must <tt>#define DEBUG</tt> 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 <tt>-debug</tt>.  This allows debugging output to tailored to many different circumstances but otherwise be fairly unobtrusive. Note, any file that actually uses <tt>pldebug()</tt> must also define <tt>NEED_PLDEBUG</tt> before the <tt>plplotP.h</tt> include.  This is to eliminate warnings caused by those files in which this is defined but never referenced.
 
* <tt>pldebug( label, format [, arg1, arg2, ...] )</tt> :  This functions creates an output message defined by the format string <tt>format</tt> and the arguments <tt>arg1, arg2, ...</tt> (equivalent to <tt>printf()</tt>) where the string <tt>label</tt> is prepended. To enable printing of debugging output, you must <tt>#define DEBUG</tt> 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 <tt>-debug</tt>.  This allows debugging output to tailored to many different circumstances but otherwise be fairly unobtrusive. Note, any file that actually uses <tt>pldebug()</tt> must also define <tt>NEED_PLDEBUG</tt> before the <tt>plplotP.h</tt> include.  This is to eliminate warnings caused by those files in which this is defined but never referenced.
*<tt>dbug_enter(a)</tt> : This function will put the string <tt>    entered a (__FILE__, line __LINE__\n</tt> to <tt>stderr</tt> if the macro <tt>DEBUG_ENTER</tt> is set.
+
*<tt>dbug_enter(a)</tt> : This function will put the string <nowiki>    entered a (__FILE__, line __LINE__\n</nowiki> to <tt>stderr</tt> if the macro <tt>DEBUG_ENTER</tt> is set.

Revision as of 00:59, 16 June 2008

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.