How to install python debug-info for gdb?
Asked Answered
M

2

5

I want to use gdb to debug python script. After starting gdb, it outputs:

[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

According to its prompts, I execute debuginfo-install python-2.7.5-16.el7.x86_64 command, and the output is:

[root@localhost scripts]# debuginfo-install python-2.7.5-16.el7.x86_64
Loaded plugins: product-id
centos-extra                                                                               | 3.4 kB  00:00:00
rhel                                                                                       | 4.1 kB  00:00:00
centos-extra/primary_db                                                                    | 563 kB  00:00:00
Could not find debuginfo for main pkg: python-2.7.5-16.el7.x86_64
Could not find debuginfo pkg for dependency package glibc-2.17-55.el7.x86_64
Could not find debuginfo pkg for dependency package python-libs-2.7.5-16.el7.x86_64
No debuginfo packages available to install

P.S.: There are 2 yum data source: the RHEL 7.0 iso and CentOS link:

[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

How can I install python debug-info?

Mercia answered 16/4, 2015 at 2:18 Comment(0)
B
5

I want to use gdb to debug python script

I believe the debug info is for debugging the Python interpreter itself, not Python scripts. As far as I know gdb doesn't know about Python scripts. If you start gdb python, you're asking gdb to debug the python interpreter.

To debug Python scripts you can use pdb (instead of gdb) which has some similarities in its commands...

import pdb

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

EDIT: So the question was how to install debug-info for Python. Are you sure you want to debug Python itself?

Here are some thoughts: The RHEL iso is probably not the correct source for -devel information. I don't think the original iso will have the info you need.

I found -debuginfo packages for your original python packages in several places, but there is a warning (eg. http://rpm.pbone.net/index.php3/stat/4/idpl/26126276/dir/redhat_7.x/com/python-debuginfo-2.7.5-16.el7.x86_64.rpm.html) which says:

This package is obsolete.

There is a version of the debug info on http://buildlogs.centos.org/c7.00.04/python/20140617165351/2.7.5-16.el7.x86_64/ . It's been years since I've use yum, but I believe that you can download that package manually, and run yum on the downloaded package to install it. According to the messages in your original question, you will have to install the debuginfo for glibc and python-libs too (or maybe first). Something like: yum --nogpgcheck localinstall packagename.arch.rpm

Ballroom answered 17/4, 2015 at 4:46 Comment(9)
Yeah, you are right. I have confused 2 thing, thanks!Mercia
@NanXiao: If the answer helps you, it would be nice if you 'accept' the answer (clicking the 'v'). That way, people can find the answer more easily, and the question gets marked as 'answered'.Ballroom
The point of this question should be "how to install python debug info", could you help me?Mercia
But from Redhat document: "For example, using a CentOS debuginfo RPM for a Red Hat Enterprise Linux RPM package will not work.". I am afraid this method can't work.Mercia
Did you consider installing Python and its debug info from CentOS? They should be compatible. (removing the original RHEL package, of course). Also, I found this package oss.oracle.com/ol7/debuginfo/…Ballroom
and ftp.de/pub/scientific/7rolling/archive/debuginfo/…Ballroom
very appreciated for your detailed and patient answers! BTW, the ftp://ftp.de/pub/scientific/7rolling/archive/debuginfo/python-debuginfo-2.7.5-16.el7.x86_64.rpm link seems out of work now, could you access it?Mercia
Strange - yes, I checked before posting the link. Here's another one: ftp.scientificlinux.org/linux/scientific/7.0/archive/debuginfo/…Ballroom
according to #29664756 Extensions package includes debugging symbols and adds Python-specific commands into gdbVitrify
C
3

There are some instructions here on how to install python-debuginfo on various OS's.

Specifically:

Fedora:

sudo yum install gdb python-debuginfo

Ubuntu:

sudo apt-get install gdb python2.7-dbg

Centos*:

sudo yum install yum-utils

sudo debuginfo-install glibc

sudo yum install gdb python-debuginfo

Chastity answered 3/5, 2018 at 21:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.