Python Forum
Python GDB scripts for Fedora41
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python GDB scripts for Fedora41
#1
Hi, this might be a long shot and may not fall in the python coding help category exactly but I can't find any other information about it.

I am trying to get the Python GDB scripts setup on my system so I can get access to py-bt, py-list, etc.

I am running Fedora 41 with Python3.13. I have installed python3-3.13.2-1.fc41.x86_64, python3.13-debuginfo-3.13.1-2.fc41.x86_64, and python3.13-debugsource-3.13.1-2.fc41.x86_64 but none of those RPMs provide python3-gdb.py or python3.13-gdb.py

I do see /usr/lib/debug/usr/lib64/libpython3.13.so.1.0-3.13.1-2.fc41.x86_64.debug-gdb.py and /usr/lib/debug/usr/lib64/libpython3.13d.so.1.0-3.13.1-2.fc41.x86_64.debug-gdb.py, however, it doesn't seem like gdb is trying to load those. Most likely, this is because on my system /usr/bin/python3.13d is not linked against /usr/lib64/libpython3.13d.so.1.0 but rather /lib64/libpython3.13d.so.1.0.

This is my .gdbinit file:

set debuginfod enabled on
add-auto-load-safe-path /usr/share/gdb/python/gdb/
add-auto-load-safe-path /usr/lib/debug/
set auto-load python-scripts on
set auto-load gdb-scripts on
Any help with this is appreciated.
Reply
#2
Not a Fedora user here but the Python documentation suggests that you issue the following commands for Fedora
Output:
sudo dnf install gdb sudo dnf debuginfo-install python3
Have you done this step?
« We can solve any problem by introducing an extra level of indirection »
Reply
#3
The key issue seems to be the mismatch between where your Python binary expects to find the library (/lib64/) and where the debug scripts are configured (/usr/lib64/).
One straightforward fix is to create a symbolic link so that the path GDB looks in actually points to the real location.
For example, you can make GDB’s expected directory match by linking:
sudo ln -s /usr/lib/debug/usr/lib64 /usr/lib/debug/lib64
After doing this,when GDB looks in /usr/lib/debug/lib64/,
it should find the auto-load scripts (since they appear via the symlink) and load the Python commands.

Alternatively, you can tell GDB where to look by setting its debug-file-directory.
In your .gdbinit file (or at the GDB prompt) add a line like:
set debug-file-directory /usr/lib/debug/usr/lib64:/usr/lib/debug
This tells GDB to check both paths when searching for debug files
Reply
#4
(Apr-13-2025, 08:09 AM)snippsat Wrote: The key issue seems to be the mismatch between where your Python binary expects to find the library (/lib64/) and where the debug scripts are configured (/usr/lib64/).
One straightforward fix is to create a symbolic link so that the path GDB looks in actually points to the real location.
For example, you can make GDB’s expected directory match by linking:
sudo ln -s /usr/lib/debug/usr/lib64 /usr/lib/debug/lib64
After doing this,when GDB looks in /usr/lib/debug/lib64/,
it should find the auto-load scripts (since they appear via the symlink) and load the Python commands.

Alternatively, you can tell GDB where to look by setting its debug-file-directory.
In your .gdbinit file (or at the GDB prompt) add a line like:
set debug-file-directory /usr/lib/debug/usr/lib64:/usr/lib/debug
This tells GDB to check both paths when searching for debug files

On my system /usr/lib/debug/lib64 is a link to /usr/lib/debug/usr/lib64/ so that's not it.

total 16
drwxr-xr-x. 1 root root   62 Jan 17 08:31 .
dr-xr-xr-x. 1 root root 1148 Mar  7 12:58 ..
lrwxrwxrwx. 1 root root    7 Apr 13  2023 bin -> usr/bin
drwxr-xr-x. 1 root root  736 Jan 17 08:31 .build-id
drwxr-xr-x. 1 root root   62 Jan 17 08:31 .dwz
lrwxrwxrwx. 1 root root    7 Apr 13  2023 lib -> usr/lib
lrwxrwxrwx. 1 root root    9 Apr 13  2023 lib64 -> usr/lib64
lrwxrwxrwx. 1 root root    8 Apr 13  2023 sbin -> usr/sbin
drwxr-xr-x. 1 root root   38 Dec  8 16:00 usr
What I am seeing is that GDB doesn't even seem to be looking for debug info for libpython. It only looks for python3.13d and since there is no GDB scripts file for that executable, it's not loading anything. The only things I see in /usr/lib/debug/usr/bin are:

total 64
drwxr-xr-x. 1 root root   304 Jan 17 08:31 .
drwxr-xr-x. 1 root root    38 Dec  8 16:00 ..
-r--r--r--. 1 root root 15624 Dec  8 16:00 python3.13-3.13.1-2.fc41.x86_64.debug
-r--r--r--. 1 root root 15344 Dec  8 16:00 python3.13d-3.13.1-2.fc41.x86_64.debug
-r--r--r--. 1 root root 15632 Dec  8 16:00 python3.13t-3.13.1-2.fc41.x86_64.debug
-r--r--r--. 1 root root 15360 Dec  8 16:00 python3.13td-3.13.1-2.fc41.x86_64.debug
If I create a symlink like this:

lrwxrwxrwx. 1 root root    64 Apr 14 11:05 python3.13d-gdb.py -> ../lib64/libpython3.13d.so.1.0-3.13.1-2.fc41.x86_64.debug-gdb.py
everything loads correctly and I have all of the Python GDB scripts.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to communicate between scripts in python via shared file? daiboonchu 4 1,724 Dec-31-2024, 01:56 PM
Last Post: Pedroski55
  Trying to us python.exe from our network to run scripts cubangt 3 1,987 Aug-17-2023, 07:53 PM
Last Post: deanhystad
  Running python scripts from github etc pacmyc 7 5,109 Mar-03-2021, 10:26 PM
Last Post: pacmyc
  Reading SQL scripts from excel file and run it using python saravanatn 2 4,651 Aug-23-2020, 04:49 PM
Last Post: saravanatn
  No Scripts File present after python installation ag2207 5 7,644 Jul-30-2020, 11:11 AM
Last Post: buran
  How to merge my two python scripts in one ? HK2432 0 2,694 Jan-31-2020, 10:16 PM
Last Post: HK2432
  How can I Open and close .py file from python scripts SayHiii 9 7,802 Dec-17-2019, 06:10 AM
Last Post: Malt
  autostart python scripts in background (Windows10) john36 4 9,823 Oct-01-2019, 01:36 PM
Last Post: john36
  Run macros of excel sheet from python scripts shubhamjainj 3 13,015 May-01-2019, 08:40 AM
Last Post: buran
  Possible to run Python scripts from oracle? dglass 8 12,172 Sep-06-2018, 05:14 PM
Last Post: dglass

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020