]> Pileus Git - ~andy/gtk/commitdiff
the value of ---enable_debug is written into glibconfig.h so everything is
authorOwen Taylor <owt1@cornell.edu>
Thu, 19 Feb 1998 18:02:03 +0000 (18:02 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Thu, 19 Feb 1998 18:02:03 +0000 (18:02 +0000)
Thu Feb 19 12:18:24 1998  Owen Taylor  <owt1@cornell.edu>

* glib/configure.in glib/glibconfig.h.in: the value of
---enable_debug is written into glibconfig.h so everything
is recompiled when it changes. (HACK)

* gtk/gtkmain.c gdk/gdk.c docs/debugging.txt:
Added --gdk-no-debug and --gtk-no-debug switches. Effect
of switches is no cumulative.

docs/debugging.txt
gdk/gdk.c
gdk/x11/gdkmain-x11.c
glib/acconfig.h
glib/configure.in
glib/glibconfig.h.in
gtk/gtkmain.c

index 1313fcc061c36e019e7c334c2115658043cf15fd..68905895c265664174ba68a10e265699faf90f4f 100644 (file)
@@ -42,20 +42,31 @@ time by the --enable-debug option.
 RUN TIME OPTIONS
 ----------------
 
-At run time, if GTK+ was compiled with debugging enabled, 
-different types of debugging information can be printed
-out by setting the --gtk-debug and --gdk-debug command line
-options, or the GTK_DEBUG and GDK_DEBUG environment 
-variables. (The command line options override the environment
-variables)
+At run time, if GTK+ was compiled with debugging enabled, different
+types of debugging information can be printed out. This is controlled
+by the:
+  GTK_DEBUG and GDK_DEBUG environment variables
+  --gtk-debug and --gdk-debug command line options
+  --gtk-no-debug and --gdk-no-debug command line options
 
-Each of these can either be the special value ALL,
-or a sequence of ':' separated options. (Note, case is
-significant)
+First the environment variables are applied, then the command line
+options are applied in the order given on the command line.
 
-As noted below, some of these are useful in application
-debugging, but most are only interested to those debugging
-the libraries
+Each of these can either be the special value ALL, or a sequence of
+':' separated options. (Note, case is significant). The environment
+variables and the --gtk-debug and --gdk-debug options add debugging
+options and the --gtk-no-debug and --gdk-no-debug options remove
+them.
+
+As noted below, some of these are useful in application debugging, but
+most are only interested to those debugging the libraries
+
+For instance:
+
+  GDK_DEBUG_FLAGS=misc:dnd testgtk --gdk-no-debug dnd --gdk-debug events
+
+runs testgtk with the 'misc' and 'events' debugging options.
 
  GTK_DEBUG
  ---------
@@ -81,3 +92,7 @@ the libraries
  'color-context' - Information about the internal workings of 
                    GdkColorContext
  'xim'           - Information about X Input Method support
+
+
+                                    - Owen Taylor <owt1@cornell.edu>
+                                      98/02/19
\ No newline at end of file
index af38b2fcc20c10527b79c918fc737f73bcd632f0..9f0d9bdb40c843d8e8cb894507d1fa4115d5fca4 100644 (file)
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -233,6 +233,9 @@ static GDebugKey gdk_debug_keys[] = {
   {"color-context", GDK_DEBUG_COLOR_CONTEXT},
   {"xim",           GDK_DEBUG_XIM}
 };
+
+static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey);
+
 #endif /* G_ENABLE_DEBUG */
 
 /*
@@ -267,10 +270,6 @@ gdk_init (int    *argc,
   int argc_orig = *argc;
   char **argv_orig;
 
-#ifdef G_ENABLE_DEBUG
-  gboolean debug_set = FALSE;
-#endif /* G_ENABLE_DEBUG */
-
   argv_orig = malloc ((argc_orig + 1) * sizeof (char*));
   for (i = 0; i < argc_orig; i++)
     argv_orig[i] = g_strdup ((*argv)[i]);
