Different, but similar problem: I tell everyone that in their home directory "~/.gdbinit" file they must load one common python module via an absolute path.
This is exactly one line, not something complicated.
You should note: Some would call this a security threat, It is a balancing act - I have to trust my team, they have to trust me. I think of it this way: we all work with sharp-pointy things, we must be knowledgeable of what we are doing. Every team is unique, use your judgement.
I also have to deal with multiple versions of GDB but a common single .gdbinit file. Example; AndroidOLD(GDB), AndroidNEW(GDB), LinuxHost(GDB), and SomeOther(GDB)
People switch between projects using different things through out the day, common script directory problem. And I have my own scripts in my home directory
I depend upon GDB-Python extensions
import os
import gdb
On Linux, I can determine the exact version of GDB by looking at the absolute path to the executable hence: AndroidOLD(gdb) vrs AndroidNEW(gdb) can be determined by looking for a version number in the path.
exename = os.readlink( '/proc/self/exe' )
I can also use these items to determine the host type(cygwin, linux, mac, etc), and more details about the target architecture (ie: Which android cpu target?)
print (gdb.HOST_CONFIG)
# gives: x86_64-linux-gnu
# Alternates: MACOS, or CYGWIN32 or CYGWIN64
print (gdb.TARGET_CONFIG)
# Gives: 64bit android, 32bit android, or something else
Now, more to the original posters question: A common directory with lots of scripts
- I have multiple "common directories"
- And I have to deal with different architectures
- And my people switch between projects
- And switch between versions
Some project systems have a common root directory (ie: Android) for the project or module, and all sub components are sub directories of that common directory. Using python - you can start with the current directory, then climb up the directory tree one at a time until you find some magic file that tells you more (for example some file that identifies the root directory of an android build)
now that I know all of that, I can iterate over the files I need to load via:
import gdb
gdb.execute('source %s' % filename)
Problem solved.