home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / TRSICAT.LZX / CATS_CD2_TRSI / Reference_Library / Devices / iffp / debug.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-21  |  3.0 KB  |  111 lines

  1. /*
  2.  * mydebug.h - #include this file sometime after stdio.h
  3.  * Set MYDEBUG to 1 to turn on debugging, 0 to turn off debugging
  4.  */
  5.  
  6. #ifndef MYDEBUG_H
  7. #define MYDEBUG_H
  8.  
  9. #define MYDEBUG     0
  10.  
  11.  
  12. #if MYDEBUG
  13.  
  14. /*
  15.  * MYDEBUG User Options
  16.  */
  17.  
  18. /* Set to 1 to turn second level D2(bug()) statements */
  19. #define DEBUGLEVEL2    1
  20.  
  21. /* Set to a non-zero # of ticks if a delay is wanted after each debug message */
  22. #define DEBUGDELAY        0
  23.  
  24. /* Always non-zero for the DDx macros */
  25. #define DDEBUGDELAY        50
  26.  
  27. /* Set to 1 for serial debugging (link with debug.lib) */
  28. #define KDEBUG        0
  29.  
  30. /* Set to 1 for parallel debugging (link with ddebug.lib) */
  31. #define DDEBUG        0
  32.  
  33. #endif /* MYDEBUG */
  34.  
  35.  
  36. /* Prototypes for Delay, kprintf, dprintf. Or use proto/dos.h or functions.h. */
  37. #include <clib/dos_protos.h>
  38. void kprintf(UBYTE *fmt,...);
  39. void dprintf(UBYTE *fmt,...);
  40.  
  41. /*
  42.  * D(bug()), D2(bug()), DQ((bug()) only generate code if MYDEBUG is non-zero
  43.  *
  44.  * Use D(bug()) for general debugging, D2(bug()) for extra debugging that
  45.  * you usually won't need to see, DD(bug()) for debugging statements that
  46.  * you always want followed by a delay, and DQ(bug()) for debugging that
  47.  * you'll NEVER want a delay after (ie. debugging inside a Forbid, Disable,
  48.  * Task, or Interrupt)
  49.  *
  50.  * Some example uses (all are used the same):
  51.  * D(bug("about to do xyz. variable = $%lx\n",myvariable)); 
  52.  * D2(bug("v1=$%lx v2=$%lx v3=$%lx\n",v1,v2,v3)); 
  53.  * DQ(bug("in subtask: variable = $%lx\n",myvariable));
  54.  * DD(bug("About to do xxx\n"));
  55.  *
  56.  * Set MYDEBUG above to 1 when debugging is desired and recompile the modules
  57.  *  you wish to debug.  Set to 0 and recompile to turn off debugging.
  58.  *
  59.  * User options set above:
  60.  * Set DEBUGDELAY to a non-zero # of ticks (ex. 50) when a delay is desired.
  61.  * Set DEBUGLEVEL2 nonzero to turn on second level (D2) debugging statements
  62.  * Set KDEBUG to 1 and link with debug.lib for serial debugging.
  63.  * Set DDEBUG to 1 and link with ddebug.lib for parallel debugging.
  64.  */
  65.  
  66.  
  67. /* 
  68.  * Debugging function automaticaly set to printf, kprintf, or dprintf
  69.  */
  70.  
  71. #if KDEBUG
  72. #define bug kprintf
  73. #elif DDEBUG
  74. #define bug dprintf
  75. #else    /* else changes all bug's to printf's */
  76. #define bug printf
  77. #endif
  78.  
  79. /*
  80.  * Debugging macros
  81.  */
  82.  
  83. /* D(bug(     delays DEBUGDELAY if DEBUGDELAY is > 0
  84.  * DD(bug(    always delays DDEBUGDELAY
  85.  * DQ(bug(      (debug quick) never uses Delay.  Use in forbids,disables,ints
  86.  * The similar macros with "2" in their names are second level debugging
  87.  */
  88. #if MYDEBUG    /* Turn on first level debugging */
  89. #define D(x)  (x); if(DEBUGDELAY>0) Delay(DEBUGDELAY)
  90. #define DD(x) (x); Delay(DDEBUGDELAY)
  91. #define DQ(x) (x)
  92. #if DEBUGLEVEL2 /* Turn on second level debugging */
  93. #define D2(x)  (x); if(DEBUGDELAY>0) Delay(DEBUGDELAY)
  94. #define DD2(x) (x); Delay(DDEBUGDELAY)
  95. #define DQ2(x) (x)
  96. #else  /* Second level debugging turned off */
  97. #define D2(x) ;
  98. #define DD2(x) ;
  99. #define DQ2(x) ;
  100. #endif /* DEBUGLEVEL2 */
  101. #else  /* First level debugging turned off */
  102. #define D(x) ;
  103. #define DQ(x) ;
  104. #define D2(x) ;
  105. #define DD(x) ;
  106. #endif
  107.  
  108.  
  109. #endif /* MYDEBUG_H */
  110.  
  111.