Advanced python tracing

strace python -m trace --trace myprog.py | grep -v 'write(1,'
Trace python statement execution and syscalls invoked during that simultaneously
Sample Output
echo 'print("Hello world!")' > helloworld.py; strace python -m trace --trace helloworld.py | grep -v 'write(1,'
execve("/usr/bin/python", ["python", "-m", "trace", "--trace", "helloworld.py"], [/* 22 vars */]) = 0
brk(0)                                  = 0x222e000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f364a418000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=81069, ...}) = 0
mmap(NULL, 81069, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f364a404000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
..snip...
write(1, " --- modulename: helloworld, fun"..., 188 --- modulename: helloworld, funcname: <module>
helloworld.py(1): print("Hello world!")
Hello world!
 --- modulename: trace, funcname: _unsettrace
trace.py(80):         sys.settrace(None)
) = 188
exit_group(0)                           = ?
+++ exited with 0 +++

0
By: roolebo
2016-05-27 21:01:01

What Others Think

Command line efu is really a digital mentor for me as it always helps me to produce a command line code. One should read essay writing service reviews before help in essays. I also learn to develop a code in python programming language from this forum because the members and technical teams are so responsive.
LawrenceBartell · 73 weeks and 3 days ago
I have been looking for this information for a long time, I was very surprised when I found it here. jiofi.local.html
malkovich · 60 weeks and 1 day ago
Houston is a large metropolis in Texas, extending to Galveston Bay. It’s closely linked with the Space Center Houston, the coastal visitor center at NASA’s astronaut training and flight control complex. MaxRemind top rank medical billing company of USA offers medical billing services in Houston, TX, medical credentialing services and home health agency software in Houston.
stevematt · 34 weeks and 5 days ago
took me time to read the forum but its actually great. People should know about this more. wichitadentalimplantswichitaks.com
Killersmile · 25 weeks and 3 days ago
Whenever I am going toward a tremendous load of weight and strain, I will when everything is said in done attract towards religion. Get brilliant contemplations concerning how to do it. One hire this https://www.passivevoicechecker.com/passive-voice-checker-online/ to work at time. Doing alluding to practices gives me a monstrous store of supporting and comfort.
Ahmed74 · 23 weeks and 1 day ago
I'm not an alluding to individual yet I don't see youth clearing. Click http://www.grammarcheckonline.net/check-my-grammar-online-service/ to read a useful info about how to do this work. By going for a not really ideal birth, we issue with the brand name laws.
Ahmed74 · 23 weeks and 1 day ago
Not in the humblest degree like incapacitating and formal strategy in different schools ran by the gathering or public divisions, self-getting ready enlightening undertakings offers a more reasonable approach to manage regulate control direct make their youths more imaginative. Try this http://www.colonchecker.com/what-to-know-about-order-of-adjectives-in-english/ for more info. Being the educator of your young adult, picked illuminating courses should fulfill.
Ahmed74 · 23 weeks and 1 day ago
I wanted to master python and this will be a great exercise for me. Nice work with the codes. https://unioncityconcrete.com/
CarlCuperstone · 23 weeks and 1 day ago
Happy to see that these scores since I have performed so well in the Fantasy Cycling. Visit homepage for more info. With the headway of time, there is an improvement in my show.
tinakutch · 18 weeks and 1 day ago
There are a goliath number of such things in this conversation discussion which are putting my portrayal on the map. Just have a look http://www.sentencecorrection.biz/best-known-sentence-comma-checker-online/ i hope you will like it. This stage is genuinely stunning.
tinakutch · 18 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: