summaryrefslogtreecommitdiff
path: root/giscanner/utils.py
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-09-07 09:52:54 -0400
committerColin Walters <walters@verbum.org>2010-09-07 10:22:23 -0400
commit4905b753cbad546875616eae13918eca539680c9 (patch)
treef251134c64683fadf1774d230e17056130b34c1f /giscanner/utils.py
parent2eb614e805311841e17fd4dbe76aa70443f3a911 (diff)
downloadgobject-introspection-4905b753cbad546875616eae13918eca539680c9.tar.gz
scanner: Add various static debug hooks in GI_SCANNER_DEBUG
For backwards compat, keep the presence of the environment variable at all to mean "exception". Also start a HACKING file.
Diffstat (limited to 'giscanner/utils.py')
-rw-r--r--giscanner/utils.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/giscanner/utils.py b/giscanner/utils.py
index dba958ef..2263b8cd 100644
--- a/giscanner/utils.py
+++ b/giscanner/utils.py
@@ -22,6 +22,27 @@ import re
import os
import subprocess
+_debugflags = None
+def have_debug_flag(flag):
+ """Check for whether a specific debugging feature is enabled.
+Well-known flags:
+ * start: Drop into debugger just after processing arguments
+ * exception: Drop into debugger on fatalexception
+ * warning: Drop into debugger on warning
+ * posttrans: Drop into debugger just before introspectable pass
+"""
+ global _debugflags
+ if _debugflags is None:
+ _debugflags = os.environ.get('GI_SCANNER_DEBUG', '').split(',')
+ if '' in _debugflags:
+ _debugflags.remove('')
+ return flag in _debugflags
+
+def break_on_debug_flag(flag):
+ if have_debug_flag(flag):
+ import pdb
+ pdb.set_trace()
+
# Copied from h2defs.py
_upperstr_pat1 = re.compile(r'([^A-Z])([A-Z])')
_upperstr_pat2 = re.compile(r'([A-Z][A-Z])([A-Z][0-9a-z])')