home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / monitors / rsys / rsyssrc.lha / RSysDebug.h < prev    next >
C/C++ Source or Header  |  1993-07-24  |  4KB  |  139 lines

  1. /*
  2. ***************************************************************************
  3. *
  4. * Datei:
  5. *      RSysDebug.h
  6. *
  7. * Inhalt:
  8. *
  9. *         --- Globale Routinen ---
  10. *
  11. *
  12. *         --- Lokale  Routinen ---
  13. *
  14. *
  15. * Bemerkungen:
  16. *      Include-Datei zur Installierung von Debug-Routinen in RSys.
  17. *      Das Define MYDEBUG ist zu entkommentieren, falls ein Debugging
  18. *      stattfinden soll.
  19. *
  20. * Erstellungsdatum:
  21. *      07-Jul-93     Rolf Böhme
  22. *
  23. * Änderungen:
  24. *      07-Jul-93     Rolf Böhme      Erstellung
  25. *
  26. ***************************************************************************
  27. */
  28.  
  29. /*
  30.  * Set MYDEBUG to 1 to turn on debugging, 0 to turn off debugging
  31.  */
  32. #ifndef MYDEBUG_H
  33. #define MYDEBUG_H
  34.  
  35. /*#define MYDEBUG     1*/
  36.  
  37. #if MYDEBUG
  38. /*
  39.  * MYDEBUG User Options
  40.  */
  41.  
  42. /* Set to 1 to turn second level D2(bug()) statements */
  43. #define DEBUGLEVEL2    0
  44.  
  45. /* Set to a non-zero # of ticks if a delay is wanted after each debug message */
  46. #define DEBUGDELAY        20
  47.  
  48. /* Always non-zero for the DDx macros */
  49. #define DDEBUGDELAY        50
  50.  
  51. /* Set to 1 for serial debugging (link with debug.lib) */
  52. #define KDEBUG     1
  53.  
  54. /* Set to 1 for parallel debugging (link with ddebug.lib) */
  55. #define DDEBUG        0
  56.  
  57. #endif /* MYDEBUG */
  58.  
  59. /*
  60.  * D(bug()), D2(bug()), DQ((bug()) only generate code if MYDEBUG is non-zero
  61.  *
  62.  * Use D(bug()) for general debugging, D2(bug()) for extra debugging that
  63.  * you usually won't need to see, DD(bug()) for debugging statements that
  64.  * you always want followed by a delay, and DQ(bug()) for debugging that
  65.  * you'll NEVER want a delay after (ie. debugging inside a Forbid, Disable,
  66.  * Task, or Interrupt)
  67.  *
  68.  * Some example uses (all are used the same):
  69.  * D(bug("about to do xyz. variable = $%lx\n",myvariable));
  70.  * D2(bug("v1=$%lx v2=$%lx v3=$%lx\n",v1,v2,v3));
  71.  * DQ(bug("in subtask: variable = $%lx\n",myvariable));
  72.  * DD(bug("About to do xxx\n"));
  73.  *
  74.  * Set MYDEBUG above to 1 when debugging is desired and recompile the modules
  75.  *  you wish to debug.    Set to 0 and recompile to turn off debugging.
  76.  *
  77.  * User options set above:
  78.  * Set DEBUGDELAY to a non-zero # of ticks (ex. 50) when a delay is desired.
  79.  * Set DEBUGLEVEL2 nonzero to turn on second level (D2) debugging statements
  80.  * Set KDEBUG to 1 and link with debug.lib for serial debugging.
  81.  * Set DDEBUG to 1 and link with ddebug.lib for parallel debugging.
  82.  */
  83.  
  84.  
  85. /*
  86.  * Debugging function automaticaly set to printf, kprintf, or dprintf
  87.  */
  88.  
  89. #if KDEBUG
  90. #define bug kprintf
  91. #elif DDEBUG
  92. #define bug dprintf
  93. #else    /* else changes all bug's to printf's */
  94. #define bug printf
  95. #endif
  96.  
  97. /*
  98.  * Debugging macros
  99.  */
  100.  
  101. /* D(bug(     delays DEBUGDELAY if DEBUGDELAY is > 0
  102.  * DD(bug(    always delays DDEBUGDELAY
  103.  * DQ(bug(         (debug quick) never uses Delay.  Use in forbids,disables,ints
  104.  * The similar macros with "2" in their names are second level debugging
  105.  */
  106. #if MYDEBUG     /* Turn on first level debugging */
  107. #define D(x)  (x); if(DEBUGDELAY>0) Delay(DEBUGDELAY)
  108. #define DD(x) (x); Delay(DDEBUGDELAY)
  109. #define DQ(x) (x)
  110. #if DEBUGLEVEL2 /* Turn on second level debugging */
  111. #define D2(x)    (x); if(DEBUGDELAY>0) Delay(DEBUGDELAY)
  112. #define DD2(x) (x); Delay(DDEBUGDELAY)
  113. #define DQ2(x) (x)
  114. #else  /* Second level debugging turned off */
  115. #define D2(x) ;
  116. #define DD2(x) ;
  117. #define DQ2(x) ;
  118. #endif /* DEBUGLEVEL2 */
  119. #else  /* First level debugging turned off */
  120. #define D(x) ;
  121. #define DQ(x) ;
  122. #define D2(x) ;
  123. #define DD(x) ;
  124. #endif
  125.  
  126. #define DPOS D(kprintf("File %20s at line %3ld in %s()\n",__FILE__,__LINE__,__FUNC__))
  127.  
  128. #endif
  129.  
  130. /*#define LOGLEVEL 1*/
  131.  
  132. #if LOGLEVEL
  133. #define DPOS {if(SysWnd) OffMenu(SysWnd,FULLMENUNUM(7,0,0));OpenErrorLogFile();WriteLogFile(0,"File %20s at line %3ld in %s()\n",__FILE__,__LINE__,__FUNC__);CloseErrorLogFile();}
  134. #endif
  135.  
  136. /* MYDEBUG_H */
  137.  
  138.  
  139.