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?
Explanation. GDB embeds the Python interpreter so it can use Python as an extension language. You can't just import gdb from /usr/bin/python like it's an ordinary Python library because GDB isn't structured as a library. What you can do is source MY-SCRIPT.py from within gdb (equivalent to running gdb -x MY-SCRIPT.py ) ...
... but gdb supporting Python, doesn't mean Python on its own can access gdb functionality (apparently, the gdb has its own built-in separate Python interpreter).
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With