Re: [RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx

Doug Evans
2010-11-30T04:11:21Z

[-- Attachment #1: Type: text/plain, Size: 821 bytes --]

On Mon, Nov 29, 2010 at 7:54 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Mon, 29 Nov 2010 16:03:02 -0800
>> From: Doug Evans <dje@google.com>
>> Cc: gdb-patches@sourceware.org
>>
>> I will check this in then, pending doc RFA.
>
> OK.  Do we want this to be mentioned in NEWS?
>
> Thanks.

Probably. :-)

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

PR python/12227
* NEWS: Mention -np
* main.c (captured_main): Recognize -np.
* top.c (inhibit_pythoninit): New global.
* top.h (inhibit_pythoninit): Declare.
* python/python.c (finish_python_initialization): Only initialize
gdb module if not -np.

doc/
* gdb.texinfo (Mode Options): Document -np.

testsuite/
* lib/gdb.exp: Add -np to INTERNAL_GDBFLAGS.

[-- Attachment #2: gdb-101129-pr-12227-2.patch.txt --]
[-- Type: text/plain, Size: 4889 bytes --]

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

PR python/12227
* NEWS: Mention -np
* main.c (captured_main): Recognize -np.
* top.c (inhibit_pythoninit): New global.
* top.h (inhibit_pythoninit): Declare.
* python/python.c (finish_python_initialization): Only initialize
gdb module if not -np.

doc/
* gdb.texinfo (Mode Options): Document -np.

testsuite/
* lib/gdb.exp: Add -np to INTERNAL_GDBFLAGS.

Index: NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.411
diff -u -p -r1.411 NEWS
--- NEWS 5 Nov 2010 16:55:37 -0000 1.411
+++ NEWS 30 Nov 2010 04:09:31 -0000
@@ -3,6 +3,10 @@

*** Changes since GDB 7.2

+* New command line options
+
+-np Do not initialize the gdb python module.
+
* GDB has a new command: "set directories".
It is like the "dir" command except that it replaces the
source path list instead of augmenting it.
Index: main.c
===================================================================
RCS file: /cvs/src/src/gdb/main.c,v
retrieving revision 1.87
diff -u -p -r1.87 main.c
--- main.c 22 Sep 2010 19:59:15 -0000 1.87
+++ main.c 29 Nov 2010 23:49:58 -0000
@@ -396,6 +396,7 @@ captured_main (void *data)
{"silent", no_argument, &quiet, 1},
{"nx", no_argument, &inhibit_gdbinit, 1},
{"n", no_argument, &inhibit_gdbinit, 1},
+ {"np", no_argument, &inhibit_pythoninit, 1},
{"batch-silent", no_argument, 0, 'B'},
{"batch", no_argument, &batch_flag, 1},
{"epoch", no_argument, &epoch_interface, 1},
Index: top.c
===================================================================
RCS file: /cvs/src/src/gdb/top.c,v
retrieving revision 1.185
diff -u -p -r1.185 top.c
--- top.c 2 Nov 2010 16:48:41 -0000 1.185
+++ top.c 29 Nov 2010 23:49:58 -0000
@@ -88,6 +88,9 @@ char gdbinit[PATH_MAX + 1] = GDBINIT_FIL

int inhibit_gdbinit = 0;

+/* If nonzero, don't load any initial python scripts. */
+int inhibit_pythoninit = 0;
+
/* If nonzero, and GDB has been configured to be able to use windows,
attempt to open them upon startup. */

Index: top.h
===================================================================
RCS file: /cvs/src/src/gdb/top.h,v
retrieving revision 1.22
diff -u -p -r1.22 top.h
--- top.h 7 Apr 2010 16:54:39 -0000 1.22
+++ top.h 29 Nov 2010 23:49:58 -0000
@@ -30,6 +30,7 @@ extern int in_user_command;
extern int caution;
extern char gdb_dirbuf[1024];
extern int inhibit_gdbinit;
+extern int inhibit_pythoninit;
extern int epoch_interface;
extern char gdbinit[];

Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.778
diff -u -p -r1.778 gdb.texinfo
--- doc/gdb.texinfo 29 Nov 2010 23:20:57 -0000 1.778
+++ doc/gdb.texinfo 29 Nov 2010 23:49:58 -0000
@@ -1025,6 +1025,14 @@ Do not execute commands found in any ini
options and arguments have been processed. @xref{Command Files,,Command
Files}.

+@item -np
+@cindex @code{--np}
+Do not initialize the @code{gdb} python module.
+Normally @value{GDBN}, as part of initialization, will initialize
+the @code{gdb} python module. @xref{Python API}.
+This interferes with, for example, running the GDB testsuite which
+wants to use its own copy.
+
@item -quiet
@itemx -silent
@itemx -q
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 23:49:58 -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 -np.
+ We don't want to pick up, for example, python-based commands from the
+ install directory when running the testsuite. */
+ if (! inhibit_pythoninit)
+ /* Install the default gdb.PYTHONDIR. */
+ PyRun_SimpleString ("GdbSetPythonDirectory (gdb.PYTHONDIR)");
+
do_cleanups (cleanup);
}

Index: testsuite/lib/gdb.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v
retrieving revision 1.159
diff -u -p -r1.159 gdb.exp
--- testsuite/lib/gdb.exp 23 Nov 2010 22:25:37 -0000 1.159
+++ testsuite/lib/gdb.exp 29 Nov 2010 23:49:58 -0000
@@ -56,7 +56,7 @@ verbose "using GDBFLAGS = $GDBFLAGS" 2
# INTERNAL_GDBFLAGS contains flags that the testsuite requires.
global INTERNAL_GDBFLAGS
if ![info exists INTERNAL_GDBFLAGS] {
- set INTERNAL_GDBFLAGS "-nw -nx"
+ set INTERNAL_GDBFLAGS "-nw -nx -np"
}

# The variable gdb_prompt is a regexp which matches the gdb prompt.