Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Debug and trace in python
#1
I have to try use command: python -m trace --listfuncs --trackcalls main.py I write a simple code to test: file testdebug:
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pycharm debug help mg24 1 1,032 Nov-18-2022, 05:38 AM
Last Post: deanhystad
  Python debug suddenly got bad ben1122 3 1,098 Sep-03-2022, 06:20 AM
Last Post: ben1122
  Avoid third party functions to wrote my python code into system debug-log? mark 9 2,201 Apr-09-2022, 08:41 PM
Last Post: mark
Lightbulb trace library xxxlabradorxxx 1 1,144 Oct-01-2021, 11:30 PM
Last Post: Larz60+
Bug Help Debug please jamesaarr 12 3,863 Jul-28-2021, 11:20 PM
Last Post: Pedroski55
  Error in Int object is not subscript-able. How to debug this ? yanDvator 1 2,226 Aug-03-2020, 02:28 PM
Last Post: Larz60+
  Tracing a multiplication table w/ Python trace() NationalRex22 0 1,750 Jun-11-2019, 03:31 AM
Last Post: NationalRex22
  trace invalid pointer simon149 7 5,098 Apr-16-2019, 07:05 AM
Last Post: simon149
  Stack trace shows different exception type than print micseydel 5 4,415 Apr-01-2019, 10:24 PM
Last Post: micseydel
  How to create shadow between two colours and control a line after we trace it? CrazyPythonNerd 0 2,113 Mar-06-2019, 01:31 PM
Last Post: CrazyPythonNerd

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020