如何转储整个Python进程以供以后调试检查? [英] How do I dump an entire Python process for later debugging inspection?

查看:145
本文介绍了如何转储整个Python进程以供以后调试检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Python应用程序在一个奇怪的状态。我不想对进程进行实时调试。可以将其转储到文件中,稍后检查其状态吗?我知道我已经在gdb中恢复了c程序的core文件,但是我不知道如何以一种有用的方式从gdb检查Python应用程序。



是关于调试生产系统中的memleaks 。)

解决方案

没有内置方式其他而不是中止(使用os.abort()),如果资源限制允许,则会导致coredump) - 尽管您可以建立自己的转储功能,以转储关心的数据的相关信息。没有现成的工具。



对于处理Python进程的核心文件, Python源包含一个包含有用的宏的gdbinit文件。它比通过进程本身(使用pdb或交互式解释器)更加痛苦,但它使生活更容易一些。


I have a Python application in a strange state. I don't want to do live debugging of the process. Can I dump it to a file and examine its state later? I know I've restored corefiles of C programs in gdb later, but I don't know how to examine a Python application in a useful way from gdb.

(This is a variation on my question about debugging memleaks in a production system.)

解决方案

There is no builtin way other than aborting (with os.abort(), causing the coredump if resource limits allow it) -- although you can certainly build your own 'dump' function that dumps relevant information about the data you care about. There are no ready-made tools for it.

As for handling the corefile of a Python process, the Python source has a gdbinit file that contains useful macros. It's still a lot more painful than somehow getting into the process itself (with pdb or the interactive interpreter) but it makes life a little easier.

这篇关于如何转储整个Python进程以供以后调试检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