@@ -295,6 +294,16 @@ gdk_init (int    *argc,
 
   synchronize = FALSE;
 
+#ifdef G_ENABLE_DEBUG
+  {
+    gchar *debug_string = getenv("GDK_DEBUG");
+    if (debug_string != NULL)
+      gdk_debug_flags = g_parse_debug_string (debug_string,
+                                             gdk_debug_keys,
+                                             gdk_ndebug_keys);
+  }
+#endif /* G_ENABLE_DEBUG */
+
   if (argc && argv)
     {
       if (*argc > 0)
@@ -303,7 +312,10 @@ gdk_init (int    *argc,
       for (i = 1; i < *argc;)
        {
          if ((*argv)[i] == NULL)
-           continue;
+           {
+             i += 1;
+             continue;
+           }
          
 #ifdef G_ENABLE_DEBUG    
          if (strcmp ("--gdk-debug", (*argv)[i]) == 0)
@@ -312,15 +324,27 @@ gdk_init (int    *argc,
 
              if ((i + 1) < *argc && (*argv)[i + 1])
                {
-                 gdk_debug_flags = g_parse_debug_string ((*argv)[i+1],
-                                                         gdk_debug_keys,
-                                 sizeof(gdk_debug_keys) / sizeof(GDebugKey));
-                 debug_set = TRUE;
+                 gdk_debug_flags |= g_parse_debug_string ((*argv)[i+1],
+                                                          gdk_debug_keys,
+                                                          gdk_ndebug_keys);
+                 (*argv)[i + 1] = NULL;
+                 i += 1;
+               }
+           }
+         else if (strcmp ("--gdk-no-debug", (*argv)[i]) == 0)
+           {
+             (*argv)[i] = NULL;
+
+             if ((i + 1) < *argc && (*argv)[i + 1])
+               {
+                 gdk_debug_flags &= ~g_parse_debug_string ((*argv)[i+1],
+                                                           gdk_debug_keys,
+                                                           gdk_ndebug_keys);
                  (*argv)[i + 1] = NULL;
                  i += 1;
                }
            }
-#endif G_ENABLE_DEBUG
+#endif /* G_ENABLE_DEBUG */
          else if (strcmp ("--display", (*argv)[i]) == 0)
            {
              (*argv)[i] = NULL;
@@ -438,17 +462,6 @@ gdk_init (int    *argc,
       gdk_progname = "<unknown>";
     }
 
-#ifdef G_ENABLE_DEBUG
-  if (!debug_set)
-    {
-      gchar *debug_string = getenv("GDK_DEBUG");
-      if (debug_string != NULL)
-       gdk_debug_flags = g_parse_debug_string (debug_string,
-                                               gdk_debug_keys,
-                               sizeof(gdk_debug_keys) / sizeof(GDebugKey));
-    }
-#endif /* G_ENABLE_DEBUG */
-
   gdk_display = XOpenDisplay (gdk_display_name);
   if (!gdk_display)
     {
@@ -2180,12 +2193,14 @@ gdk_event_translate (GdkEvent *event,
          break;
        }
 
+#ifdef G_ENABLE_DEBUG
         if ((gdk_debug_flags & GDK_DEBUG_DND) & dnd_drag_perhaps)
          {
            g_print("We may[%d] have a drag into %#lx = %#lx\n",
                    gdk_dnd.drag_really,
                    xevent->xcrossing.window, real_sw->xwindow);
          }
+#endif /* G_ENABLE_DEBUG */
 
        if (dnd_drag_perhaps && gdk_dnd.drag_really && 
            (xevent->xcrossing.window == real_sw->xwindow))
@@ -2247,12 +2262,14 @@ gdk_event_translate (GdkEvent *event,
          event->crossing.detail = GDK_NOTIFY_UNKNOWN;
          break;
        }
+#ifdef G_ENABLE_DEBUG
       if ((gdk_debug_flags & GDK_DEBUG_DND) & dnd_drag_perhaps)
        {
          g_print("We may[%d] have a drag out of %#lx = %#lx\n",
                  gdk_dnd.drag_really,
                  xevent->xcrossing.window, real_sw->xwindow);
        }
+#endif /* G_ENABLE_DEBUG */
       if (dnd_drag_perhaps && !gdk_dnd.drag_really &&
          (xevent->xcrossing.window == real_sw->xwindow))
        {
@@ -2361,6 +2378,7 @@ gdk_event_translate (GdkEvent *event,
     case VisibilityNotify:
       /* Print debugging info.
        */
+#ifdef G_ENABLE_DEBUG
       if (gdk_debug_flags & GDK_DEBUG_EVENTS)
        switch (xevent->xvisibility.state)
          {
@@ -2377,6 +2395,7 @@ gdk_event_translate (GdkEvent *event,
                     xevent->xvisibility.window - base_id);
            break;
          }
+#endif /* G_ENABLE_DEBUG */
 
       event->visibility.type = GDK_VISIBILITY_NOTIFY;
       event->visibility.window = window;
@@ -3552,10 +3571,12 @@ gdk_ic_cleanup (void)
          destroyed++;
        }
     }
+#ifdef G_ENABLE_DEBUG
   if ((gdk_debug_flags & GDK_DEBUG_XIM) && destroyed > 0)
     {
       g_warning ("Cleaned up %i IC(s)\n", destroyed);
     }
+#endif /* G_ENABLE_DEBUG */
   g_list_free(xim_ic_list);
   xim_ic_list = NULL;
 }
index af38b2fcc20c10527b79c918fc737f73bcd632f0..9f0d9bdb40c843d8e8cb894507d1fa4115d5fca4 100644 (file)
@@ -233,6 +233,9 @@ static GDebugKey gdk_debug_keys[] = {
   {"color-context", GDK_DEBUG_COLOR_CONTEXT},
   {"xim",           GDK_DEBUG_XIM}
 };
+
+static const int gdk_ndebug_keys = sizeof(gdk_debug_keys)/sizeof(GDebugKey);
+
 #endif /* G_ENABLE_DEBUG */
 
 /*
@@ -267,10 +270,6 @@ gdk_init (int    *argc,
   int argc_orig = *argc;
   char **argv_orig;
 
-#ifdef G_ENABLE_DEBUG
-  gboolean debug_set = FALSE;
-#endif /* G_ENABLE_DEBUG */
-
   argv_orig = malloc ((argc_orig + 1) * sizeof (char*));
   for (i = 0; i < argc_orig; i++)
     argv_orig[i] = g_strdup ((*argv)[i]);
@@ -295,6 +294,16 @@ gdk_init (int    *argc,
 
   synchronize = FALSE;
 
+#ifdef G_ENABLE_DEBUG
+  {
+    gchar *debug_string = getenv("GDK_DEBUG");
+    if (debug_string != NULL)
+      gdk_debug_flags = g_parse_debug_string (debug_string,
+                                             gdk_debug_keys,
+                                             gdk_ndebug_keys);
+  }
+#endif /* G_ENABLE_DEBUG */
+
   if (argc && argv)
     {
       if (*argc > 0)
@@ -303,7 +312,10 @@ gdk_init (int    *argc,
       for (i = 1; i < *argc;)
        {
          if ((*argv)[i] == NULL)
-           continue;
+           {
+             i += 1;
+             continue;
+           }
          
 #ifdef G_ENABLE_DEBUG    
          if (strcmp ("--gdk-debug", (*argv)[i]) == 0)
@@ -312,15 +324,27 @@ gdk_init (int    *argc,
 
              if ((i + 1) < *argc && (*argv)[i + 1])
                {
-                 gdk_debug_flags = g_parse_debug_string ((*argv)[i+1],
-                                                         gdk_debug_keys,
-                                 sizeof(gdk_debug_keys) / sizeof(GDebugKey));
-                 debug_set = TRUE;
+                 gdk_debug_flags |= g_parse_debug_string ((*argv)[i+1],
+                                                          gdk_debug_keys,
+                                                          gdk_ndebug_keys);
+                 (*argv)[i + 1] = NULL;
+                 i += 1;
+               }
+           }
+         else if (strcmp ("--gdk-no-debug", (*argv)[i]) == 0)
+           {
+             (*argv)[i] = NULL;
+
+             if ((i + 1) < *argc && (*argv)[i + 1])
+               {
+                 gdk_debug_flags &= ~g_parse_debug_string ((*argv)[i+1],
+                                                           gdk_debug_keys,
+                                                           gdk_ndebug_keys);
                  (*argv)[i + 1] = NULL;
                  i += 1;
                }
            }
-#endif G_ENABLE_DEBUG
+#endif /* G_ENABLE_DEBUG */
          else if (strcmp ("--display", (*argv)[i]) == 0)
            {
              (*argv)[i] = NULL;
@@ -438,17 +462,6 @@ gdk_init (int    *argc,
       gdk_progname = "<unknown>";
     }
 
-#ifdef G_ENABLE_DEBUG
-  if (!debug_set)
-    {
-      gchar *debug_string = getenv("GDK_DEBUG");
-      if (debug_string != NULL)
-       gdk_debug_flags = g_parse_debug_string (debug_string,
-                                               gdk_debug_keys,
-                               sizeof(gdk_debug_keys) / sizeof(GDebugKey));
-    }
-#endif /* G_ENABLE_DEBUG */
-
   gdk_display = XOpenDisplay (gdk_display_name);
   if (!gdk_display)
     {
@@ -2180,12 +2193,14 @@ gdk_event_translate (GdkEvent *event,
          break;
        }
 
+#ifdef G_ENABLE_DEBUG
         if ((gdk_debug_flags & GDK_DEBUG_DND) & dnd_drag_perhaps)
          {
            g_print("We may[%d] have a drag into %#lx = %#lx\n",
                    gdk_dnd.drag_really,
                    xevent->xcrossing.window, real_sw->xwindow);
          }
+#endif /* G_ENABLE_DEBUG */
 
        if (dnd_drag_perhaps && gdk_dnd.drag_really && 
            (xevent->xcrossing.window == real_sw->xwindow))
@@ -2247,12 +2262,14 @@ gdk_event_translate (GdkEvent *event,
          event->crossing.detail = GDK_NOTIFY_UNKNOWN;
          break;
        }
+#ifdef G_ENABLE_DEBUG
       if ((gdk_debug_flags & GDK_DEBUG_DND) & dnd_drag_perhaps)
        {
          g_print("We may[%d] have a drag out of %#lx = %#lx\n",
                  gdk_dnd.drag_really,
                  xevent->xcrossing.window, real_sw->xwindow);
        }
+#endif /* G_ENABLE_DEBUG */
       if (dnd_drag_perhaps && !gdk_dnd.drag_really &&
          (xevent->xcrossing.window == real_sw->xwindow))
        {
@@ -2361,6 +2378,7 @@ gdk_event_translate (GdkEvent *event,
     case VisibilityNotify:
       /* Print debugging info.
        */
+#ifdef G_ENABLE_DEBUG
       if (gdk_debug_flags & GDK_DEBUG_EVENTS)
        switch (xevent->xvisibility.state)
          {
@@ -2377,6 +2395,7 @@ gdk_event_translate (GdkEvent *event,
                     xevent->xvisibility.window - base_id);
            break;
          }
+#endif /* G_ENABLE_DEBUG */
 
       event->visibility.type = GDK_VISIBILITY_NOTIFY;
       event->visibility.window = window;
@@ -3552,10 +3571,12 @@ gdk_ic_cleanup (void)
          destroyed++;
        }
     }
+#ifdef G_ENABLE_DEBUG
   if ((gdk_debug_flags & GDK_DEBUG_XIM) && destroyed > 0)
     {
       g_warning ("Cleaned up %i IC(s)\n", destroyed);
     }
+#endif /* G_ENABLE_DEBUG */
   g_list_free(xim_ic_list);
   xim_ic_list = NULL;
 }
index 8fb6672b9224636c1dcfe388ecfe1edfa546328f..86edcee2a8bd881b4ba0114cfc2f715147c1611c 100644 (file)
@@ -32,6 +32,7 @@
 \f
 
 /* Other stuff */
+#undef G_COMPILED_WITH_DEBUGGING
 #undef HAVE_BROKEN_WCTYPE
 #undef HAVE_DOPRNT
 #undef HAVE_FLOAT_H
index 7f3815d9112cad4ef552ab6d833b8c74e5be1423..0816180ee518c21c7b453e22e213f28a3105b80b 100644 (file)
@@ -32,6 +32,8 @@ else
   fi
 fi
 
+AC_DEFINE_UNQUOTED(G_COMPILED_WITH_DEBUGGING, "${enable_debug}")
+
 # Checks for programs.
 AC_PROG_CC
 AM_PROG_CC_STDC
index 5fd8a65a0f4ebaa286177a3cf664c3decdb2e243..a8ca74bdc77269cd181fd41ea0bfe39cc8933e66 100644 (file)
@@ -3,6 +3,9 @@
 /* Define to empty if the keyword does not work.  */
 #undef const
 
+/* Force recompilation when --enable-debug value changes */
+#undef G_COMPILED_WITH_DEBUGGING
+
 /* Define if you don't have vprintf but do have _doprnt.  */
 #undef HAVE_DOPRNT
 
index 90ce42cc0aa2e270b9b18097f3c5bb231a318666..3e1cd8c43e9ac9d5b91faa2749d623fbf62c7bd1 100644 (file)
@@ -141,22 +141,24 @@ static GdkColormap *gtk_colormap;    /* The colormap to be used in creating new
                                            *  widgets.
                                            */
 
-guint gtk_debug_flags;         /* Global GTK debug flag */
+guint gtk_debug_flags = 0;                /* Global GTK debug flag */
 
 #ifdef G_ENABLE_DEBUG
 static GDebugKey gtk_debug_keys[] = {
   {"objects", GTK_DEBUG_OBJECTS}
 };
+
+static const int gtk_ndebug_keys = sizeof(gtk_debug_keys)/sizeof(GDebugKey);
+
 #endif /* G_ENABLE_DEBUG */
 
+
+
+
 void
 gtk_init (int   *argc,
          char ***argv)
 {
-#ifdef G_ENABLE_DEBUG
-  gboolean debug_set = FALSE;
-#endif
-
   if (0)
     {
       g_set_error_handler (gtk_error);
@@ -171,22 +173,48 @@ gtk_init (int      *argc,
   gdk_init (argc, argv);
   
 #ifdef G_ENABLE_DEBUG
+  {
+    gchar *debug_string = getenv("GTK_DEBUG");
+    if (debug_string != NULL)
+      gtk_debug_flags = g_parse_debug_string (debug_string,
+                                             gtk_debug_keys,
+                                             gtk_ndebug_keys);
+  }
+
   if (argc && argv)
     {
       gint i;
       
       for (i = 1; i < *argc;)
        {
-         if ((*argv[i]) && strcmp ("--gtk-debug", (*argv)[i]) == 0)
+         if ((*argv)[i] == NULL)
+           {
+             i += 1;
+             continue;
+           }
+
+         if (strcmp ("--gtk-debug", (*argv)[i]) == 0)
            {
              (*argv)[i] = NULL;
 
              if ((i + 1) < *argc && (*argv)[i + 1])
                {
-                 gtk_debug_flags = g_parse_debug_string ((*argv)[i+1],
-                                                         gtk_debug_keys,
-                                 sizeof(gtk_debug_keys) / sizeof(GDebugKey));
-                 debug_set = TRUE;
+                 gtk_debug_flags |= g_parse_debug_string ((*argv)[i+1],
+                                                          gtk_debug_keys,
+                                                          gtk_ndebug_keys);
+                 (*argv)[i + 1] = NULL;
+                 i += 1;
+               }
+           }
+         else if (strcmp ("--gtk-no-debug", (*argv)[i]) == 0)
+           {
+             (*argv)[i] = NULL;
+
+             if ((i + 1) < *argc && (*argv)[i + 1])
+               {
+                 gtk_debug_flags &= ~g_parse_debug_string ((*argv)[i+1],
+                                                           gtk_debug_keys,
+                                                           gtk_ndebug_keys);
                  (*argv)[i + 1] = NULL;
                  i += 1;
                }
@@ -195,14 +223,6 @@ gtk_init (int       *argc,
        }
     }
 
-  if (!debug_set)
-    {
-      gchar *debug_string = getenv("GTK_DEBUG");
-      if (debug_string != NULL)
-       gtk_debug_flags = g_parse_debug_string (debug_string,
-                                               gtk_debug_keys,
-                               sizeof(gtk_debug_keys) / sizeof(GDebugKey));
-    }
 #endif /* G_ENABLE_DEBUG */
 
   /* Initialize the default visual and colormap to be