From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9487 invoked by alias); 29 Nov 2010 00:40:00 -0000 Received: (qmail 9477 invoked by uid 22791); 29 Nov 2010 00:39:59 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 29 Nov 2010 00:39:52 +0000 Received: from wpaz13.hot.corp.google.com (wpaz13.hot.corp.google.com [172.24.198.77]) by smtp-out.google.com with ESMTP id oAT0doJU006788 for ; Sun, 28 Nov 2010 16:39:50 -0800 Received: from ruffy.mtv.corp.google.com (ruffy.mtv.corp.google.com [172.18.118.116]) by wpaz13.hot.corp.google.com with ESMTP id oAT0dnp2030042 for ; Sun, 28 Nov 2010 16:39:49 -0800 Received: by ruffy.mtv.corp.google.com (Postfix, from userid 67641) id 502FC246199; Sun, 28 Nov 2010 16:39:49 -0800 (PST) To: gdb-patches@sourceware.org Subject: [RFA] Don't install gdb.PYTHONDIR if -nx Message-Id: <20101129003949.502FC246199@ruffy.mtv.corp.google.com> Date: Mon, 29 Nov 2010 00:40:00 -0000 From: dje@google.com (Doug Evans) X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-11/txt/msg00476.txt.bz2 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 * 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); }