summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-02-11 18:16:28 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-02-11 18:16:28 +0000
commit6006a7cf5bcbed74b706541a0c59cdc7ae95eec6 (patch)
treeba13dba9d4c8ea95acfc4aeb80b070e23d17e8aa
parent3fe3019ea9187a91e5ae5e3ff6646804239c453b (diff)
downloadATCD-6006a7cf5bcbed74b706541a0c59cdc7ae95eec6.tar.gz
(use_debug_stream_to_get_rid_of_warning): changed to return
debug_stream instead of (not) using it. ghs warned that "controlling expression is constant" the way things were.
-rw-r--r--TAO/tao/debug.cpp185
1 files changed, 95 insertions, 90 deletions
diff --git a/TAO/tao/debug.cpp b/TAO/tao/debug.cpp
index 5f277247988..2a641c607f9 100644
--- a/TAO/tao/debug.cpp
+++ b/TAO/tao/debug.cpp
@@ -1,8 +1,9 @@
-// @ (#)debug.cpp 1.3 95/10/02
+// $Id$
+// @ (#)debug.cpp 1.3 95/10/02
// Copyright 1994-1995 by Sun Microsystems Inc.
// All Rights Reserved
//
-// ORB: Simple debug/trace support
+// ORB: Simple debug/trace support
//
// THREADING NOTE: the global values here (debug_{level,filter,stream)
// are assumed to be modified "safely", e.g. in the main thread as
@@ -13,18 +14,22 @@
#include "tao/corba.h"
-#if !defined (ACE_HAS_PTHREADS) // _POSIX_THREAD_SAFE_FUNCTIONS implied
-#define flockfile(f)
+#if !defined (ACE_HAS_PTHREADS) // _POSIX_THREAD_SAFE_FUNCTIONS implied
+#define flockfile(f)
#define funlockfile(f)
#endif /* ACE_HAS_PTHREADS */
-u_int TAO_Export TAO_debug_level = 0;
-char * TAO_Export TAO_debug_filter = "l";
+u_int TAO_Export TAO_debug_level = 0;
+char * TAO_Export TAO_debug_filter = "l";
static FILE *debug_stream = stderr;
-void use_debug_stream_to_get_rid_of_warning (void) {ACE_UNUSED_ARG (debug_stream);}
// Dummy function to get rid of "'debug_stream' defined but not used" warning
+FILE *
+use_debug_stream_to_get_rid_of_warning (void)
+{
+ return debug_stream;
+}
// The rest of this file is not needed without -DDEBUG, and unless the
// vfprintf () call is available it can't work.
@@ -33,7 +38,7 @@ void use_debug_stream_to_get_rid_of_warning (void) {ACE_UNUSED_ARG (debug_stream
// same functionality ... this could be modified to use that routine
// where it's available.
-#if defined (DEBUG) && defined (HAVE_VPRINTF)
+#if defined (DEBUG) && defined (HAVE_VPRINTF)
// Support for prefixing debug messages with process ID and, if
// threaded, the thread ID. This lets messages from different sources
@@ -66,7 +71,7 @@ emit_prefix (FILE *stream)
}
// !defined (ACE_HAS_PTHREADS)
-#else
+#else
// Without threads, guard initialization so it can be repeated,
// and don't emit the thread ID in the messages.
@@ -74,17 +79,17 @@ emit_prefix (FILE *stream)
static void
setup (void)
{
- if (my_pid == 0)
+ if (my_pid == 0)
{
my_pid = ACE_OS::getpid ();
// other setup goes here
}
}
-#define emit_prefix(stream) fprintf (stream, "p%ld: ", (long) my_pid)
-#endif /* !ACE_HAS_PTHREADS */
+#define emit_prefix(stream) fprintf (stream, "p%ld: ", (long) my_pid)
+#endif /* !ACE_HAS_PTHREADS */
-#elif defined (_WIN32)
+#elif defined (_WIN32)
// Not all implementations of Win32 have threads, but in any case this
// code doesn't yet support Win32 threads.
@@ -92,35 +97,35 @@ setup (void)
static void
setup (void)
{
- if (my_pid == 0)
+ if (my_pid == 0)
my_pid = GetCurrentProcessId ();
// other setup goes here
}
-#define emit_prefix(stream) fprintf (stream, "p%ld: ", my_pid)
+#define emit_prefix(stream) fprintf (stream, "p%ld: ", my_pid)
#else
-# error "unknown OS platform"
+# error "unknown OS platform"
#endif /* OS-specific initialization */
void TAO_Export
dmsg_filter (const char *_FAR categories,
- const char *_FAR fmt,
- ...)
+ const char *_FAR fmt,
+ ...)
{
const char *cp = 0;
if (!categories || !TAO_debug_filter)
return;
- else if (*TAO_debug_filter != '*')
- { // filter with "*" --> all pass
+ else if (*TAO_debug_filter != '*')
+ { // filter with "*" --> all pass
for (cp = categories; *cp; cp++)
- if (strchr (TAO_debug_filter, *cp) != 0)
- break;
+ if (strchr (TAO_debug_filter, *cp) != 0)
+ break;
if (!*cp)
- return;
+ return;
}
va_list ap;
@@ -129,9 +134,9 @@ dmsg_filter (const char *_FAR categories,
flockfile (debug_stream);
emit_prefix (debug_stream);
- switch (*cp)
- { // standard categories
- case 'l': ACE_OS::fprintf (debug_stream, " (LEAK) "); break;
+ switch (*cp)
+ { // standard categories
+ case 'l': ACE_OS::fprintf (debug_stream, " (LEAK) "); break;
}
va_start (ap, fmt);
@@ -142,14 +147,14 @@ dmsg_filter (const char *_FAR categories,
funlockfile (debug_stream);
#if defined (_WIN32)
- OutputDebugString ("called dmsg_filter\n"); // experimental
+ OutputDebugString ("called dmsg_filter\n"); // experimental
#endif /* _WIN32 */
}
void TAO_Export
-dmsg_filter (u_int level,
- const char *_FAR fmt,
- ...)
+dmsg_filter (u_int level,
+ const char *_FAR fmt,
+ ...)
{
if (level > TAO_debug_level)
return;
@@ -167,13 +172,13 @@ dmsg_filter (u_int level,
funlockfile (debug_stream);
#if defined (_WIN32)
- OutputDebugString ("called dmsg_filter\n"); // experimental
+ OutputDebugString ("called dmsg_filter\n"); // experimental
#endif /* _WIN32 */
}
void TAO_Export
-dmsg_v (const char *_FAR fmt,
- ...)
+dmsg_v (const char *_FAR fmt,
+ ...)
{
va_list ap;
@@ -188,39 +193,39 @@ dmsg_v (const char *_FAR fmt,
funlockfile (debug_stream);
#if defined (_WIN32)
- OutputDebugString ("called dmsg_v\n"); // experimental
+ OutputDebugString ("called dmsg_v\n"); // experimental
#endif /* _WIN32 */
}
void TAO_Export
-_dmsg_x (CORBA::Environment _FAR &env,
- const char *_FAR info)
+_dmsg_x (CORBA::Environment _FAR &env,
+ const char *_FAR info)
{
- const CORBA::Exception *ex = env.exception ();
+ const CORBA::Exception *ex = env.exception ();
setup ();
flockfile (debug_stream);
emit_prefix (debug_stream);
ACE_OS::fprintf (debug_stream, "exception '%s' at '%s'\n", ex->id (), info);
- if (env.exception_type () == CORBA::SYSTEM_EXCEPTION)
+ if (env.exception_type () == CORBA::SYSTEM_EXCEPTION)
{
CORBA::SystemException *sysex = (CORBA::SystemException *) ex;
emit_prefix (debug_stream);
ACE_OS::fprintf (debug_stream, "minor %#lx, completion %#lx\n",
- sysex->minor (), (long) sysex->completion ());
+ sysex->minor (), (long) sysex->completion ());
}
funlockfile (debug_stream);
#if defined (_WIN32)
- OutputDebugString ("called _dmsg_x\n"); // experimental
+ OutputDebugString ("called _dmsg_x\n"); // experimental
#endif /* _WIN32 */
}
void TAO_Export
dmsg_opaque (char *_FAR label,
- u_char *_FAR buffer,
- u_long len)
+ u_char *_FAR buffer,
+ u_long len)
{
setup ();
flockfile (debug_stream);
@@ -231,47 +236,47 @@ dmsg_opaque (char *_FAR label,
ACE_OS::fprintf (debug_stream, " (empty)");
else if (len > UINT_MAX)
ACE_OS::fprintf (debug_stream, "Oversized opaque data: %ld bytes", len);
- else
+ else
{
u_int i;
for (i = 0; i < len; i++)
- if (!isprint (buffer [i]))
- break;
-
- if (i < len)
- {
- if (len >= 20)
- ACE_OS::fprintf (debug_stream, "%ld bytes binary data", len);
- else
- {
- ACE_OS::fprintf (debug_stream, "binary data {%2X", buffer [0]);
- for (i = 1; i < len; i++)
- ACE_OS::fprintf (debug_stream, ", %2x", buffer [i]);
- ACE_OS::fprintf (debug_stream, "}");
- }
- }
- else
- {
- if (len >= 50)
- ACE_OS::fprintf (debug_stream, "%ld bytes string data", len);
- else
- ACE_OS::fprintf (debug_stream, "string data { \"%.*s\" }",
+ if (!isprint (buffer [i]))
+ break;
+
+ if (i < len)
+ {
+ if (len >= 20)
+ ACE_OS::fprintf (debug_stream, "%ld bytes binary data", len);
+ else
+ {
+ ACE_OS::fprintf (debug_stream, "binary data {%2X", buffer [0]);
+ for (i = 1; i < len; i++)
+ ACE_OS::fprintf (debug_stream, ", %2x", buffer [i]);
+ ACE_OS::fprintf (debug_stream, "}");
+ }
+ }
+ else
+ {
+ if (len >= 50)
+ ACE_OS::fprintf (debug_stream, "%ld bytes string data", len);
+ else
+ ACE_OS::fprintf (debug_stream, "string data { \"%.*s\" }",
(int) len, buffer);
- }
+ }
}
ACE_OS::fprintf (debug_stream, "\n");
funlockfile (debug_stream);
#if defined (_WIN32)
- OutputDebugString ("called dmsg_opaque\n"); // experimental
+ OutputDebugString ("called dmsg_opaque\n"); // experimental
#endif /* _WIN32 */
}
void TAO_Export
dmsg_opaque_full (char *_FAR label,
- const u_char *_FAR buffer,
- u_long len)
+ const u_char *_FAR buffer,
+ u_long len)
{
setup ();
flockfile (debug_stream);
@@ -281,33 +286,33 @@ dmsg_opaque_full (char *_FAR label,
if (len == 0 || !buffer)
ACE_OS::fprintf (debug_stream, " (empty)");
- else
+ else
{
u_int i;
for (i = 0; i < len; i++)
- {
- if (i == 0)
- ACE_OS::fprintf (debug_stream, "\nhex: ");
- else if ((i % 32) == 0)
- ACE_OS::fprintf (debug_stream, "\n ");
- else if ((i % 4) == 0)
- ACE_OS::fprintf (debug_stream, " ");
- ACE_OS::fprintf (debug_stream, "%02x", buffer[i]);
- }
+ {
+ if (i == 0)
+ ACE_OS::fprintf (debug_stream, "\nhex: ");
+ else if ((i % 32) == 0)
+ ACE_OS::fprintf (debug_stream, "\n ");
+ else if ((i % 4) == 0)
+ ACE_OS::fprintf (debug_stream, " ");
+ ACE_OS::fprintf (debug_stream, "%02x", buffer[i]);
+ }
for (i = 0; i < len; i++)
- {
- if (i == 0)
- ACE_OS::fprintf (debug_stream, "\nchars: ");
- else if ((i % 32) == 0)
- ACE_OS::fprintf (debug_stream, "\n ");
- else if ((i % 4) == 0)
- ACE_OS::fprintf (debug_stream, " ");
- ACE_OS::fprintf (debug_stream, "%c ",
- (isprint (buffer[i]) ? buffer[i] : '?'));
-
- }
+ {
+ if (i == 0)
+ ACE_OS::fprintf (debug_stream, "\nchars: ");
+ else if ((i % 32) == 0)
+ ACE_OS::fprintf (debug_stream, "\n ");
+ else if ((i % 4) == 0)
+ ACE_OS::fprintf (debug_stream, " ");
+ ACE_OS::fprintf (debug_stream, "%c ",
+ (isprint (buffer[i]) ? buffer[i] : '?'));
+
+ }
ACE_OS::fprintf (debug_stream, "\n");
}
@@ -315,7 +320,7 @@ dmsg_opaque_full (char *_FAR label,
funlockfile (debug_stream);
#if defined (_WIN32)
- OutputDebugString ("called dmsg_opaque_full\n"); // experimental
+ OutputDebugString ("called dmsg_opaque_full\n"); // experimental
#endif /* _WIN32 */
}