Lptrace is essentially GDB-based, enters the process memory space, and executes a python command to print out the trace at the time.
Use tool: Https://github.com/khamidou/lptrace
1, Linux is very simple:
Installation
Yum Install GDB
Pip Install Lptrace
Use:
[email protected]:/vagrant$ python -m SimpleHTTPServer 8080 &[1] 1818[email protected]:/vagrant$ Serving HTTP on 0.0.0.0 port 8080 ...
[email protected]:/vagrant$ sudo python lptrace-p1818... Fileno (/usr/lib/python2.7/socketserver.py:438) Meth (/usr/lib/python2.7/socket.py:223) Fileno (/usr/lib/ python2.7/socketserver.py:438) Meth (/usr/lib/python2.7/socket.py:223) _handle_request_noblock (/usr/lib/python2.7 /socketserver.py:271) Get_request (/usr/lib/python2.7/socketserver.py:446) Accept (/usr/lib/python2.7/socket.py : 201) __init__ (/usr/lib/python2.7/socket.py:185) verify_request (/usr/lib/python2.7/socketserver.py:296) Process_ Request (/usr/lib/python2.7/socketserver.py:304) finish_request (/usr/lib/python2.7/socketserver.py:321) __init__ ( /usr/lib/python2.7/socketserver.py:632) Setup (/usr/lib/python2.7/socketserver.py:681) makefile (/usr/lib/ python2.7/socket.py:212) __init__ (/usr/lib/python2.7/socket.py:246) makefile (/usr/lib/python2.7/socket.py:212) __ init__ (/usr/lib/python2.7/socket.py:246) handle (/usr/lib/python2.7/basehttpserver.py:336) handle_one_request (/ usr/lib/python2.7/basehttpserver.py:301) ^creceived ctrl-c, quitting[email protected]:/vagrant$
You can see, the server is handling the request in real time! After pressing Ctrl-c, the trace was removed and the program execution resumes normally.
2, the Mac is a little complicated: The key I did not try to succeed
Setting method Reference: HTTP://WWW.JIANSHU.COM/P/CE2D77D7D1C4
Https://sourceware.org/gdb/wiki/BuildingOnDarwin
Ways to view Python's trace