PLplot: pldebug.h Source File

PLplot 5.10.0

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pldebug.h
Go to the documentation of this file.
1 // $Id: pldebug.h 11998 2011-10-21 12:34:16Z andrewross $
2 //
3 // Copyright (C) 1995 by Maurice J. LeBrun
4 //
5 // Debugging support for PLplot.
6 //
7 // This software may be freely copied, modified and redistributed without
8 // fee provided that this copyright notice is preserved intact on all
9 // copies and modified copies.
10 //
11 // There is no warranty or other guarantee of fitness of this software.
12 // It is provided solely "as is". The author(s) disclaim(s) all
13 // responsibility and liability with respect to this software's usage or
14 // its effect upon hardware or computer systems.
15 //
16
17 #ifndef __PLDEBUG_H__
18 #define __PLDEBUG_H__
19
20 #include <stdarg.h>
21
22 // For the truly desperate debugging task
23
24 #ifdef DEBUG_ENTER
25 #define dbug_enter( a ) \
26 if ( plsc->debug ) \
27 fprintf( stderr, " entered %s (%s, line %d)\n", a, __FILE__, __LINE__ );
28
29 #else
30 #define dbug_enter( a )
31 #endif
32
33 // If we're using a debugging malloc, include the header file here
34
35 #ifdef DEBUGGING_MALLOC
36 #include <malloc.h>
37 #endif
38
39 //--------------------------------------------------------------------------
40 // pldebug()
41 //
42 // Included into every plplot source file to control debugging output. To
43 // enable printing of debugging output, you must #define DEBUG before
44 // including plplotP.h or specify -DDEBUG in the compile line, for each file
45 // that you want to have debug output enabled. When running the program you
46 // must in addition specify -debug. This allows debugging output to tailored
47 // to many different circumstances but otherwise be fairly unobtrusive.
48 //
49 // Note, any file that actually uses pldebug() must also define NEED_PLDEBUG
50 // before the plplotP.h include. This is to eliminate warnings caused by
51 // those files in which this is defined but never referenced. All this could
52 // be much nicer if CPP had the abilities of m4, sigh..
53 //
54 // Syntax:
55 // pldebug(label, format [, arg1, arg2, ...] );
56 //
57 // The label is typically the calling function name.
58 //--------------------------------------------------------------------------
59
60 #ifdef NEED_PLDEBUG
61 static void
62 pldebug( const char *label, ... )
63 {
64 #ifdef DEBUG
65 va_list args;
66 char *fmt;
67
68 if ( plsc->debug )
69 {
70 if ( plsc->termin )
71 c_pltext();
72 va_start( args, label );
73
74 // print out identifying tag
75
76 fprintf( stderr, "%s: ", label );
77
78 // print out remainder of message
79 // Need to get fmt BEFORE it's used in the vfprintf
80
81 fmt = (char *) va_arg( args, char * );
82 vfprintf( stderr, fmt, args );
83
84 va_end( args );
85 if ( plsc->termin )
86 c_plgra();
87 }
88 #else
89 // Avoid warning about unused parameter
90 (void) label;
91 #endif // DEBUG
92 }
93 #endif // NEED_PLDEBUG
94
95 #endif // __PLDEBUG_H__