V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
kamushin
V2EX  ›  Python

GDB attach Python 程序, 打印执行栈, 遇到问题

  •  
  •   kamushin · 2016-05-16 14:39:02 +08:00 · 4347 次点击
    这是一个创建于 2904 天前的主题,其中的信息可能已经有所发展或是发生改变。
    根据这篇文档 https://docs.python.org/devguide/gdb.html
    在 ~/.gdbinit 中加入了 set auto-load safe-path /home/my/python-gdb.py
    可是 GDB 给出了报错 "/root/.gdbinit:1: Error in sourced command file:
    No symbol table is loaded. Use the "file" command."
    V 站上 Python 程序员应该是比较多的, 大家有用 GDB 看 Python 调用栈的经验吗
    4 条回复    2016-05-16 22:22:15 +08:00
    introom
        1
    introom  
       2016-05-16 15:54:07 +08:00 via Android
    这个和 python 没关系, gcc 编译的时候不要任何优化,用-O0 就可以了
    kamushin
        2
    kamushin  
    OP
       2016-05-16 18:08:25 +08:00
    @introom 感觉是编译的 Python 版本是不带 debug symbol 的
    congeec
        3
    congeec  
       2016-05-16 18:23:56 +08:00
    你说的靠谱, debian 系的可以安装 python-dbg 。
    在 OS X 我是自己编译一个带 debug symbol 的版本来调试 CPython 扩展的
    daybyday
        4
    daybyday  
       2016-05-16 22:22:15 +08:00
    要不要试试 pyrasite ,可以 attach 到运行中的 Python 进程,并执行任意 Python 代码
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4683 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 05:36 · PVG 13:36 · LAX 22:36 · JFK 01:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.