PLplot: pldebug.h Source File

PLplot 5.15.0

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