记一次PyQT5 core dump调试过程

1. 首先设置系统允许生成core dump文件

步骤一:开启core dump文件生成

ulimit -c unlimited

步骤二:设置core dump文件位置

vi /etc/sysctl.conf

修改(添加)如下两个变量

kernel.core_pattern =/var/core/core_%e_%p

kernel.core_uses_pid= 0

这里是改为生成目录在/var/core/,%e代表程序名称,%p是进程ID

如果想直接生成在可执行文件相同目录,前面不要加任何目录,直接

kernel.core_pattern =core_%e_%p

步骤三:让修改生效

sysctl -p/etc/sysctl.conf

2. 准备工作

准备工作

安装 gdb 和 python2.7-dbg:

sudo apt-get install gdb python2.7-dbg

设置 /proc/sys/kernel/yama/ptrace_scope:

echo 0 |sudo tee /proc/sys/kernel/yama/ptrace_scope

3. gdb调试Python core文件的方法

使用gdb打开并调试core文件

gdb python core
$ gdb python core
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python...Reading symbols from /usr/lib/debug/.build-id/04/9b3068eb18127661de41257e012a54934fb0ee.debug...done.
done.


[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `python2 mantra_hmi_pro.py'.
Program terminated with signal SIGABRT, Aborted.
#0  0x00007f04fdf36428 in __GI_raise (sig=
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值