Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Don't install gdb.PYTHONDIR if -nx
@ 2010-11-29  0:40 Doug Evans
  2010-11-29 21:38 ` Tom Tromey
  2010-11-30  4:22 ` [RFA] " Daniel Jacobowitz
  0 siblings, 2 replies; 23+ messages in thread
From: Doug Evans @ 2010-11-29  0:40 UTC (permalink / raw)
  To: gdb-patches

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);
 }
 


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2010-12-07  4:02 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-29  0:40 [RFA] Don't install gdb.PYTHONDIR if -nx Doug Evans
2010-11-29 21:38 ` Tom Tromey
2010-11-30  0:03   ` [RFA, doc RFA] " Doug Evans
2010-11-30  0:30     ` Jan Kratochvil
2010-11-30  3:54     ` Eli Zaretskii
2010-11-30  4:11       ` Doug Evans
2010-11-30 11:20         ` Eli Zaretskii
2010-11-30 15:29           ` Doug Evans
2010-11-30 18:59             ` Tom Tromey
2010-12-06 20:43               ` Doug Evans
2010-12-06 20:50                 ` Eli Zaretskii
2010-12-06 20:58                   ` Doug Evans
2010-12-06 21:15                     ` Eli Zaretskii
2010-12-06 21:16                       ` Doug Evans
2010-12-06 22:17                         ` Doug Evans
2010-12-07  4:02                           ` Eli Zaretskii
2010-12-06 21:15                     ` Doug Evans
2010-12-07  1:38                 ` Jan Kratochvil
2010-11-30  4:22 ` [RFA] " Daniel Jacobowitz
2010-11-30  5:16   ` Doug Evans
2010-11-30 18:19     ` Daniel Jacobowitz
2010-11-30 18:25       ` Doug Evans
2010-11-30  5:33   ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox