How to install python debug symbols for GDB on amazon linux AMI

amazon ec2amazon-ami

I am running into problems on my EC2 box running Python in an elastic-beanstalk container. In order to debug the problem, I need to attach a debugger to it and debug python with python symbols.

When I attach GDB to the process, I get this error:

Reading symbols from /usr/bin/python...(no debugging symbols found)...done. 
Attaching to program: /usr/bin/python, process 31238
Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols
from /usr/lib/debug/lib64/ld-2.12.so.debug...done. done. Loaded
symbols for /lib64/ld-linux-x86-64.so.2 0x00007ffec3759a63 in ?? ()
Missing separate debuginfos, use: debuginfo-install
python-2.6-2.23.amzn1.noarch

However, when I run debug-info install python-2.6-2.23.amzn1.noarch, it doe

[root@1.2.3.4]# debuginfo-install python-2.6-2.23.amzn1.noarch
Loaded plugins: auto-update-debuginfo, fastestmirror, priorities, update-motd
enabling amzn-main-debuginfo
enabling amzn-updates-debuginfo
Loading mirror speeds from cached hostfile
 * amzn-main: packages.us-east-1.amazonaws.com
 * amzn-main-debuginfo: packages.us-east-1.amazonaws.com
 * amzn-updates: packages.us-east-1.amazonaws.com
 * amzn-updates-debuginfo: packages.us-east-1.amazonaws.com
amzn-main                                                                                                                                                         | 2.1 kB     00:00     
amzn-main-debuginfo                                                                                                                                               | 1.9 kB     00:00     
amzn-updates                                                                                                                                                      | 2.3 kB     00:00     
amzn-updates-debuginfo                                                                                                                                            | 1.9 kB     00:00     
Checking for new repos for mirrors
Could not find debuginfo for main pkg: 1:python-2.6-2.23.amzn1.noarch
No debuginfo packages available to install

Any idea how to get these symbols on the box?

Best Answer

As per amazon support:

The Amazon Linux images all have the repository for debuginfo disabled by default as they would not be needed in production. You can enable them in two ways:

  1. Edit the two following files and change enabled=0 to enabled=1 in the debuginfo section of:

    /etc/yum.repos.d/amzn-main.repo
    /etc/yum.repos.d/amzn-updates.repo
    

    Then run the following command to install the debuginfo for python 2.6:

    sudo yum install python26-debuginfo
    
  2. To temporarily enable the same repositories just for the case of the install that you need, you could run the following command on it's own:

    sudo yum install --enablerepo=amzn-main-debuginfo,amzn-updates-debuginfo python26-debuginfo
    

For Amazon Linux 2 instead either:

  1. Edit /etc/yum.repos.d/amzn2-core.repo as above before installing
  2. Or to run all in one command (as root):
    yum install --enablerepo=amzn2-core-debuginfo python3-debuginfo