As I've been setting my laptop and learning Solus 4.1, I've come to some milestones which might come in handy for others trying to set up a good debugging system. Here it is, from fresh install of Solus4.1 to working GDB10.1 + Python3.9!
#Install development tools
sudo eopkg install -c system.devel
#set up .profile like this:
source /usr/share/defaults/etc/profile
#adding variables to PATH
PATH=$HOME/.local/bin:$PATH;
#Python variables
PATH=$HOME/Applications/Python-3.9.1/out/bin:$PATH;
LD_LIBRARY_PATH=$HOME/Applications/Python-3.9.1/out/lib:$LD_LIBRARY_PATH;
alias python=/home/jeremi-solus/Applications/Python-3.9.1/out/bin/python3.9
export PATH
export LD_LIBRARY_PATH
#remaining .profile
#set up .bashrc like this
#import profile data if exists
if [ -f "$HOME/.profile" ]; then
source "$HOME/.profile"
#else load default profile environment variables
else
source /usr/share/defaults/etc/profile
fi
#remaining .bashrc
#compile Python (debug build + dev (--enable-shared is equivalent to python3-dev)) (create the "out" directory first - then run both commands from it)
../configure --with-pydebug --with-lto --enable-optimizations --prefix=/home/jeremi-solus/Applications/Python-3.9.1/out --exec-prefix=/home/jeremi-solus/Applications/Python-3.9.1/out --enable-shared
make altinstall
#after compiling Python, you can start compiling GDB. set these flags before running the "configure" command (before compiling)
export CFLAGS="-I/home/jeremi-solus/Applications/Python-3.9.1/out/include/python3.9d -I/home/jeremi-solus/Applications/Python-3.9.1/out/include/python3.9d"
export LDFLAGS="-L/home/jeremi-solus/Applications/Python-3.9.1/out/lib -lcrypt -lpthread -ldl -lutil -lm"
export LIBS="-lcrypt -lpthread -ldl -lutil -lm"
#note down the path to compiled Python binary. You need to pass this path to GDB configure script
/home/jeremi-solus/Applications/Python-3.9.1/out/bin/python3.9
#run configure script like this - make sure you don't close the bash shell after exporting the earlier set values!! Also, make sure earlier set .profile vars are set by running "source ~/.bashrc"
./configure --prefix=/home/jeremi-solus/Applications/gdb-10.1/out --exec-prefix=/home/jeremi-solus/Applications/gdb-10.1/out --enable-lto --with-python=/home/jeremi-solus/Applications/Python-3.9.1/out/bin/python3.9
#make GDB (run this from the out directory)
make
#start GDB with this command
./gdb -data-directory ./data-directory