home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d0xx / d041 / dbug.lha / Dbug / dbug.h < prev    next >
Encoding:
C/C++ Source or Header  |  1986-11-27  |  5.2 KB  |  146 lines

  1. /************************************************************************
  2.  *                                    *
  3.  *            Copyright (c) 1984, Fred Fish            *
  4.  *                All Rights Reserved                *
  5.  *                                    *
  6.  *    This software and/or documentation is released for public    *
  7.  *    distribution for personal, non-commercial use only.        *
  8.  *    Limited rights to use, modify, and redistribute are hereby    *
  9.  *    granted for non-commercial purposes, provided that all        *
  10.  *    copyright notices remain intact and all changes are clearly    *
  11.  *    documented.  The author makes no warranty of any kind with    *
  12.  *    respect to this product and explicitly disclaims any implied    *
  13.  *    warranties of merchantability or fitness for any particular    *
  14.  *    purpose.                            *
  15.  *                                    *
  16.  ************************************************************************
  17.  */
  18.  
  19.  
  20. /*
  21.  *  FILE
  22.  *
  23.  *    dbug.h    user include file for programs using the dbug package
  24.  *
  25.  *  SYNOPSIS
  26.  *
  27.  *    #include <local/dbug.h>
  28.  *
  29.  *  SCCS ID
  30.  *
  31.  *    @(#)dbug.h    1.9 10/29/86
  32.  *
  33.  *  DESCRIPTION
  34.  *
  35.  *    Programs which use the dbug package must include this file.
  36.  *    It contains the appropriate macros to call support routines
  37.  *    in the dbug runtime library.
  38.  *
  39.  *    To disable compilation of the macro expansions define the
  40.  *    preprocessor symbol "DBUG_OFF".  This will result in null
  41.  *    macros expansions so that the resulting code will be smaller
  42.  *    and faster.  (The difference may be smaller than you think
  43.  *    so this step is recommended only when absolutely necessary).
  44.  *    In general, tradeoffs between space and efficiency are
  45.  *    decided in favor of efficiency since space is seldom a
  46.  *    problem on the new machines).
  47.  *
  48.  *    All externally visible symbol names follow the pattern
  49.  *    "_db_xxx..xx_" to minimize the possibility of a dbug package
  50.  *    symbol colliding with a user defined symbol.
  51.  *    
  52.  *    The DBUG_<N> style macros are obsolete and should not be used
  53.  *    in new code.  Macros to map them to instances of DBUG_PRINT
  54.  *    are provided for compatibility with older code.  They may go
  55.  *    away completely in subsequent releases.
  56.  *
  57.  *  AUTHOR
  58.  *
  59.  *    Fred Fish
  60.  *    (Currently employed by Motorola Computer Division, Tempe, Az.)
  61.  *    (602) 438-5976
  62.  *
  63.  */
  64.  
  65.  
  66. /*
  67.  *    Internally used dbug variables which must be global.
  68.  */
  69.  
  70. #ifndef DBUG_OFF
  71.     extern int _db_on_;            /* TRUE if debug currently enabled */
  72.     extern FILE *_db_fp_;        /* Current debug output stream */
  73.     extern char *_db_process_;        /* Name of current process */
  74.     extern int _db_keyword_ ();        /* Accept/reject keyword */
  75.     extern void _db_push_ ();        /* Push state, set up new state */
  76.     extern void _db_pop_ ();        /* Pop previous debug state */
  77.     extern void _db_enter_ ();        /* New user function entered */
  78.     extern void _db_return_ ();        /* User function return */
  79.     extern void _db_pargs_ ();        /* Remember args for line */
  80.     extern void _db_doprnt_ ();        /* Print debug output */
  81.     extern void _db_setjmp_ ();        /* Save debugger environment */
  82.     extern void _db_longjmp_ ();    /* Restore debugger environment */
  83. # endif
  84.  
  85.  
  86. /*
  87.  *    These macros provide a user interface into functions in the
  88.  *    dbug runtime support library.  They isolate users from changes
  89.  *    in the MACROS and/or runtime support.
  90.  *
  91.  *    The symbols "__LINE__" and "__FILE__" are expanded by the
  92.  *    preprocessor to the current source file line number and file
  93.  *    name respectively.
  94.  *
  95.  *    WARNING ---  Because the DBUG_ENTER macro allocates space on
  96.  *    the user function's stack, it must precede any executable
  97.  *    statements in the user function.
  98.  *
  99.  */
  100.  
  101. # ifdef DBUG_OFF
  102. #    define DBUG_ENTER(a1)
  103. #    define DBUG_RETURN(a1) return(a1)
  104. #    define DBUG_VOID_RETURN return
  105. #    define DBUG_EXECUTE(keyword,a1)
  106. #    define DBUG_PRINT(keyword,arglist)
  107. #    define DBUG_2(keyword,format)        /* Obsolete */
  108. #    define DBUG_3(keyword,format,a1)        /* Obsolete */
  109. #    define DBUG_4(keyword,format,a1,a2)    /* Obsolete */
  110. #    define DBUG_5(keyword,format,a1,a2,a3)    /* Obsolete */
  111. #    define DBUG_PUSH(a1)
  112. #    define DBUG_POP()
  113. #    define DBUG_PROCESS(a1)
  114. #    define DBUG_FILE (stderr)
  115. #    define DBUG_SETJMP setjmp
  116. #    define DBUG_LONGJMP longjmp
  117. # else
  118. #    define DBUG_ENTER(a) \
  119.     auto char *_db_func_, *_db_file_; \
  120.     int _db_level_; \
  121.     _db_enter_ (a,__FILE__,__LINE__,&_db_func_,&_db_file_,&_db_level_)
  122. #    define DBUG_LEAVE \
  123.     (_db_return_ (__LINE__, &_db_func_, &_db_file_, &_db_level_))
  124. #    define DBUG_RETURN(a1) return (DBUG_LEAVE, (a1))
  125. /*   define DBUG_RETURN(a1) {DBUG_LEAVE; return(a1);}  Alternate form */
  126. #    define DBUG_VOID_RETURN {DBUG_LEAVE; return;}
  127. #    define DBUG_EXECUTE(keyword,a1) \
  128.     {if (_db_on_) {if (_db_keyword_ (keyword)) { a1 }}}
  129. #    define DBUG_PRINT(keyword,arglist) \
  130.     {if (_db_on_) {_db_pargs_(__LINE__,keyword); _db_doprnt_ arglist;}}
  131. #    define DBUG_2(keyword,format) \
  132.     DBUG_PRINT(keyword,(format))        /* Obsolete */
  133. #    define DBUG_3(keyword,format,a1) \
  134.     DBUG_PRINT(keyword,(format,a1))        /* Obsolete */
  135. #    define DBUG_4(keyword,format,a1,a2) \
  136.     DBUG_PRINT(keyword,(format,a1,a2))    /* Obsolete */
  137. #    define DBUG_5(keyword,format,a1,a2,a3) \
  138.     DBUG_PRINT(keyword,(format,a1,a2,a3))    /* Obsolete */
  139. #    define DBUG_PUSH(a1) _db_push_ (a1)
  140. #    define DBUG_POP() _db_pop_ ()
  141. #    define DBUG_PROCESS(a1) (_db_process_ = a1)
  142. #    define DBUG_FILE (_db_fp_)
  143. #    define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
  144. #    define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
  145. # endif
  146.