debug output tunings
- From: jacob berkman <jacob ximian com>
- To: orbit-list gnome org
- Subject: debug output tunings
- Date: 04 Jan 2002 14:50:14 -0500
this patch is a stab at letting the debug flags orbit runs with be
tunable at run-time.
currently it just looks at the ORBIT_DEBUG env var, but it could use an
--orbit-debug command line arg like gtk quite easily. so you can set
ORBIT_DEBUG=traces, or ORBIT_DEBUG=traces:timings to choose the spew you
want at run time. there's no performance / size hit when debugging is
off, and a limited runtime hit if you have debugging on but no debugging
flags set.
it's not totally correct or complete, but i don't really know which
things encased in #ifdef DEBUG are internal or would be helpful for
people debugging corba problems. hopefully one of you guys would like
to finish this part :)
jacob
--
"In fact, can you imagine anything more terrifying than a zombie clown?"
-- moby
Index: configure.in
===================================================================
RCS file: /cvs/gnome/ORBit2/configure.in,v
retrieving revision 1.68
diff -u -r1.68 configure.in
--- configure.in 2001/12/31 10:47:57 1.68
+++ configure.in 2002/01/04 19:48:25
@@ -52,6 +52,15 @@
dnl --enable-comile-warnings
AC_ARG_ENABLE(compile-warnings, [ --enable-compile-warnings=[no/yes] Turn on compiler warnings.], [enable_compile_warnings="$enableval"],[enable_compile_warnings="yes"])
+dnl --enable-debug=(yes|minimum|no)
+AC_ARG_ENABLE(debug, [ --enable-debug=[no/yes] turn on debugging [default=no]],,enable_debug=no)
+if test "$enable_debug" = "yes"; then
+ ORBIT_DEBUG_CFLAGS="-DG_ENABLE_DEBUG"
+else
+ ORBIT_DEBUG_CFLAGS=""
+fi
+AC_SUBST(ORBIT_DEBUG_CFLAGS)
+
dnl Handle indent variations
dnl default is "sopwith indent", use "--enable-indent=kr" for "kr"appy indent.
AC_ARG_ENABLE(indent, [ --disable-indent do not indent output code], use_indent=$enableval, use_indent=yes)
Index: src/orb/Makefile.am
===================================================================
RCS file: /cvs/gnome/ORBit2/src/orb/Makefile.am,v
retrieving revision 1.15
diff -u -r1.15 Makefile.am
--- src/orb/Makefile.am 2001/11/18 19:01:31 1.15
+++ src/orb/Makefile.am 2002/01/04 19:48:25
@@ -10,6 +10,7 @@
-DORBIT_VERSION=\"@ORBIT_VERSION@\" \
-DORBIT2_INTERNAL_API \
$(WARN_CFLAGS) \
+ $(ORBIT_DEBUG_CFLAGS) \
$(ORBIT_CFLAGS)
libORBit_2_la_SOURCES=orbit-init.c orbit-init.h
Index: src/orb/GIOP/Makefile.am
===================================================================
RCS file: /cvs/gnome/ORBit2/src/orb/GIOP/Makefile.am,v
retrieving revision 1.11
diff -u -r1.11 Makefile.am
--- src/orb/GIOP/Makefile.am 2001/12/11 17:21:08 1.11
+++ src/orb/GIOP/Makefile.am 2002/01/04 19:48:25
@@ -3,6 +3,7 @@
-I$(top_builddir)/include \
-DORBIT2_INTERNAL_API \
$(WARN_CFLAGS) \
+ $(ORBIT_DEBUG_CFLAGS) \
$(ORBIT_CFLAGS)
noinst_LTLIBRARIES=libGIOP.la
Index: src/orb/dynamic/Makefile.am
===================================================================
RCS file: /cvs/gnome/ORBit2/src/orb/dynamic/Makefile.am,v
retrieving revision 1.13
diff -u -r1.13 Makefile.am
--- src/orb/dynamic/Makefile.am 2001/11/18 19:01:33 1.13
+++ src/orb/dynamic/Makefile.am 2002/01/04 19:48:25
@@ -12,6 +12,7 @@
-I$(top_builddir)/include/orbit/dynamic \
-DORBIT2_INTERNAL_API \
$(WARN_CFLAGS) \
+ $(ORBIT_DEBUG_CFLAGS) \
$(ORBIT_CFLAGS)
DYNAMIC_IDLOUT=dynamic-defs-common.c
Index: src/orb/orb-core/Makefile.am
===================================================================
RCS file: /cvs/gnome/ORBit2/src/orb/orb-core/Makefile.am,v
retrieving revision 1.41
diff -u -r1.41 Makefile.am
--- src/orb/orb-core/Makefile.am 2001/11/18 19:01:33 1.41
+++ src/orb/orb-core/Makefile.am 2002/01/04 19:48:25
@@ -11,6 +11,7 @@
-DORBIT_TYPELIB_DIR=\""$(TYPELIB_DIR)"\" \
-DORBIT2_INTERNAL_API \
$(WARN_CFLAGS) \
+ $(ORBIT_DEBUG_CFLAGS) \
$(ORBIT_CFLAGS)
main_src = \
Index: src/orb/orb-core/corba-object.c
===================================================================
RCS file: /cvs/gnome/ORBit2/src/orb/orb-core/corba-object.c,v
retrieving revision 1.74
diff -u -r1.74 corba-object.c
--- src/orb/orb-core/corba-object.c 2002/01/03 17:50:34 1.74
+++ src/orb/orb-core/corba-object.c 2002/01/04 19:48:25
@@ -139,16 +139,17 @@
retval = ORBit_lookup_objref (&fakeme);
-#ifdef OBJECT_DEBUG
- g_warning ("Lookup '%s' (%p) == %p", type_id, profiles, retval);
- {
+#ifdef G_ENABLE_DEBUG
+ if (_orbit_debug_flags & ORBIT_DEBUG_OBJECTS) {
GSList *l;
+ g_warning ("Lookup '%s' (%p) == %p", type_id, profiles, retval);
+
g_print ("Profiles: ");
for (l = profiles; l; l = l->next)
g_print ("%s", IOP_profile_dump (&fakeme, l->data));
g_print ("\n");
}
-#endif
+#endif /* G_ENABLE_DEBUG */
if (!retval) {
retval = ORBit_objref_new (orb, fakeme.type_qid);
@@ -260,10 +261,9 @@
if (ORBit_try_connection (obj)) {
obj->object_key = objkey;
obj->connection->orb_data = obj->orb;
-#ifdef OBJECT_DEBUG
- fprintf (stderr, "Initiated a connection to '%s' '%s' '%s'\n",
- proto, host, service);
-#endif
+ ORBIT_NOTE (OBJECTS,
+ fprintf (stderr, "Initiated a connection to '%s' '%s' '%s'\n",
+ proto, host, service));
return obj->connection;
}
}
@@ -428,14 +428,11 @@
num_profiles = 0;
giop_send_buffer_append_aligned (buf, &num_profiles, 4);
-#ifdef OBJECT_DEBUG
- fprintf (stderr, "Marshal object '%p'\n", obj);
-#endif
+ ORBIT_NOTE (OBJECTS, fprintf (stderr, "Marshal object '%p'\n", obj));
+
if (obj)
for (cur = obj->profile_list; cur; cur = cur->next) {
-#ifdef OBJECT_DEBUG
- fprintf (stderr, "%s\n", IOP_profile_dump (obj, cur->data));
-#endif
+ ORBIT_NOTE (OBJECTS, fprintf (stderr, "%s\n", IOP_profile_dump (obj, cur->data)));
IOP_profile_marshal (obj, buf, cur->data);
}
}
Index: src/orb/orb-core/corba-orb.c
===================================================================
RCS file: /cvs/gnome/ORBit2/src/orb/orb-core/corba-orb.c,v
retrieving revision 1.49
diff -u -r1.49 corba-orb.c
--- src/orb/orb-core/corba-orb.c 2001/12/18 12:09:50 1.49
+++ src/orb/orb-core/corba-orb.c 2002/01/04 19:48:25
@@ -12,9 +12,12 @@
#include "iop-profiles.h"
#include "orb-core-private.h"
#include "orbhttp.h"
+#include "orbit-debug.h"
extern ORBit_option orbit_supported_options[];
+OrbitDebugFlags _orbit_debug_flags = ORBIT_DEBUG_NONE;
+
/*
* Command line option handling.
*/
@@ -114,6 +117,7 @@
CORBA_Environment *ev)
{
CORBA_ORB retval;
+ const char *env_string;
static ORBit_RootObject_Interface orb_if = {
ORBIT_ROT_ORB,
CORBA_ORB_release_fn
@@ -126,6 +130,22 @@
g_assert (ORBIT_ALIGNOF_CORBA_DOUBLE > 2);
ORBit_option_parse (argc, argv, orbit_supported_options);
+
+ env_string = g_getenv ("ORBIT_DEBUG");
+ if (env_string != NULL) {
+ static GDebugKey debug_keys[] = {
+ { "traces", ORBIT_DEBUG_TRACES },
+ { "timings", ORBIT_DEBUG_TIMINGS },
+ { "types", ORBIT_DEBUG_TYPES },
+ { "messages", ORBIT_DEBUG_MESSAGES },
+ { "objects", ORBIT_DEBUG_OBJECTS },
+ };
+
+ _orbit_debug_flags |=
+ g_parse_debug_string (env_string,
+ debug_keys,
+ G_N_ELEMENTS (debug_keys));
+ }
giop_init ();
Index: src/orb/orb-core/orbit-debug.h
===================================================================
RCS file: /cvs/gnome/ORBit2/src/orb/orb-core/orbit-debug.h,v
retrieving revision 1.8
diff -u -r1.8 orbit-debug.h
--- src/orb/orb-core/orbit-debug.h 2002/01/03 17:50:34 1.8
+++ src/orb/orb-core/orbit-debug.h 2002/01/04 19:48:25
@@ -1,73 +1,31 @@
#ifndef __ORBIT_DEBUG_H__
#define __ORBIT_DEBUG_H__
-/*
- * Flip this switch to dump
- * general debug messages.
+/*
+ * we may want a generic messages, for things like dprintf. for now,
+ * just use the mask for those
*/
-#undef DEBUG
+typedef enum {
+ ORBIT_DEBUG_NONE = 0,
+ ORBIT_DEBUG_TRACES = 1 << 0,
+ ORBIT_DEBUG_TIMINGS = 1 << 1,
+ ORBIT_DEBUG_TYPES = 1 << 2,
+ ORBIT_DEBUG_MESSAGES = 1 << 3,
+ ORBIT_DEBUG_OBJECTS = 1 << 4,
+ ORBIT_DEBUG_MASK = 0x1f
+} OrbitDebugFlags;
-/*
- * Flip this switch to get a nice trace
- * of method invocations.
- */
-#undef TRACE_DEBUG
-
-/*
- * Define this to get microsecond time stamps on
- * each method invocation, a-la strace -ttt
- */
-#undef TRACE_TIMING
-
-/*
- * Flip this switch if you want tyeplib
- * related warnings.
- */
-#undef TYPE_DEBUG
-
-/*
- * Define this one to get object profile hashing
- * and other object related debug.
- */
-#undef OBJECT_DEBUG
+extern OrbitDebugFlags _orbit_debug_flags;
+#ifdef G_ENABLE_DEBUG
-#ifndef DEBUG
-
-static inline void dprintf (const char *format, ...) { };
-#define dump_arg(a,b)
-
-#else /* DEBUG */
-
#include <stdio.h>
-
-#define dprintf(...) fprintf(stderr, __VA_ARGS__)
-
-static inline void
-dump_arg (const ORBit_IArg *a, CORBA_TypeCode tc)
-{
- fprintf (stderr, " '%s' : kind - %d, %c%c",
- a->name, tc->kind,
- a->flags & (ORBit_I_ARG_IN | ORBit_I_ARG_INOUT) ? 'i' : ' ',
- a->flags & (ORBit_I_ARG_OUT | ORBit_I_ARG_INOUT) ? 'o' : ' ');
-}
-
-#endif /* DEBUG */
+#define ORBIT_NOTE(type, action) G_STMT_START { \
+ if (_orbit_debug_flags & ORBIT_DEBUG_##type) \
+ { action; }; } G_STMT_END
-
-#ifndef TRACE_DEBUG
-
-static inline void tprintf (const char *format, ...) { };
-#define tprintf_trace_value(a,b)
-#define tprintf_header(obj,md)
-#define tprintf_timestamp()
-#define tprintf_end_method()
-
-#else /* TRACE_DEBUG */
-
-#include <stdio.h>
-
+/* tracing debug */
void ORBit_trace_objref (const CORBA_Object obj);
void ORBit_trace_any (const CORBA_any *any);
void ORBit_trace_typecode (const CORBA_TypeCode tc);
@@ -76,24 +34,30 @@
void ORBit_trace_header (CORBA_Object object,
ORBit_IMethod *m_data);
void ORBit_trace_end_method (void);
+
+/* timing debug */
+void ORBit_trace_timestamp (void);
+
void ORBit_trace_profiles (CORBA_Object obj);
-#define tprintf(...) fprintf(stderr, __VA_ARGS__)
-#define tprintf_header(obj,md) ORBit_trace_header(obj,md)
-#define tprintf_trace_value(a,b) \
- ORBit_trace_value ((gconstpointer *)(a), (b))
-#define tprintf_end_method() \
- ORBit_trace_end_method ()
+#else /* !G_ENABLE_DEBUG */
+#define ORBIT_NOTE(type, action)
-#ifdef TRACE_TIMING
-# define tprintf_timestamp() \
- ORBit_trace_timestamp ()
-void ORBit_trace_timestamp (void);
-#else
-# define tprintf_timestamp()
-#endif
+#endif /* G_ENABLE_DEBUG */
+
+#define dprintf(...) ORBIT_NOTE(MESSAGES, fprintf(stderr, __VA_ARGS__))
+
+#define dump_arg(a, tc) ORBIT_NOTE(MESSAGES, \
+ fprintf (stderr, " '%s' : kind - %d, %c%c", \
+ a->name, tc->kind, \
+ a->flags & (ORBit_I_ARG_IN | ORBit_I_ARG_INOUT) ? 'i' : ' ', \
+ a->flags & (ORBit_I_ARG_OUT | ORBit_I_ARG_INOUT) ? 'o' : ' '))
-#endif /* TRACE_DEBUG */
+#define tprintf(...) ORBIT_NOTE(TRACES, fprintf(stderr, __VA_ARGS__))
+#define tprintf_header(obj,md) ORBIT_NOTE(TRACES, ORBit_trace_header(obj,md))
+#define tprintf_trace_value(a,b) ORBIT_NOTE(TRACES, ORBit_trace_value ((gconstpointer *)(a), (b)))
+#define tprintf_end_method() ORBIT_NOTE(TRACES, ORBit_trace_end_method ())
+#define tprintf_timestamp() ORBIT_NOTE(TIMINGS, ORBit_trace_timestamp ())
#endif /* __ORBIT_DEBUG_H__ */
Index: src/orb/orb-core/orbit-small.c
===================================================================
RCS file: /cvs/gnome/ORBit2/src/orb/orb-core/orbit-small.c,v
retrieving revision 1.57
diff -u -r1.57 orbit-small.c
--- src/orb/orb-core/orbit-small.c 2002/01/03 14:28:46 1.57
+++ src/orb/orb-core/orbit-small.c 2002/01/04 19:48:25
@@ -533,14 +533,16 @@
recv_buffer, ev, &m_data->exceptions, obj->orb);
giop_recv_buffer_unuse (recv_buffer);
-#ifdef TRACE_DEBUG
- if (ev->_major == CORBA_SYSTEM_EXCEPTION)
- tprintf (" System Exception: '%s' ", ev->_id);
- else {
- tprintf (" User Exception: '%s' ", ev->_id);
- ORBit_trace_any (&ev->_any);
+#ifdef G_ENABLE_DEBUG
+ if (_orbit_debug_flags & ORBIT_DEBUG_TRACES) {
+ if (ev->_major == CORBA_SYSTEM_EXCEPTION)
+ tprintf (" System Exception: '%s' ", ev->_id);
+ else {
+ tprintf (" User Exception: '%s' ", ev->_id);
+ ORBit_trace_any (&ev->_any);
+ }
}
-#endif
+#endif /* G_ENABLE_DEBUG */
return MARSHAL_EXCEPTION_COMPLETE;
}
Index: src/orb/orb-core/orbit-trace.c
===================================================================
RCS file: /cvs/gnome/ORBit2/src/orb/orb-core/orbit-trace.c,v
retrieving revision 1.14
diff -u -r1.14 orbit-trace.c
--- src/orb/orb-core/orbit-trace.c 2002/01/03 17:50:34 1.14
+++ src/orb/orb-core/orbit-trace.c 2002/01/04 19:48:25
@@ -5,12 +5,10 @@
#include "orb-core-private.h"
#include "orbit-debug.h"
-#ifdef TRACE_DEBUG
+#ifdef G_ENABLE_DEBUG
# include <unistd.h>
-#endif
-
-#ifdef TRACE_TIMING
# include <sys/time.h>
+# include <ctype.h>
#endif
/*
@@ -20,7 +18,7 @@
#undef DEBUG_TRACE
-#ifdef TRACE_DEBUG
+#ifdef G_ENABLE_DEBUG
#define NOT_NULL(str) ((str) == NULL ? "(null)" : (str))
void
@@ -60,12 +58,11 @@
CORBA_unsigned_long i;
gconstpointer subval;
-#ifdef DEBUG_TRACE
+ ORBIT_NOTE (MESSAGES,
fprintf (stderr, "\ntrace '%s' %p align %d, (size %d)\n",
NOT_NULL (TC_CORBA_TCKind->subnames [tc->kind]), *val,
tc->c_align,
- ORBit_gather_alloc_info (tc));
-#endif
+ ORBit_gather_alloc_info (tc)));
*val = ALIGN_ADDRESS (*val, tc->c_align);
@@ -211,7 +208,6 @@
*val = ((guchar *)*val) + ORBit_gather_alloc_info (tc);
}
-#ifdef TRACE_TIMING
void
ORBit_trace_timestamp (void)
{
@@ -220,7 +216,6 @@
gettimeofday (&t, NULL);
tprintf ("%lu.%lu ", t.tv_sec, t.tv_usec);
}
-#endif
void
ORBit_trace_header (CORBA_Object object,
@@ -261,6 +256,5 @@
}
tprintf ("\n");
}
-
-#endif /* TRACE_DEBUG */
+#endif /* G_ENABLE_DEBUG */
Index: src/orb/orb-core/orbit-typelib.c
===================================================================
RCS file: /cvs/gnome/ORBit2/src/orb/orb-core/orbit-typelib.c,v
retrieving revision 1.6
diff -u -r1.6 orbit-typelib.c
--- src/orb/orb-core/orbit-typelib.c 2001/10/25 02:00:41 1.6
+++ src/orb/orb-core/orbit-typelib.c 2002/01/04 19:48:25
@@ -246,10 +246,9 @@
ORBit_IModule *module;
if (!(handle = g_module_open (fname, G_MODULE_BIND_LAZY))) {
-#ifdef TYPE_DEBUG
- g_warning ("Failed to load '%s': '%s'", fname,
- g_module_error ());
-#endif
+ ORBIT_NOTE (TYPES,
+ g_warning ("Failed to load '%s': '%s'", fname,
+ g_module_error ()));
return FALSE;
}
@@ -265,10 +264,9 @@
ORBit_IInterface **p;
gulong length, i;
-#ifdef TYPE_DEBUG
- g_warning ("Loaded interfaces of serial %d from '%s'",
- module->version, fname);
-#endif
+ ORBIT_NOTE (TYPES,
+ g_warning ("Loaded interfaces of serial %d from '%s'",
+ module->version, fname));
for (p = module->interfaces, length = 0; p && *p; p++)
length++;
@@ -290,9 +288,8 @@
dest = &iinterfaces->_buffer [i];
add_iinterface (dest);
-#ifdef TYPE_DEBUG
- g_warning ("Type '%s'", dest->tc->repo_id);
-#endif
+ ORBIT_NOTE (TYPES,
+ g_warning ("Type '%s'", dest->tc->repo_id));
}
types = ORBit_copy_value (
Index: src/orb/poa/Makefile.am
===================================================================
RCS file: /cvs/gnome/ORBit2/src/orb/poa/Makefile.am,v
retrieving revision 1.23
diff -u -r1.23 Makefile.am
--- src/orb/poa/Makefile.am 2001/11/25 23:10:00 1.23
+++ src/orb/poa/Makefile.am 2002/01/04 19:48:25
@@ -13,6 +13,7 @@
-I$(top_srcdir)/src/orb/poa \
-DORBIT2_INTERNAL_API \
$(WARN_CFLAGS) \
+ $(ORBIT_DEBUG_CFLAGS) \
$(ORBIT_CFLAGS)
POA_IDLOUT=poa-defs-common.c
Index: src/orb/util/Makefile.am
===================================================================
RCS file: /cvs/gnome/ORBit2/src/orb/util/Makefile.am,v
retrieving revision 1.12
diff -u -r1.12 Makefile.am
--- src/orb/util/Makefile.am 2001/11/18 19:01:35 1.12
+++ src/orb/util/Makefile.am 2002/01/04 19:48:25
@@ -6,6 +6,7 @@
-DORBIT_SYSTEM_RCFILE=\"$(sysconfdir)/orbitrc\" \
-DORBIT2_INTERNAL_API \
$(WARN_CFLAGS) \
+ $(ORBIT_DEBUG_CFLAGS) \
$(ORBIT_CFLAGS)
liborb_util_la_SOURCES= \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]