This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] Don't install gdb.PYTHONDIR if -nx


Hi.

I was testing a change to gdb/command/pretty_printers.py
and was tripping over the fact that gdb was picking up
the installed copies.
The testsuite loads the copies from the build dir, but
python keeps the one already installed during gdb startup.

This patch only installs gdb.PYTHONDIR (and only runs
gdb/__init__.py which installs the python-based gdb commands)
if not running with -nx.

I don't entirely like the patch, it's extending -nx into
new territory, e.g., -nx controlling whether certain commands
are available or not.  It shouldn't matter, from the user's
perspective, whether the commands are implemented in python.

However, the only other alternative I can think of is to
add a new option, and I'm guessing that's unacceptable.

Ok to check in?
Or would a new option be preferable?
E.g., -np to disable loading of python code, or some such.

2010-11-28  Doug Evans  <dje@google.com>

	* python/python.c (finish_python_initialization): Don't install
	gdb.PYTHONDIR (or run gdb/__init__.py) if running -nx.

Index: python/python.c
===================================================================
RCS file: /cvs/src/src/gdb/python/python.c,v
retrieving revision 1.53
diff -u -p -r1.53 python.c
--- python/python.c	12 Nov 2010 20:49:42 -0000	1.53
+++ python/python.c	29 Nov 2010 00:08:56 -0000
@@ -1080,11 +1080,15 @@ def GdbSetPythonDirectory (dir):\n\
   ipy = gdb.PYTHONDIR + '/gdb/__init__.py'\n\
   if os.path.exists (ipy):\n\
     execfile (ipy)\n\
-\n\
-# Install the default gdb.PYTHONDIR.\n\
-GdbSetPythonDirectory (gdb.PYTHONDIR)\n\
 ");
 
+  /* Don't install the python directory if -nx.
+     We don't want to pick up, for example, python-based commands from the
+     install directory when running the testsuite.  */
+  if (! inhibit_gdbinit)
+    /* Install the default gdb.PYTHONDIR.  */
+    PyRun_SimpleString ("GdbSetPythonDirectory (gdb.PYTHONDIR)");
+
   do_cleanups (cleanup);
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]