--- /dev/null
+* You can use the GI_SCANNER_DEBUG environment variable; see utils.py
+ for a list of debug flags.
import sys
from . import ast
+from . import utils
(WARNING,
ERROR,
def log(self, log_type, text, file_positions=None, prefix=None):
"""Log a warning, using optional file positioning information.
If the warning is related to a ast.Node type, see log_node_warning()."""
+ utils.break_on_debug_flag('warning')
+
if not self._enable_warnings:
return
from giscanner.shlibs import resolve_shlibs
from giscanner.sourcescanner import SourceScanner
from giscanner.transformer import Transformer
-from giscanner.utils import files_are_identical
+from . import utils
def _get_option_parser():
parser = optparse.OptionParser('%prog [options] sources')
main = MainTransformer(transformer, blocks)
main.transform()
+ utils.break_on_debug_flag('tree')
+
final = IntrospectablePass(transformer)
final.validate()
temp_f = os.fdopen(temp_f, 'w')
passthrough_gir(main_f_name, temp_f)
temp_f.close()
- if not files_are_identical(main_f_name, temp_f_name):
+ if not utils.files_are_identical(main_f_name, temp_f_name):
_error("Failed to re-parse gir file; scanned=%r passthrough=%r" % (
main_f_name, temp_f_name))
os.unlink(temp_f_name)
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])')
import sys
if 'GI_SCANNER_DEBUG' in os.environ:
- def on_exception(type, value, tb):
+ def on_exception(exctype, value, tb):
+ print "Caught exception: %r %r" % (exctype, value)
import pdb
pdb.pm()
sys.excepthook = on_exception