Jun-20-2017, 09:35 AM
I have to try use command: python -m trace --listfuncs --trackcalls main.py I write a simple code to test: file testdebug:
hello
hello1
calling relationships:
*** /usr/lib/python2.7/trace.py ***
trace.Trace.runctx -> trace._unsettrace
--> testdebug
trace.Trace.runctx -> testdebug.<module>
*** testdebug ***
--> testdebug1.py
testdebug.<module> -> testdebug1.<module>
testdebug.<module> -> testdebug1.hello
*** testdebug1.py ***
--> testdebug2.py
testdebug1.<module> -> testdebug2.<module>
testdebug1.hello -> testdebug2.hello1
Very easy, if i read this result, me will known testdebug caller testdebug1.hello and testdebug1.hello -> testdebug2.hello1. Problem of me is when me trace binwalk(open source). I see part of follow code:
*** /usr/local/lib/python2.7/dist-packages/binwalk/core/display.py ***
--> /usr/lib/python2.7/csv.py
display.<module> -> csv.<module>
display.<module> -> display.Display
display.Display.__init__ -> display.Display._configure_formatting
display.Display._configure_formatting -> display.Display.format_strings
display.Display._fprint -> display.Display._format_line
display.Display.footer -> display.Display._fprint
--> /usr/local/lib/python2.7/dist-packages/binwalk/core/compat.py
display.Display.header -> compat.has_key
display.Display.header -> display.Display._fprint
display.Display.result -> display.Display._fprint
I found display.py and it firstly appear at line above code. I really don't known where display.py is caller. When i keep looking, I see follow code:
*** /usr/local/lib/python2.7/dist-packages/binwalk/core/module.py ***
--> /usr/local/lib/python2.7/dist-packages/binwalk/core/display.py
module.Module.footer -> display.Display.footer
module.Module.header -> display.Display.add_custom_header
module.Module.header -> display.Display.format_strings
module.Module.header -> display.Display.header
module.Module.main -> display.Display.format_strings
module.Module.main -> module.Module._plugins_post_scan
module.Module.main -> module.Module._plugins_pre_scan
module.Module.main -> module.Module.init
module.Module.main -> module.Module.reset_dependencies
module.Module.main -> module.Module.run
May it is caller from /binwalk/core/module.py. But why first, What is caller it?
from testdebug1 import * hello()file testdebug1:
from testdebug2 import * def hello(): print "hello" hello1()file testdebug2:
def hello1(): print "hello1"And after i use command: python -m trace --listfuncs --trackcalls testdebug I have result:
hello
hello1
calling relationships:
*** /usr/lib/python2.7/trace.py ***
trace.Trace.runctx -> trace._unsettrace
--> testdebug
trace.Trace.runctx -> testdebug.<module>
*** testdebug ***
--> testdebug1.py
testdebug.<module> -> testdebug1.<module>
testdebug.<module> -> testdebug1.hello
*** testdebug1.py ***
--> testdebug2.py
testdebug1.<module> -> testdebug2.<module>
testdebug1.hello -> testdebug2.hello1
Very easy, if i read this result, me will known testdebug caller testdebug1.hello and testdebug1.hello -> testdebug2.hello1. Problem of me is when me trace binwalk(open source). I see part of follow code:
*** /usr/local/lib/python2.7/dist-packages/binwalk/core/display.py ***
--> /usr/lib/python2.7/csv.py
display.<module> -> csv.<module>
display.<module> -> display.Display
display.Display.__init__ -> display.Display._configure_formatting
display.Display._configure_formatting -> display.Display.format_strings
display.Display._fprint -> display.Display._format_line
display.Display.footer -> display.Display._fprint
--> /usr/local/lib/python2.7/dist-packages/binwalk/core/compat.py
display.Display.header -> compat.has_key
display.Display.header -> display.Display._fprint
display.Display.result -> display.Display._fprint
I found display.py and it firstly appear at line above code. I really don't known where display.py is caller. When i keep looking, I see follow code:
*** /usr/local/lib/python2.7/dist-packages/binwalk/core/module.py ***
--> /usr/local/lib/python2.7/dist-packages/binwalk/core/display.py
module.Module.footer -> display.Display.footer
module.Module.header -> display.Display.add_custom_header
module.Module.header -> display.Display.format_strings
module.Module.header -> display.Display.header
module.Module.main -> display.Display.format_strings
module.Module.main -> module.Module._plugins_post_scan
module.Module.main -> module.Module._plugins_pre_scan
module.Module.main -> module.Module.init
module.Module.main -> module.Module.reset_dependencies
module.Module.main -> module.Module.run
May it is caller from /binwalk/core/module.py. But why first, What is caller it?