5754674 [rkeene@sledge /home/rkeene/devel/cygwin-stuff/cyg-root/usr/include/sys]$ cat -n strace.h
  1 /* sys/strace.h */
  2 
  3 /* This file contains routines for tracing system calls and other internal
  4    phenomenon.
  5 
  6    When tracing system calls, try to use the same style throughout:
  7 
  8    result = syscall (arg1, arg2, arg3) [optional extra stuff]
  9 
 10    If a system call can block (eg: read, write, wait), print another message
 11    before hanging so the user will know why the program has stopped.
 12 
 13    Note: __seterrno will also print a trace message.  Have that printed
 14    *first*.  This will make it easy to always know what __seterrno is
 15    refering to.  For the same reason, try not to have __seterrno messages
 16    printed alone.
 17 */
 18 
 19 #ifndef _SYS_STRACE_H
 20 #define _SYS_STRACE_H
 21 
 22 #include <stdarg.h>
 23 
 24 class strace
 25 {
 26   int vsprntf (char *buf, const char *func, const char *infmt, va_list ap);
 27   void write (unsigned category, const char *buf, int count);
 28 public:
 29   int microseconds ();
 30   int version;
 31   int active;
 32   int lmicrosec;
 33   int execing;
 34   strace() : version(1) {}
 35   void prntf (unsigned, const char *func, const char *, ...);
 36   void wm (int message, int word, int lon);
 37 };
 38 
 39 extern strace strace;
 40 
 41 #define _STRACE_INTERFACE_ACTIVATE_ADDR  -1
 42 #define _STRACE_INTERFACE_ACTIVATE_ADDR1 -2
 43 
 44 /* Bitmasks of tracing messages to print.  */
 45 
 46 #define _STRACE_ALL  0x00001 // so behaviour of strace=1 is unchanged
 47 #define _STRACE_FLUSH    0x00002 // flush output buffer after every message
 48 #define _STRACE_INHERIT  0x00004 // children inherit mask from parent
 49 #define _STRACE_UHOH     0x00008 // unusual or weird phenomenon
 50 #define _STRACE_SYSCALL  0x00010 // system calls
 51 #define _STRACE_STARTUP  0x00020 // argc/envp printout at startup
 52 #define _STRACE_DEBUG    0x00040 // info to help debugging
 53 #define _STRACE_PARANOID 0x00080 // paranoid info
 54 #define _STRACE_TERMIOS  0x00100 // info for debugging termios stuff
 55 #define _STRACE_SELECT   0x00200 // info on ugly select internals
 56 #define _STRACE_WM   0x00400 // trace windows messages (enable _strace_wm)
 57 #define _STRACE_SIGP     0x00800 // trace signal and process handling
 58 #define _STRACE_MINIMAL  0x01000 // very minimal strace output
 59 #define _STRACE_EXITDUMP 0x04000 // dump strace cache on exit
 60 #define _STRACE_SYSTEM   0x08000 // cache strace messages
 61 #define _STRACE_NOMUTEX  0x10000 // don't use mutex for synchronization
 62 #define _STRACE_MALLOC   0x20000 // trace malloc calls
 63 #define _STRACE_THREAD   0x40000 // thread-locking calls
 64 #define _STRACE_NOTALL   0x80000 // don't include if _STRACE_ALL
 65 
 66 extern "C" void small_printf (const char *, ...);
 67 
 68 #ifdef NOSTRACE
 69 #define define_strace(c, f)
 70 #define define_strace1(c, f)
 71 #else
 72 #ifdef NEW_MACRO_VARARGS
 73 /* Output message to strace log */
 74 
 75 #define define_strace0(c,...) \
 76   do { \
 77       if ((c & _STRACE_SYSTEM) || strace.active) \
 78     strace.prntf (c, __PRETTY_FUNCTION__, __VA_ARGS__); \
 79     } \
 80   while (0)
 81 
 82 #define define_strace(c, ...) define_strace0 (_STRACE_ ## c, __VA_ARGS__)
 83 #define define_strace1(c, ...) define_strace0 ((_STRACE_ ## c | _STRACE_NOTALL), __VA_ARGS__)
 84 
 85 #define debug_printf(...)   define_strace (DEBUG, __VA_ARGS__)
 86 #define paranoid_printf(...)    define_strace (PARANOID, __VA_ARGS__)
 87 #define select_printf(...)  define_strace (SELECT, __VA_ARGS__)
 88 #define sigproc_printf(...) define_strace (SIGP, __VA_ARGS__)
 89 #define syscall_printf(...) define_strace (SYSCALL, __VA_ARGS__)
 90 #define system_printf(...)  define_strace (SYSTEM, __VA_ARGS__)
 91 #define termios_printf(...) define_strace (TERMIOS, __VA_ARGS__)
 92 #define wm_printf(...)      define_strace (WM, __VA_ARGS__)
 93 #define minimal_printf(...) define_strace1 (MINIMAL, __VA_ARGS__)
 94 #define malloc_printf(...)  define_strace1 (MALLOC, __VA_ARGS__)
 95 #define thread_printf(...)  define_strace1 (THREAD, __VA_ARGS__)
 96 #else
 97 #define strace_printf_wrap(what, fmt, args...) \
 98    ((void) ({\
 99     if ((_STRACE_ ## what & _STRACE_SYSTEM) || strace.active) \
100       strace.prntf(_STRACE_ ## what, __PRETTY_FUNCTION__, fmt, ## args); \
101     0; \
102     }))
103 #define strace_printf_wrap1(what, fmt, args...) \
104     ((void) ({\
105     if ((_STRACE_ ## what & _STRACE_SYSTEM) || strace.active) \
106       strace.prntf((_STRACE_ ## what) | _STRACE_NOTALL, __PRETTY_FUNCTION__, fmt, ## args); \
107     0; \
108     }))
109 
110 #define debug_printf(fmt, args...) strace_printf_wrap(DEBUG, fmt , ## args)
111 #define paranoid_printf(fmt, args...) strace_printf_wrap(PARANOID, fmt , ## args)
112 #define select_printf(fmt, args...) strace_printf_wrap(SELECT, fmt , ## args)
113 #define sigproc_printf(fmt, args...) strace_printf_wrap(SIGP, fmt , ## args)
114 #define syscall_printf(fmt, args...) strace_printf_wrap(SYSCALL, fmt , ## args)
115 #define system_printf(fmt, args...) strace_printf_wrap(SYSTEM, fmt , ## args)
116 #define termios_printf(fmt, args...) strace_printf_wrap(TERMIOS, fmt , ## args)
117 #define wm_printf(fmt, args...) strace_printf_wrap(WM, fmt , ## args)
118 #define minimal_printf(fmt, args...) strace_printf_wrap1(MINIMAL, fmt , ## args)
119 #define malloc_printf(fmt, args...) strace_printf_wrap1(MALLOC, fmt , ## args)
120 #define thread_printf(fmt, args...) strace_printf_wrap1(THREAD, fmt , ## args)
121 #endif /*NEW_MACRO_VARARGS*/
122 #endif /*NOSTRACE*/
123 #endif /* _SYS_STRACE_H */
5754675 [rkeene@sledge /home/rkeene/devel/cygwin-stuff/cyg-root/usr/include/sys]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2001-01-31 15:09:12