zoukankan      html  css  js  c++  java
  • 关于查看python的trace的方法

    lptrace本质上是基于GDB的,进入到进程内存空间,然后执行了一段python指令把当时的trace给print出来

    使用工具:https://github.com/khamidou/lptrace

    1、linux上很简单:

    安装

    yum install gdb

    pip install lptrace

    使用:

    vagrant@precise32:/vagrant$ python -m SimpleHTTPServer 8080 &
    [1] 1818
    vagrant@precise32:/vagrant$ Serving HTTP on 0.0.0.0 port 8080 ...


    vagrant@precise32:/vagrant$ sudo python lptrace -p 1818
    ...
    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
    vagrant@precise32:/vagrant$
    

    You can see that the server is handling the request in real time! After pressing Ctrl-C, the trace is removed and the program execution resumes normally.

    2、mac上有点复杂:关键我也没有尝试成功

    设置方法参考:http://www.jianshu.com/p/ce2d77d7d1c4

    https://sourceware.org/gdb/wiki/BuildingOnDarwin

  • 相关阅读:
    【转】SVN与Git比较
    我遇到了Hibernate异常
    使用 Eclipse 远程调试 Java 应用程序
    linux显示桌面快捷键设置
    Ubuntu共享WiFi(AP)给Android方法
    用zd1211+Ubuntu 10.04实现的AP
    Ubuntu开机自动禁用无线网络
    戴尔大力宣传Ubuntu 对比与Windows的差异
    【SSH进阶之路】Spring的AOP逐层深入——采用注解完成AOP(七)
    【SSH进阶之路】Spring的AOP逐层深入——AOP的基本原理(六)
  • 原文地址:https://www.cnblogs.com/shengulong/p/8007086.html
Copyright © 2011-2022 走看看