-
Notifications
You must be signed in to change notification settings - Fork 1
/
debug.py
42 lines (31 loc) · 1.27 KB
/
debug.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# debug.py
# Copyright (C) 2012 Ulrich Hecht
# This file is part of 6502 Decompiler.
# 6502 Decompiler is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3 as published
# by the Free Software Foundation.
# 6502 Decompiler is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
# You should have received a copy of the GNU General Public License along
# with 6502 Decompiler. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import sys
SSA, DESSA, EXPR, ARGRET, TRACE, BLOCK, CODE, MAIN, TYPE = range(0, 9)
_name = ['ssa', 'dessa', 'expr', 'argret', 'trace', 'block', 'code', 'main', 'type']
enabled = set()
debug_level = 0
debugout = sys.stdout
enabled = set()
def debug(type, level, *args, **kwargs):
global enabled
if debug_level >= level and type in enabled:
print(_name[type].ljust(6).upper(), *args, file=debugout, **kwargs)
def enable(lst):
global enabled
if 'all' in lst:
lst = _name
enabled = [list.index(_name, x) for x in lst]
def debug_enabled(level):
return debug_level >= level