This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 2/2] Add gdb_libdir/python-<version> in front of Python search path.
- From: Joel Brobecker <brobecker at adacore dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 20 May 2010 11:40:03 -0700
- Subject: [PATCH 2/2] Add gdb_libdir/python-<version> in front of Python search path.
- References: <1274380803-25266-1-git-send-email-brobecker@adacore.com>
This patch puts gdb_libdir/python-<version> at the beginning of
the python search path. This allows GDB to use its own copy/version
of the Python library.
2010-05-20 Joel Brobecker <brobecker@adacore.com>
* python.c (_initialize_python): Add variable libdir in gdb module.
Insert gdb_libdir/python-<version> at head of python search path.
Tested on x86_64-linux. No regression.
---
gdb/python/python.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 3110328..fa76838 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -654,6 +654,7 @@ Enables or disables printing of Python stack traces."),
PyModule_AddStringConstant (gdb_module, "VERSION", (char*) version);
PyModule_AddStringConstant (gdb_module, "HOST_CONFIG", (char*) host_name);
PyModule_AddStringConstant (gdb_module, "TARGET_CONFIG", (char*) target_name);
+ PyModule_AddStringConstant (gdb_module, "libdir", (char*) gdb_libdir);
gdbpy_initialize_auto_load ();
gdbpy_initialize_values ();
@@ -702,6 +703,11 @@ class GdbOutputFile:\n\
\n\
sys.stderr = GdbOutputFile()\n\
sys.stdout = GdbOutputFile()\n\
+\n\
+# Put gdb_libdir/python-<version> in the python search path. This allows\n\
+# us to provide GDB bundled with its own python runtime (the .py/pyc files).\n\
+sys.path.insert(0, gdb.libdir + \"/python-%d.%d\" % (sys.version_info[0],\n\
+ sys.version_info[1]))\n\
");
/* Release the GIL while gdb runs. */
--
1.7.1