python-debug
study
set breakpoint on line number by gdb ? http://www.macs.hw.ac.uk/~hwloidl/hackspace/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/share/doc/gcc-linaro-arm-linux-gnueabihf-raspbian/html/gdb/Basic-Python.html https://wiki.python.org/moin/DebuggingWithGdb注意
1. debuginfo-install commnad --> yum install yum-utils參考資料
https://pymotw.com/2/sys/tracing.html https://stripe.com/blog/exploring-python-using-gdbtrace flow by sys.settrace() 以openstack swift 的 set metadata 為例
1. add global function trace_calls(), 如下
def trace_calls(frame, event, arg):
if event != 'call':
return
co = frame.f_code
func_name = co.co_name
if func_name == 'write':
# Ignore write() calls from print statements
return
func_line_no = frame.f_lineno
func_filename = co.co_filename
caller = frame.f_back
caller_line_no = caller.f_lineno
caller_filename = caller.f_code.co_filename
print 'Call to %s on line %s of %s' % \
(func_name, func_line_no, func_filename)
return
2. 將 sys.settrace() 加到 POST function, 因set metadata 會走進 container 的 post function, 如下
def POST(self, req):
"""Handle HTTP POST request."""
sys.settrace(trace_calls)
...
3. post function 的 children functions 會顯示在 /var/log/messages