如何为gdb安装python调试信息?

如何为gdb安装python调试信息?,python,linux,debugging,gdb,rhel,Python,Linux,Debugging,Gdb,Rhel,我想使用gdb调试python脚本。启动gdb后,输出: [root@localhost scripts]# gdb python GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-51.el7 Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

我想使用
gdb
调试
python
脚本。启动
gdb
后,输出:

[root@localhost scripts]# gdb python
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-51.el7
Copyright (C) 2013 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-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/python2.7...Reading symbols from /usr/bin/python2.7...(no debugging symbols found)..
.done.
(no debugging symbols found)...done.
Missing separate debuginfos, use: debuginfo-install python-2.7.5-16.el7.x86_64
注意:有两个yum数据源:RHEL 7.0 iso和CentOS链接:

[rhel]
name=rhel 7.0
baseurl=file:///mnt/iso
enabled=1
gpgcheck=0


[centos-extra]
name=centos extra
baseurl=http://cbs.centos.org/repos/virt7-testing/x86_64/os/
enabled=1
gpgcheck=0
如何安装python调试信息

我想使用gdb调试python脚本

我相信调试信息是用来调试Python解释器本身的,而不是Python脚本。据我所知,gdb并不了解Python脚本。如果启动
gdb-python
,则要求gdb调试python解释器

要调试Python脚本,可以使用pdb(而不是gdb),它的命令有一些相似之处

import pdb

....code...
pdb.set_trace()      # This introduces a breakpoint
... code...
编辑:所以问题是如何为Python安装调试信息。您确定要调试Python本身吗

这里有一些想法:RHEL iso可能不是-devel信息的正确来源。我不认为原始iso会有你需要的信息

我在几个地方找到了原始python包的-debuginfo包,但是有一个警告(例如):

这个包裹已经过时了


上有调试信息的版本。我已经多年没有使用过yum了,但我相信您可以手动下载该软件包,然后在下载的软件包上运行yum来安装它。根据原始问题中的消息,您还必须为glibc和pythonlibs安装
debuginfo
(或者可能首先安装)。类似于:
yum--nogpgcheck localinstall packagename.arch.rpm

有一些关于如何在各种操作系统上安装python调试信息的说明

具体而言:

软呢帽:

sudo yum安装gdb python debuginfo

Ubuntu:

sudo apt get安装gdb python2.7-dbg

Centos*:

sudo-yum安装yum-utils

sudo debuginfo安装glibc

sudo yum安装gdb python debuginfo


是的,你说得对。我弄糊涂了两件事,谢谢@NanXiao:如果答案对你有帮助,那么你最好“接受”这个答案(点击“v”)。这样,人们就可以更容易地找到答案,并且问题被标记为“已回答”。这个问题的重点应该是“
如何安装python调试信息”
”,您能帮我吗?但是来自:“例如,对Red Hat Enterprise Linux RPM包使用CentOS debuginfo RPM将不起作用。”。恐怕这个方法不能用。你有没有考虑从PixOS安装Python及其调试信息?它们应该是兼容的。(当然,移除原始RHEL包)。还有,我找到了这个包裹
import pdb

....code...
pdb.set_trace()      # This introduces a breakpoint
... code...