• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

pldebug.h

Go to the documentation of this file.
00001 // $Id: pldebug.h 11269 2010-10-22 00:25:36Z airwin $
00002 //
00003 //  Copyright (C) 1995 by Maurice J. LeBrun
00004 //
00005 //  Debugging support for PLplot.
00006 //
00007 //  This software may be freely copied, modified and redistributed without
00008 //  fee provided that this copyright notice is preserved intact on all
00009 //  copies and modified copies.
00010 //
00011 //  There is no warranty or other guarantee of fitness of this software.
00012 //  It is provided solely "as is". The author(s) disclaim(s) all
00013 //  responsibility and liability with respect to this software's usage or
00014 //  its effect upon hardware or computer systems.
00015 //
00016 
00017 #ifndef __PLDEBUG_H__
00018 #define __PLDEBUG_H__
00019 
00020 #include <stdarg.h>
00021 
00022 // For the truly desperate debugging task
00023 
00024 #ifdef DEBUG_ENTER
00025 #define dbug_enter( a ) \
00026     if ( plsc->debug )  \
00027         fprintf( stderr, "    entered %s (%s, line %d)\n", a, __FILE__, __LINE__ );
00028 
00029 #else
00030 #define dbug_enter( a )
00031 #endif
00032 
00033 // If we're using a debugging malloc, include the header file here
00034 
00035 #ifdef DEBUGGING_MALLOC
00036 #include <malloc.h>
00037 #endif
00038 
00039 //--------------------------------------------------------------------------
00040 // pldebug()
00041 //
00042 // Included into every plplot source file to control debugging output.  To
00043 // enable printing of debugging output, you must #define DEBUG before
00044 // including plplotP.h or specify -DDEBUG in the compile line, for each file
00045 // that you want to have debug output enabled.  When running the program you
00046 // must in addition specify -debug.  This allows debugging output to tailored
00047 // to many different circumstances but otherwise be fairly unobtrusive.
00048 //
00049 // Note, any file that actually uses pldebug() must also define NEED_PLDEBUG
00050 // before the plplotP.h include.  This is to eliminate warnings caused by
00051 // those files in which this is defined but never referenced.  All this could
00052 // be much nicer if CPP had the abilities of m4, sigh..
00053 //
00054 // Syntax:
00055 //      pldebug(label, format [, arg1, arg2, ...] );
00056 //
00057 // The label is typically the calling function name.
00058 //--------------------------------------------------------------------------
00059 
00060 #ifdef NEED_PLDEBUG
00061 static void
00062 pldebug( const char *label, ... )
00063 {
00064 #ifdef DEBUG
00065     va_list args;
00066     char    *fmt;
00067 
00068     if ( plsc->debug )
00069     {
00070         if ( plsc->termin )
00071             c_pltext();
00072         va_start( args, label );
00073 
00074         // print out identifying tag
00075 
00076         fprintf( stderr, "%s: ", label );
00077 
00078         // print out remainder of message
00079         // Need to get fmt BEFORE it's used in the vfprintf
00080 
00081         fmt = (char *) va_arg( args, char * );
00082         vfprintf( stderr, fmt, args );
00083 
00084         va_end( args );
00085         if ( plsc->termin )
00086             c_plgra();
00087     }
00088 #endif  // DEBUG
00089 }
00090 #endif  // NEED_PLDEBUG
00091 
00092 #endif  // __PLDEBUG_H__

Generated on Wed Oct 12 2011 20:42:22 for PLplot by  doxygen 1.7.1