Update gdbinit
fix wrong path of libstdcxx python script
If the version number of gcc was updated, but this script was not update the variable of %GCC_NAME% which will lead an error of missing libstdcxx module
This update use python script to search the real path of the gcc folder and insert it into the sys.path variable
Sounds good. One thing I noticed is that have multiple dirs left because of python cache files (we should try fix this with the next gcc update).
$ echo /usr/share/gcc*
/usr/share/gcc-11.3.0 /usr/share/gcc-13.2.0 /usr/share/gcc-13.3.0
A hacky workaround is to sort the dirs, which is a good idea anyway since listdir order isn't stable.
What about:
import sys
import glob
python_dirs = sorted(glob.glob("/usr/share/gcc*/python"), reverse=True)
sys.path.insert(0, (python_dirs or [sys.path[0])[0])
Or we add a big warning to the gcc build file that gdb needs to be rebuilt on version changes.
I've created https://github.com/msys2/MSYS2-packages/pull/4748 as an alternative
@lazka
Sounds good. One thing I noticed is that have multiple dirs left because of python cache files (we should try fix this with the next gcc update).
$ echo /usr/share/gcc* /usr/share/gcc-11.3.0 /usr/share/gcc-13.2.0 /usr/share/gcc-13.3.0A hacky workaround is to sort the dirs, which is a good idea anyway since listdir order isn't stable.
What about:
import sys import glob python_dirs = sorted(glob.glob("/usr/share/gcc*/python"), reverse=True) sys.path.insert(0, (python_dirs or [sys.path[0])[0])
This may be a good idea. Some newbies like me are always confused about the prompt, and don't know how to deal with this, we added this method to provide a way for newbies to easily use it.
> import sys
> import glob
> python_dirs = sorted(glob.glob("/usr/share/gcc*/python"), reverse=True)
> sys.path.insert(0, (python_dirs or sys.path)[0])