Add LIBDIR/gdb/python- to Python search path

Joel Brobecker
2010-05-20T18:40:17Z

Hello,

I wrote the following two patches in order to allow GDB's python
interpreter to import the modules provided by the python library
from a location that's relative to GDB itself.

The intent is to allow us to package up a GDB binary with python support.
Since we do not know whether the target system on which GDB is going to
be installed has the correct version of python (or even if it has, whether
it has been built correctly), we want to also package up the python
library as well. That way, regardless of what the target system provides,
we know the debugger will be using a well-defined version of the python
library.

The location I chose for that is GDB_LIBDIR/python-<version>, where
GDB_LIBDIR is LIBDIR/gdb by default. So, for instance, with a prefix
set to /my/prefix/dir, a default GDB_LIDIR, and Python version 2.5,
we'd be using: /my/prefix/dir/lib/gdb/python-2.5.

So the first patch introduces --with-gdb-libdir as a new command-line
configure switch. This allows us to change GDB_LIBDIR to something
different.

The second patch makes use of this new variable by adding the python
lib dir at the start of the python search path. We can possibly
make it more configurable for the user by allowing him to override
the path to the python library (Eg: --with-gdb-libpythondir), but
I don't think that this is going to bring much.

Any thoughts on the approach? Obviously, this also needs documentation,
but I'd rather have the go-ahead before I start documenting the new
switch...

Thanks,
--
Joel