diff options
| author | Pierre LALET <pierre.lalet@cea.fr> | 2015-02-16 19:00:59 +0100 |
|---|---|---|
| committer | Pierre LALET <pierre.lalet@cea.fr> | 2015-02-17 12:50:05 +0100 |
| commit | 0c4dde0602f79fcfbd75b2c6e0a01bbfd1371126 (patch) | |
| tree | d81dade687e89fd19f46293219f3e315d6599498 | |
| parent | 773a0e9a43163d84a619496863c3136e63eafc16 (diff) | |
| download | miasm-0c4dde0602f79fcfbd75b2c6e0a01bbfd1371126.tar.gz miasm-0c4dde0602f79fcfbd75b2c6e0a01bbfd1371126.zip | |
Use wrapper `named_arguments` to log function calls
Diffstat (limited to '')
| -rw-r--r-- | miasm2/analysis/sandbox.py | 4 | ||||
| -rw-r--r-- | miasm2/jitter/jitload.py | 30 |
2 files changed, 27 insertions, 7 deletions
diff --git a/miasm2/analysis/sandbox.py b/miasm2/analysis/sandbox.py index 6731929d..310b2ef0 100644 --- a/miasm2/analysis/sandbox.py +++ b/miasm2/analysis/sandbox.py @@ -5,7 +5,7 @@ from miasm2.analysis.machine import Machine from miasm2.os_dep import win_api_x86_32_seh from miasm2.jitter.csts import PAGE_READ, PAGE_WRITE from miasm2.analysis import debugging - +from miasm2.jitter.jitload import log_func class Sandbox(object): """ @@ -56,7 +56,7 @@ class Sandbox(object): self.jitter.jit.log_regs = True if not self.options.quiet_function_calls: - self.machine.log_jit.setLevel(logging.DEBUG) + log_func.setLevel(logging.INFO) if self.options.dumpblocs: self.jitter.jit.log_newbloc = True diff --git a/miasm2/jitter/jitload.py b/miasm2/jitter/jitload.py index defc139a..ccd0a35f 100644 --- a/miasm2/jitter/jitload.py +++ b/miasm2/jitter/jitload.py @@ -9,11 +9,14 @@ from miasm2.core.utils import * from miasm2.core.bin_stream import bin_stream_vm from miasm2.ir.ir2C import init_arch_C -log = logging.getLogger('jitload.py') hnd = logging.StreamHandler() hnd.setFormatter(logging.Formatter("[%(levelname)s]: %(message)s")) +log = logging.getLogger('jitload.py') log.addHandler(hnd) log.setLevel(logging.CRITICAL) +log_func = logging.getLogger('jit function call') +log_func.addHandler(hnd) +log_func.setLevel(logging.CRITICAL) try: from miasm2.jitter.jitcore_tcc import JitCore_Tcc @@ -31,21 +34,38 @@ except ImportError: log.error('cannot import jit python') def named_arguments(func): - """Function decorator to allow the use of .func_args_stdcall() - methods with either the number of arguments or the list of the - argument names. + """Function decorator to allow the use of .func_args_*() methods + with either the number of arguments or the list of the argument + names. + + The wrapper is also used to log the argument values. @func: function + """ @wraps(func) def newfunc(self, args): if isinstance(args, Sequence): ret_ad, arg_vals = func(self, len(args)) + arg_vals = namedtuple("args", args)(*arg_vals) + # func_name(arguments) return address + log_func.info('%s(%s) ret addr: %s' % ( + whoami(), + ', '.join("%s=0x%x" % (field, value) + for field, value in arg_vals._asdict().iteritems()), + hex(ret_ad))) return ret_ad, namedtuple("args", args)(*arg_vals) else: - return func(self, args) + ret_ad, arg_vals = func(self, args) + # func_name(arguments) return address + log_func.info('%s(%s) ret addr: %s' % ( + whoami(), + ', '.join(hex(arg) for arg in arg_vals), + hex(ret_ad))) + return ret_ad, arg_vals return newfunc + class CallbackHandler(object): "Handle a list of callback" |