Skip to content

Commit 15fcedd

Browse files
committed
allow enabling python harness log output via --debug argument
1 parent 4ee1195 commit 15fcedd

File tree

4 files changed

+6
-12
lines changed

4 files changed

+6
-12
lines changed

harness/fuzzware_harness/exit.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ def invoke_exit_callbacks(status, kill_signal=-1):
2323
"""
2424
global exit_hooks
2525

26-
from .globs import debug_enabled, uc
26+
from .globs import uc
2727

2828
for fn in exit_hooks:
29-
if debug_enabled:
30-
logger.debug(f"Calling exit hook {exit_hooks}")
29+
logger.debug(f"Calling exit hook {exit_hooks}")
3130
try:
3231
fn(uc)
3332
except:

harness/fuzzware_harness/globs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
debug_enabled = False
21
input_file_name = None
32
uc = None
43
regions = {}

harness/fuzzware_harness/harness.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from .util import (bytes2int, load_config_deep, parse_address_value,
1818
parse_symbols, resolve_region_file_paths)
1919

20+
logging.basicConfig(stream=sys.stdout, level=logging.WARNING)
2021
logger = logging.getLogger("emulator")
2122

2223
def unicorn_trace_syms(uc, address, size=0, user_data=None):
@@ -371,11 +372,8 @@ def main():
371372
logger.error("input file is no regular file")
372373
sys.exit(1)
373374

374-
debug_flags = [args.trace_memory, args.trace_funcs, args.breakpoints, args.gdb_port != 0]
375-
if any(debug_flags):
376-
args.debug = True
377-
378-
globs.debug_enabled = args.debug
375+
if args.debug:
376+
logger.setLevel(logging.DEBUG)
379377

380378
uc = configure_unicorn(args)
381379
globs.uc = uc

harness/fuzzware_harness/user_hooks/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from .. import globs
1111
from ..exit import do_exit
12-
from ..globs import debug_enabled
1312

1413

1514
logger = logging.getLogger("emulator")
@@ -103,8 +102,7 @@ def add_func_hook(uc, addr, func, do_return=True):
103102
def func_hook_handler(uc, addr, size, user_data):
104103
if addr in func_hooks:
105104
for hook in func_hooks[addr]:
106-
if debug_enabled:
107-
logger.info("Calling hook %s at %#08x" % (func_hooks[addr].__name__, addr))
105+
logger.info("Calling hook %s at %#08x" % (func_hooks[addr].__name__, addr))
108106
try:
109107
hook(uc)
110108
except:

0 commit comments

Comments
 (0)