[RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx
Doug Evans
dje@google.com
Tue Nov 30 00:03:00 GMT 2010
On Mon, Nov 29, 2010 at 1:38 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Doug" == Doug Evans <dje@google.com> writes:
>
> Doug> I don't entirely like the patch, it's extending -nx into
> Doug> new territory, e.g., -nx controlling whether certain commands
> Doug> are available or not. It shouldn't matter, from the user's
> Doug> perspective, whether the commands are implemented in python.
>
> I agree. In particular I think it is reasonable to want to use python
> commands from a batch script, but such a script is likely to use -nx.
>
> Doug> However, the only other alternative I can think of is to
> Doug> add a new option, and I'm guessing that's unacceptable.
>
> I think it would be fine to add one.
>
>
> Either way I think the documentation needs to be updated.
>
> Jan pointed out that this is PR 12227.
>
> Tom
>
I will check this in then, pending doc RFA.
2010-11-29 Doug Evans <dje@google.com>
PR python/12227
* 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.
-------------- next part --------------
2010-11-29 Doug Evans <dje@google.com>
PR python/12227
* 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: 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.
More information about the Gdb-patches
mailing list