How can I make Perl and Python print each line of the program being executed? How can I make Perl and Python print each line of the program being executed? bash bash

How can I make Perl and Python print each line of the program being executed?


python -m trace -t main.py

Test program:

main.py

from a import gdef f(i):    g(i)for i in range(3):    f(i)

a.py

def g(i):    print i

Output:

 --- modulename: main, funcname: <module>main.py(1): from a import g --- modulename: a, funcname: <module>a.py(1): def g(i):main.py(2): def f(i):main.py(4): for i in range(3):main.py(5):     f(i) --- modulename: main, funcname: fmain.py(3):     g(i) --- modulename: a, funcname: ga.py(2):     print i0main.py(4): for i in range(3):main.py(5):     f(i) --- modulename: main, funcname: fmain.py(3):     g(i) --- modulename: a, funcname: ga.py(2):     print i1main.py(4): for i in range(3):main.py(5):     f(i) --- modulename: main, funcname: fmain.py(3):     g(i) --- modulename: a, funcname: ga.py(2):     print i2main.py(4): for i in range(3): --- modulename: trace, funcname: _unsettracetrace.py(80):         sys.settrace(None)

Tested on Ubuntu 16.10, Python 2.7.12.


Devel::DumpTrace was released in 2011 and has more features than Devel::Trace, such as evaluating variable values in the trace output.