1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
// $Id$
// This may look like C, but it's really -*- C++ -*-
// ============================================================================
//
// = LIBRARY
// TAO
//
// = FILENAME
// debug.h
//
// = DESCRIPTION
// debug/trace support.
//
// = AUTHOR
// Copyright 1994-1995 by Sun Microsystems Inc.
//
// ============================================================================
#if !defined (TAO_DEBUG_H)
#define TAO_DEBUG_H
// These are global to simplify is use by other code, very much in
// particular by getopt and related argument-parsing code
//
// THREADING NOTE: don't set them except in an unthreaded environment
// such as process initialization. They're treated as immutable.
// 0 to ??; higher == more
extern TAO_Export u_int TAO_debug_level;
// debug messages on (1) or off (0)
extern TAO_Export u_int TAO_orbdebug;
// set by getopt
extern TAO_Export char *TAO_debug_filter;
// These are just simple 0, 1, and 2 argument messages that will
// appear when debugging's enabled, regardless of category. They also
// just compile out painlessly.
#if defined (DEBUG)
#include <stdio.h>
#include <errno.h>
#include <string.h>
// 1, 2, 3 argument messages -- generic
#define dmsg(s) { if (TAO_debug_level) dmsg_v (s); }
#define dmsg1(s,a1) { if (TAO_debug_level) dmsg_v (s, a1); }
#define dmsg2(s,a1,a2) { if (TAO_debug_level) dmsg_v (s, a1, a2); }
// dump CORBA_Exception, if any, with id tag
#define dexc(env,s) { if (TAO_debug_level && env.exception ()) \
_dmsg_x (env, s); }
// dump POSIX error indication, if any, with ID tag
#define dperror(str) { if (TAO_debug_level) dmsg_v ("%s: %s", \
str, strerror (errno)); }
// dump socket error indication, if any, with ID tag
#if defined (_WINSOCKAPI_)
#define dsockerr(s) { if (TAO_debug_level) dmsg_v ("%s: winsock error %d", \
s, WSAGetLastError()); }
#else
#define dsockerr(s) dperror(s)
#endif /* _WINSOCKAPI_ */
#else /* !DEBUG */
#define dmsg(s) { }
#define dmsg1(s,a1) { }
#define dmsg2(s,a1,a2) { }
#define dexc(env, s) { }
#define dperror(s) { }
#define dsockerr(s) { }
#endif /* DEBUG */
// These don't compile out; you must #ifdef them. This is done
// intentionally since CPP macros have severe limits, and varargs _(or
// lack thereof) is one of them.
#if defined (DEBUG)
// This is like an fprintf statement except the filter is a set of
// characters (string). If TAO_debug_level is nonzero and any
// characters in that string are in the "TAO_debug_filter" string, the
// message is then printed. Assign thosee characters as needed.
extern void TAO_Export dmsg_filter (const char *filter,
const char *fmt,
...);
// Filter according to TAO_debug_level instead of category. (For
// speed, test against TAO_debug_level directly.)
extern void TAO_Export dmsg_filter (u_int level,
const char *fmt,
...);
// General varargs debug message printer, no filtering
extern void TAO_Export dmsg_v (const char *fmt,
...);
extern void TAO_Export _dmsg_x (CORBA_Environment &env,
const char *info);
extern void TAO_Export dmsg_opaque (char *label,
u_char *buffer,
u_long len);
extern void TAO_Export dmsg_opaque_full (char *label,
const u_char *buffer,
u_long len);
#endif /* DEBUG */
#endif /* TAO_DEBUG_H */
|