summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-11-15 13:37:44 +0000
committerMatthias Clasen <mclasen@redhat.com>2020-11-15 13:37:44 +0000
commitb8d0ad8643de059688a72efe716e1043f9e539a2 (patch)
treed35d54f12a1528350723159127286c6e8acf11d5
parent65d57877a8aa2ef28a36a14c1c73692bf37c0a78 (diff)
parentafc73c38ce451f9bd1ae4d918230d1487ba9ae20 (diff)
downloadgtk+-b8d0ad8643de059688a72efe716e1043f9e539a2.tar.gz
Merge branch 'parse-debug-env-vars-always' into 'master'
Always parse GTK/GDK/GSK_DEBUG env vars and make some entries available in non-debug mode See merge request GNOME/gtk!2830
-rw-r--r--docs/reference/gtk/running.md19
-rw-r--r--gdk/gdk-private.h1
-rw-r--r--gdk/gdk.c43
-rw-r--r--gsk/gskdebug.c4
-rw-r--r--gtk/gtkmain.c9
5 files changed, 39 insertions, 37 deletions
diff --git a/docs/reference/gtk/running.md b/docs/reference/gtk/running.md
index 2b338bd148..d294f8fc82 100644
--- a/docs/reference/gtk/running.md
+++ b/docs/reference/gtk/running.md
@@ -11,9 +11,9 @@ environment variables.
### GTK_DEBUG {#GTK_Debug-Options}
-Unless GTK has been configured with `-Ddebug=false`, this variable
-can be set to a list of debug options, which cause GTK to print out
-different types of debugging information.
+This variable can be set to a list of debug options, which cause GTK to
+print out different types of debugging information. Some of these options
+are only available when GTK has been configured with `-Ddebug=true`.
actions
: Actions and menu models
@@ -141,9 +141,9 @@ The `loaders.cache` file is generated by the
### GDK_DEBUG
-Unless GTK has been configured with `-Ddebug=false`, this variable
-can be set to a list of debug options, which cause GDK to print out
-different types of debugging information.
+This variable can be set to a list of debug options, which cause GDK to
+print out different types of debugging information. Some of these options
+are only available when GTK has been configured with `-Ddebug=true`.
cursor
: Information about cursor objects (only win32)
@@ -191,10 +191,9 @@ to obtain a list of all supported debug options.
### GSK_DEBUG {#GSK-Debug-Options}
-Unless GTK has been configured with `-Ddebug=false`,
-this variable can be set to a list of debug options,
-which cause GSK to print out different types of debugging
-information.
+This variable can be set to a list of debug options, which cause GSK to
+print out different types of debugging information. Some of these options
+are only available when GTK has been configured with `-Ddebug=true`.
renderer
: General renderer information
diff --git a/gdk/gdk-private.h b/gdk/gdk-private.h
index fb058c0f39..d2d185d57e 100644
--- a/gdk/gdk-private.h
+++ b/gdk/gdk-private.h
@@ -45,6 +45,7 @@ typedef struct
const char *key;
guint value;
const char *help;
+ gboolean always_enabled;
} GdkDebugKey;
guint gdk_parse_debug_var (const char *variable,
diff --git a/gdk/gdk.c b/gdk/gdk.c
index 874e993892..953079cdd5 100644
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -128,7 +128,6 @@ static int gdk_initialized = 0; /* 1 if the library is initi
* 0 otherwise.
*/
-#ifdef G_ENABLE_DEBUG
static const GdkDebugKey gdk_debug_keys[] = {
{ "misc", GDK_DEBUG_MISC, "Miscellaneous information" },
{ "events", GDK_DEBUG_EVENTS, "Information about events" },
@@ -152,7 +151,6 @@ static const GdkDebugKey gdk_debug_keys[] = {
{ "vulkan-validate", GDK_DEBUG_VULKAN_VALIDATE, "Load the Vulkan validation layer" },
{ "default-settings",GDK_DEBUG_DEFAULT_SETTINGS, "Force default values for xsettings" },
};
-#endif
#ifdef G_HAS_CONSTRUCTORS
@@ -212,6 +210,13 @@ gdk_parse_debug_var (const char *variable,
const char *q;
gboolean invert;
gboolean help;
+ gboolean debug_enabled;
+
+#ifdef G_ENABLE_DEBUG
+ debug_enabled = TRUE;
+#else
+ debug_enabled = FALSE;
+#endif
string = g_getenv (variable);
if (string == NULL)
@@ -237,21 +242,25 @@ gdk_parse_debug_var (const char *variable,
}
else
{
+ char *val = g_strndup (p, q - p);
for (i = 0; i < nkeys; i++)
{
if (strlen (keys[i].key) == q - p &&
g_ascii_strncasecmp (keys[i].key, p, q - p) == 0)
{
+ if (!debug_enabled && !keys[i].always_enabled)
+ {
+ fprintf (stderr, "\"%s\" is only available when building GTK with G_ENABLE_DEBUG. See %s=help\n",
+ val, variable);
+ break;
+ }
result |= keys[i].value;
break;
}
}
if (i == nkeys)
- {
- char *val = g_strndup (p, q - p);
- fprintf (stderr, "Unrecognized value \"%s\". Try %s=help\n", val, variable);
- g_free (val);
- }
+ fprintf (stderr, "Unrecognized value \"%s\". Try %s=help\n", val, variable);
+ g_free (val);
}
p = q;
@@ -267,11 +276,17 @@ gdk_parse_debug_var (const char *variable,
max_width += 4;
fprintf (stderr, "Supported %s values:\n", variable);
- for (i = 0; i < nkeys; i++)
- fprintf (stderr, " %s%*s%s\n", keys[i].key, (int)(max_width - strlen (keys[i].key)), " ", keys[i].help);
+ for (i = 0; i < nkeys; i++) {
+ fprintf (stderr, " %s%*s%s", keys[i].key, (int)(max_width - strlen (keys[i].key)), " ", keys[i].help);
+ if (!debug_enabled && !keys[i].always_enabled)
+ fprintf (stderr, " [unavailable]");
+ fprintf (stderr, "\n");
+ }
fprintf (stderr, " %s%*s%s\n", "all", max_width - 3, " ", "Enable all values");
fprintf (stderr, " %s%*s%s\n", "help", max_width - 4, " ", "Print this help");
fprintf (stderr, "\nMultiple values can be given, separated by : or space.\n");
+ if (!debug_enabled)
+ fprintf (stderr, "Values marked as [unavailable] are only accessible if GTK is built with G_ENABLE_DEBUG.\n");
}
if (invert)
@@ -279,7 +294,10 @@ gdk_parse_debug_var (const char *variable,
guint all_flags = 0;
for (i = 0; i < nkeys; i++)
- all_flags |= keys[i].value;
+ {
+ if (debug_enabled || keys[i].always_enabled)
+ all_flags |= keys[i].value;
+ }
result = all_flags & (~result);
}
@@ -294,14 +312,9 @@ gdk_pre_parse (void)
gdk_ensure_resources ();
-#ifdef G_ENABLE_DEBUG
_gdk_debug_flags = gdk_parse_debug_var ("GDK_DEBUG",
gdk_debug_keys,
G_N_ELEMENTS (gdk_debug_keys));
-#else
- if (g_getenv ("GDK_DEBUG"))
- g_warning ("GDK_DEBUG set but ignored because GTK isn't built with G_ENABLE_DEBUG");
-#endif /* G_ENABLE_DEBUG */
#ifndef G_HAS_CONSTRUCTORS
stash_desktop_startup_notification_id ();
diff --git a/gsk/gskdebug.c b/gsk/gskdebug.c
index 3538cec0e5..4e197257ef 100644
--- a/gsk/gskdebug.c
+++ b/gsk/gskdebug.c
@@ -1,7 +1,6 @@
#include "gskdebugprivate.h"
#include "gdk/gdk-private.h"
-#ifdef G_ENABLE_DEBUG
static const GdkDebugKey gsk_debug_keys[] = {
{ "renderer", GSK_DEBUG_RENDERER, "General renderer information" },
{ "cairo", GSK_DEBUG_CAIRO, "Cairo renderer information" },
@@ -17,14 +16,12 @@ static const GdkDebugKey gsk_debug_keys[] = {
{ "vulkan-staging-image", GSK_DEBUG_VULKAN_STAGING_IMAGE, "Use a staging image for Vulkan texture upload" },
{ "vulkan-staging-buffer", GSK_DEBUG_VULKAN_STAGING_BUFFER, "Use a staging buffer for Vulkan texture upload" }
};
-#endif
static guint gsk_debug_flags;
static void
init_debug_flags (void)
{
-#ifdef G_ENABLE_DEBUG
static volatile gsize gsk_debug_flags__set;
if (g_once_init_enter (&gsk_debug_flags__set))
@@ -35,7 +32,6 @@ init_debug_flags (void)
g_once_init_leave (&gsk_debug_flags__set, TRUE);
}
-#endif
}
gboolean
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 6f7ca2337c..8b246477be 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -244,7 +244,6 @@ gtk_simulate_touchscreen (void)
return (gtk_get_debug_flags () & GTK_DEBUG_TOUCHSCREEN) != 0;
}
-#ifdef G_ENABLE_DEBUG
static const GdkDebugKey gtk_debug_keys[] = {
{ "keybindings", GTK_DEBUG_KEYBINDINGS, "Information about keyboard shortcuts" },
{ "modules", GTK_DEBUG_MODULES, "Information about modules and extensions" },
@@ -260,12 +259,11 @@ static const GdkDebugKey gtk_debug_keys[] = {
{ "builder", GTK_DEBUG_BUILDER, "Trace GtkBuilder operation" },
{ "builder-objects", GTK_DEBUG_BUILDER_OBJECTS, "Log unused GtkBuilder objects" },
{ "no-css-cache", GTK_DEBUG_NO_CSS_CACHE, "Disable style property cache" },
- { "interactive", GTK_DEBUG_INTERACTIVE, "Enable the GTK inspector" },
+ { "interactive", GTK_DEBUG_INTERACTIVE, "Enable the GTK inspector", TRUE },
{ "touchscreen", GTK_DEBUG_TOUCHSCREEN, "Pretend the pointer is a touchscreen" },
{ "snapshot", GTK_DEBUG_SNAPSHOT, "Generate debug render nodes" },
{ "accessibility", GTK_DEBUG_A11Y, "Information about accessibility state changes" },
};
-#endif /* G_ENABLE_DEBUG */
/* This checks to see if the process is running suid or sgid
* at the current time. If so, we don’t allow GTK to be initialized.
@@ -546,15 +544,10 @@ do_pre_parse_initialization (void)
gdk_pre_parse ();
-#ifdef G_ENABLE_DEBUG
debug_flags[0].flags = gdk_parse_debug_var ("GTK_DEBUG",
gtk_debug_keys,
G_N_ELEMENTS (gtk_debug_keys));
any_display_debug_flags_set = debug_flags[0].flags > 0;
-#else
- if (g_getenv ("GTK_DEBUG"))
- g_warning ("GTK_DEBUG set but ignored because GTK isn't built with G_ENABLE_DEBUG");
-#endif /* G_ENABLE_DEBUG */
env_string = g_getenv ("GTK_SLOWDOWN");
if (env_string)