* [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* Re: [RFA] Don't install gdb.PYTHONDIR if -nx 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 4:22 ` [RFA] " Daniel Jacobowitz 1 sibling, 1 reply; 23+ messages in thread From: Tom Tromey @ 2010-11-29 21:38 UTC (permalink / raw) To: Doug Evans; +Cc: gdb-patches >>>>> "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 ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx 2010-11-29 21:38 ` Tom Tromey @ 2010-11-30 0:03 ` Doug Evans 2010-11-30 0:30 ` Jan Kratochvil 2010-11-30 3:54 ` Eli Zaretskii 0 siblings, 2 replies; 23+ messages in thread From: Doug Evans @ 2010-11-30 0:03 UTC (permalink / raw) To: Tom Tromey, Eli Zaretskii; +Cc: gdb-patches [-- Attachment #1: Type: text/plain, Size: 1376 bytes --] 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. [-- Attachment #2: gdb-101129-pr-12227-1.patch.txt --] [-- Type: text/plain, Size: 4350 bytes --] 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. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx 2010-11-30 0:03 ` [RFA, doc RFA] " Doug Evans @ 2010-11-30 0:30 ` Jan Kratochvil 2010-11-30 3:54 ` Eli Zaretskii 1 sibling, 0 replies; 23+ messages in thread From: Jan Kratochvil @ 2010-11-30 0:30 UTC (permalink / raw) To: Doug Evans; +Cc: Tom Tromey, Eli Zaretskii, gdb-patches On Tue, 30 Nov 2010 01:03:02 +0100, Doug Evans wrote: > On Mon, Nov 29, 2010 at 1:38 PM, Tom Tromey <tromey@redhat.com> wrote: > >>>>>> "Doug" == Doug Evans <dje@google.com> writes: > > Jan pointed out that this is PR 12227. > > I will check this in then, BTW it really fixes all the issues I had in that PR python/12227. Thanks, Jan ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx 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 1 sibling, 1 reply; 23+ messages in thread From: Eli Zaretskii @ 2010-11-30 3:54 UTC (permalink / raw) To: Doug Evans; +Cc: tromey, gdb-patches > 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. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx 2010-11-30 3:54 ` Eli Zaretskii @ 2010-11-30 4:11 ` Doug Evans 2010-11-30 11:20 ` Eli Zaretskii 0 siblings, 1 reply; 23+ messages in thread From: Doug Evans @ 2010-11-30 4:11 UTC (permalink / raw) To: Eli Zaretskii; +Cc: tromey, gdb-patches [-- 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. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx 2010-11-30 4:11 ` Doug Evans @ 2010-11-30 11:20 ` Eli Zaretskii 2010-11-30 15:29 ` Doug Evans 0 siblings, 1 reply; 23+ messages in thread From: Eli Zaretskii @ 2010-11-30 11:20 UTC (permalink / raw) To: Doug Evans; +Cc: tromey, gdb-patches > Date: Mon, 29 Nov 2010 20:11:07 -0800 > From: Doug Evans <dje@google.com> > Cc: tromey@redhat.com, gdb-patches@sourceware.org > > --- 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. > + Thanks, this is fine. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx 2010-11-30 11:20 ` Eli Zaretskii @ 2010-11-30 15:29 ` Doug Evans 2010-11-30 18:59 ` Tom Tromey 0 siblings, 1 reply; 23+ messages in thread From: Doug Evans @ 2010-11-30 15:29 UTC (permalink / raw) To: Eli Zaretskii; +Cc: tromey, gdb-patches On Tue, Nov 30, 2010 at 3:20 AM, Eli Zaretskii <eliz@gnu.org> wrote: >> Date: Mon, 29 Nov 2010 20:11:07 -0800 >> From: Doug Evans <dje@google.com> >> Cc: tromey@redhat.com, gdb-patches@sourceware.org >> >> --- 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. >> + > > Thanks, this is fine. Thanks. I think we're now blocked on whether we want "-np" or "-data-directory /foo" (or some such). I don't have a strong opinion on either, I like both. [For reference sake, I've been thinking it would be useful to have an option to turn off auto-loading of scripts specified in binaries. But that's a different patch. :-)] ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx 2010-11-30 15:29 ` Doug Evans @ 2010-11-30 18:59 ` Tom Tromey 2010-12-06 20:43 ` Doug Evans 0 siblings, 1 reply; 23+ messages in thread From: Tom Tromey @ 2010-11-30 18:59 UTC (permalink / raw) To: Doug Evans; +Cc: Eli Zaretskii, gdb-patches >>>>> "Doug" == Doug Evans <dje@google.com> writes: Doug> I think we're now blocked on whether we want "-np" or "-data-directory Doug> /foo" (or some such). -np is fine with me, and we have the patch for that already. Doug> [For reference sake, I've been thinking it would be useful to have an Doug> option to turn off auto-loading of scripts specified in binaries. Doug> But that's a different patch. :-)] Yeah, that sounds reasonable to me too. It is important to make it easy for users to stop gdb from loading possibly-untrusted code. Tom ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx 2010-11-30 18:59 ` Tom Tromey @ 2010-12-06 20:43 ` Doug Evans 2010-12-06 20:50 ` Eli Zaretskii 2010-12-07 1:38 ` Jan Kratochvil 0 siblings, 2 replies; 23+ messages in thread From: Doug Evans @ 2010-12-06 20:43 UTC (permalink / raw) To: Eli Zaretskii, Jan Kratochvil; +Cc: gdb-patches [-- Attachment #1: Type: text/plain, Size: 691 bytes --] Here's a patch for -data-directory. Tested on amd64-linux, no regressions. Eli, can I have a doc RFA. Jan, can you test this to make sure it solves pr 12227 for you. 2010-12-06 Doug Evans <dje@google.com> PR python/12227 * NEWS: Mention -data-directory. * main.c (captured_main): Recognize -data-directory. doc/ * gdb.texinfo (Mode Options): Document -data-directory. testsuite/ * gdb.base/catch-syscall.exp (do_syscall_tests): Remove setting of data-directory. * lib/gdb-python.exp (gdb_check_python_config): Delete, all callers updated. * lib/gdb.exp (INTERNAL_GDBFLAGS): Add -data-directory. [-- Attachment #2: gdb-101206-pr-12227-3.patch.txt --] [-- Type: text/plain, Size: 6505 bytes --] 2010-12-06 Doug Evans <dje@google.com> PR python/12227 * NEWS: Mention -data-directory. * main.c (captured_main): Recognize -data-directory. doc/ * gdb.texinfo (Mode Options): Document -data-directory. testsuite/ * gdb.base/catch-syscall.exp (do_syscall_tests): Remove setting of data-directory. * lib/gdb-python.exp (gdb_check_python_config): Delete, all callers updated. * lib/gdb.exp (INTERNAL_GDBFLAGS): Add -data-directory. Index: NEWS =================================================================== RCS file: /cvs/src/src/gdb/NEWS,v retrieving revision 1.412 diff -u -p -r1.412 NEWS --- NEWS 1 Dec 2010 16:49:41 -0000 1.412 +++ NEWS 6 Dec 2010 20:23:28 -0000 @@ -3,6 +3,10 @@ *** Changes since GDB 7.2 +* New command line options + +-data-directory DIR Specify DIR as the "data-directory". + * 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 6 Dec 2010 20:23:29 -0000 @@ -432,6 +432,7 @@ captured_main (void *data) {"i", required_argument, 0, 'i'}, {"directory", required_argument, 0, 'd'}, {"d", required_argument, 0, 'd'}, + {"data-directory", required_argument, 0, 'D'}, {"cd", required_argument, 0, OPT_CD}, {"tty", required_argument, 0, 't'}, {"baud", required_argument, 0, 'b'}, @@ -551,6 +552,10 @@ captured_main (void *data) batch_flag = batch_silent = 1; gdb_stdout = ui_file_new(); break; + case 'D': + xfree (gdb_datadir); + gdb_datadir = xstrdup (optarg); + break; #ifdef GDBTK case 'z': { 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 6 Dec 2010 20:23:29 -0000 @@ -1111,6 +1111,12 @@ used if possible. Run @value{GDBN} using @var{directory} as its working directory, instead of the current directory. +@item -data-directory @var{directory} +@cindex @code{--data-directory} +Run @value{GDBN} using @var{directory} as its data-directory. +The data-directory is where @value{GDBN} searches for its +auxiliary files. + @item -fullname @itemx -f @cindex @code{--fullname} Index: testsuite/gdb.base/catch-syscall.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/catch-syscall.exp,v retrieving revision 1.9 diff -u -p -r1.9 catch-syscall.exp --- testsuite/gdb.base/catch-syscall.exp 6 Oct 2010 16:02:45 -0000 1.9 +++ testsuite/gdb.base/catch-syscall.exp 6 Dec 2010 20:23:29 -0000 @@ -277,8 +277,8 @@ proc test_catch_syscall_fail_nodatadir { proc do_syscall_tests {} { global gdb_prompt srcdir - # First, we need to set GDB datadir. - gdb_test_no_output "set data-directory [pwd]/../data-directory" + # NOTE: We don't have to point gdb at the correct data-directory. + # For the build tree that is handled by INTERNAL_GDBFLAGS. # Verify that the 'catch syscall' help is available set thistest "help catch syscall" Index: testsuite/gdb.python/lib-types.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.python/lib-types.exp,v retrieving revision 1.1 diff -u -p -r1.1 lib-types.exp --- testsuite/gdb.python/lib-types.exp 13 Oct 2010 20:08:45 -0000 1.1 +++ testsuite/gdb.python/lib-types.exp 6 Dec 2010 20:23:29 -0000 @@ -44,9 +44,6 @@ if ![runto_main] then { return 0 } -# Ensure sys.path, et.al. are initialized properly. -gdb_check_python_config - gdb_test_no_output "python import gdb.types" # test get_basic_type const stripping Index: testsuite/gdb.python/py-pp-maint.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.python/py-pp-maint.exp,v retrieving revision 1.2 diff -u -p -r1.2 py-pp-maint.exp --- testsuite/gdb.python/py-pp-maint.exp 29 Nov 2010 23:20:58 -0000 1.2 +++ testsuite/gdb.python/py-pp-maint.exp 6 Dec 2010 20:23:29 -0000 @@ -51,9 +51,6 @@ if ![runto_main ] then { return -1 } -# Ensure sys.path, et.al. are initialized properly. -gdb_check_python_config - gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \ ".*Breakpoint.*" gdb_test "continue" ".*Breakpoint.*" Index: testsuite/lib/gdb-python.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/lib/gdb-python.exp,v retrieving revision 1.2 diff -u -p -r1.2 gdb-python.exp --- testsuite/lib/gdb-python.exp 13 Oct 2010 20:08:45 -0000 1.2 +++ testsuite/lib/gdb-python.exp 6 Dec 2010 20:23:29 -0000 @@ -45,21 +45,3 @@ proc gdb_py_test_multiple { name args } } return 0 } - -# Establish various python configuration parameters if necessary. -# E.g. sys.path. - -proc gdb_check_python_config { } { - global USE_INSTALLED_TREE - # If we're running an installed version of gdb, and we want to test the - # installed versions of the python support scripts, then we don't want - # to point data-directory at the build tree. - if { [info exists USE_INSTALLED_TREE] && "$USE_INSTALLED_TREE" == "yes" } { - verbose -log "Assuming system config already installed." - } else { - verbose -log "Installing system config from build tree." - set gdb_data_dir "[pwd]/../data-directory" - gdb_test_no_output "set data-directory $gdb_data_dir" - gdb_test_no_output "python GdbSetPythonDirectory ('$gdb_data_dir/python')" - } -} Index: testsuite/lib/gdb.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v retrieving revision 1.160 diff -u -p -r1.160 gdb.exp --- testsuite/lib/gdb.exp 30 Nov 2010 17:41:14 -0000 1.160 +++ testsuite/lib/gdb.exp 6 Dec 2010 20:23:29 -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 -data-directory [pwd]/../data-directory" } # The variable gdb_prompt is a regexp which matches the gdb prompt. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx 2010-12-06 20:43 ` Doug Evans @ 2010-12-06 20:50 ` Eli Zaretskii 2010-12-06 20:58 ` Doug Evans 2010-12-07 1:38 ` Jan Kratochvil 1 sibling, 1 reply; 23+ messages in thread From: Eli Zaretskii @ 2010-12-06 20:50 UTC (permalink / raw) To: Doug Evans; +Cc: jan.kratochvil, gdb-patches > Date: Mon, 6 Dec 2010 12:43:02 -0800 > From: Doug Evans <dje@google.com> > Cc: gdb-patches@sourceware.org > > Eli, can I have a doc RFA. Sure. > +* New command line options > + > +-data-directory DIR Specify DIR as the "data-directory". > + How about saying what is this directory good for? > +@item -data-directory @var{directory} > +@cindex @code{--data-directory} > +Run @value{GDBN} using @var{directory} as its data-directory. > +The data-directory is where @value{GDBN} searches for its > +auxiliary files. Same here: what "auxiliary files" are those? Without knowing that, there's no chance users will benefit from this option. Thanks. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx 2010-12-06 20:50 ` Eli Zaretskii @ 2010-12-06 20:58 ` Doug Evans 2010-12-06 21:15 ` Doug Evans 2010-12-06 21:15 ` Eli Zaretskii 0 siblings, 2 replies; 23+ messages in thread From: Doug Evans @ 2010-12-06 20:58 UTC (permalink / raw) To: Eli Zaretskii; +Cc: jan.kratochvil, gdb-patches On Mon, Dec 6, 2010 at 12:50 PM, Eli Zaretskii <eliz@gnu.org> wrote: >> Date: Mon, 6 Dec 2010 12:43:02 -0800 >> From: Doug Evans <dje@google.com> >> Cc: gdb-patches@sourceware.org >> >> Eli, can I have a doc RFA. > > Sure. > >> +* New command line options >> + >> +-data-directory DIR Specify DIR as the "data-directory". >> + > > How about saying what is this directory good for? > >> +@item -data-directory @var{directory} >> +@cindex @code{--data-directory} >> +Run @value{GDBN} using @var{directory} as its data-directory. >> +The data-directory is where @value{GDBN} searches for its >> +auxiliary files. > > Same here: what "auxiliary files" are those? Without knowing that, > there's no chance users will benefit from this option. This is mostly just for testing, so I punted. But ok. Ideally I'd just include a reference to the docs for "set data-directory" or --with-gdb-datadir, but those don't say much either. Blech. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx 2010-12-06 20:58 ` Doug Evans @ 2010-12-06 21:15 ` Doug Evans 2010-12-06 21:15 ` Eli Zaretskii 1 sibling, 0 replies; 23+ messages in thread From: Doug Evans @ 2010-12-06 21:15 UTC (permalink / raw) To: Eli Zaretskii; +Cc: jan.kratochvil, gdb-patches Yay. How about just a ref to @node Data Files? On Mon, Dec 6, 2010 at 12:58 PM, Doug Evans <dje@google.com> wrote: > On Mon, Dec 6, 2010 at 12:50 PM, Eli Zaretskii <eliz@gnu.org> wrote: >>> Date: Mon, 6 Dec 2010 12:43:02 -0800 >>> From: Doug Evans <dje@google.com> >>> Cc: gdb-patches@sourceware.org >>> >>> Eli, can I have a doc RFA. >> >> Sure. >> >>> +* New command line options >>> + >>> +-data-directory DIR Specify DIR as the "data-directory". >>> + >> >> How about saying what is this directory good for? >> >>> +@item -data-directory @var{directory} >>> +@cindex @code{--data-directory} >>> +Run @value{GDBN} using @var{directory} as its data-directory. >>> +The data-directory is where @value{GDBN} searches for its >>> +auxiliary files. >> >> Same here: what "auxiliary files" are those? Without knowing that, >> there's no chance users will benefit from this option. > > This is mostly just for testing, so I punted. > But ok. Ideally I'd just include a reference to the docs for "set > data-directory" or --with-gdb-datadir, but those don't say much > either. Blech. > ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx 2010-12-06 20:58 ` Doug Evans 2010-12-06 21:15 ` Doug Evans @ 2010-12-06 21:15 ` Eli Zaretskii 2010-12-06 21:16 ` Doug Evans 1 sibling, 1 reply; 23+ messages in thread From: Eli Zaretskii @ 2010-12-06 21:15 UTC (permalink / raw) To: Doug Evans; +Cc: jan.kratochvil, gdb-patches > Date: Mon, 6 Dec 2010 12:58:27 -0800 > From: Doug Evans <dje@google.com> > Cc: jan.kratochvil@redhat.com, gdb-patches@sourceware.org > > This is mostly just for testing, so I punted. If it's only for testing, do we need to document it in the manual? Or maybe just say "for testing GDB using its test suite", and be done. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx 2010-12-06 21:15 ` Eli Zaretskii @ 2010-12-06 21:16 ` Doug Evans 2010-12-06 22:17 ` Doug Evans 0 siblings, 1 reply; 23+ messages in thread From: Doug Evans @ 2010-12-06 21:16 UTC (permalink / raw) To: Eli Zaretskii; +Cc: jan.kratochvil, gdb-patches On Mon, Dec 6, 2010 at 1:15 PM, Eli Zaretskii <eliz@gnu.org> wrote: >> Date: Mon, 6 Dec 2010 12:58:27 -0800 >> From: Doug Evans <dje@google.com> >> Cc: jan.kratochvil@redhat.com, gdb-patches@sourceware.org >> >> This is mostly just for testing, so I punted. > > If it's only for testing, do we need to document it in the manual? Or > maybe just say "for testing GDB using its test suite", and be done. Well, there's a difference b/w "mostly" and "only". :-) But I think a ref to node Data Files should be sufficient. Whaddayathink? ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx 2010-12-06 21:16 ` Doug Evans @ 2010-12-06 22:17 ` Doug Evans 2010-12-07 4:02 ` Eli Zaretskii 0 siblings, 1 reply; 23+ messages in thread From: Doug Evans @ 2010-12-06 22:17 UTC (permalink / raw) To: Eli Zaretskii; +Cc: jan.kratochvil, gdb-patches On Mon, Dec 6, 2010 at 1:16 PM, Doug Evans <dje@google.com> wrote: > On Mon, Dec 6, 2010 at 1:15 PM, Eli Zaretskii <eliz@gnu.org> wrote: >>> Date: Mon, 6 Dec 2010 12:58:27 -0800 >>> From: Doug Evans <dje@google.com> >>> Cc: jan.kratochvil@redhat.com, gdb-patches@sourceware.org >>> >>> This is mostly just for testing, so I punted. >> >> If it's only for testing, do we need to document it in the manual? Or >> maybe just say "for testing GDB using its test suite", and be done. > > Well, there's a difference b/w "mostly" and "only". :-) > > But I think a ref to node Data Files should be sufficient. > Whaddayathink? Without including all of the rest of the patch, which doesn't change, how about this? 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 6 Dec 2010 22:13:50 -0000 @@ -1111,6 +1111,12 @@ used if possible. Run @value{GDBN} using @var{directory} as its working directory, instead of the current directory. +@item -data-directory @var{directory} +@cindex @code{--data-directory} +Run @value{GDBN} using @var{directory} as its data-directory. +The data-directory is where @value{GDBN} searches for its +auxiliary files. @xref{Data Files}. + @item -fullname @itemx -f @cindex @code{--fullname} ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx 2010-12-06 22:17 ` Doug Evans @ 2010-12-07 4:02 ` Eli Zaretskii 0 siblings, 0 replies; 23+ messages in thread From: Eli Zaretskii @ 2010-12-07 4:02 UTC (permalink / raw) To: Doug Evans; +Cc: jan.kratochvil, gdb-patches > Date: Mon, 6 Dec 2010 14:17:08 -0800 > From: Doug Evans <dje@google.com> > Cc: jan.kratochvil@redhat.com, gdb-patches@sourceware.org > > +@item -data-directory @var{directory} > +@cindex @code{--data-directory} > +Run @value{GDBN} using @var{directory} as its data-directory. > +The data-directory is where @value{GDBN} searches for its > +auxiliary files. @xref{Data Files}. Fine with me, but please also add a sentence in that node regarding the new command-line option. As for NEWS, I think saying that this new option is for testing is good enough. Thanks. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA, doc RFA] Don't install gdb.PYTHONDIR if -nx 2010-12-06 20:43 ` Doug Evans 2010-12-06 20:50 ` Eli Zaretskii @ 2010-12-07 1:38 ` Jan Kratochvil 1 sibling, 0 replies; 23+ messages in thread From: Jan Kratochvil @ 2010-12-07 1:38 UTC (permalink / raw) To: Doug Evans; +Cc: Eli Zaretskii, gdb-patches On Mon, 06 Dec 2010 21:43:02 +0100, Doug Evans wrote: > Jan, can you test this to make sure it solves pr 12227 for you. Yes, it does. Fine with me. Thanks, Jan ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA] Don't install gdb.PYTHONDIR if -nx 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 4:22 ` Daniel Jacobowitz 2010-11-30 5:16 ` Doug Evans 2010-11-30 5:33 ` Jan Kratochvil 1 sibling, 2 replies; 23+ messages in thread From: Daniel Jacobowitz @ 2010-11-30 4:22 UTC (permalink / raw) To: Doug Evans; +Cc: gdb-patches On Sun, Nov 28, 2010 at 04:39:49PM -0800, Doug Evans wrote: > 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. If this is the problem you're trying to solve, I think a new option is better - but it's not -np. Why not an option to set gdb.PYTHONDIR before loading anything? That said, -np may be useful too. But at that point it becomes more of a question whether it should be part of -nx. -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA] Don't install gdb.PYTHONDIR if -nx 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 5:33 ` Jan Kratochvil 1 sibling, 1 reply; 23+ messages in thread From: Doug Evans @ 2010-11-30 5:16 UTC (permalink / raw) To: gdb-patches On Mon, Nov 29, 2010 at 8:22 PM, Daniel Jacobowitz <dan@codesourcery.com> wrote: > Why not an option to set gdb.PYTHONDIR > before loading anything? Or rather an option to set data-directory? [It might be tempting to do -x "set data-dir mumble" but -x is processed too late for .gdbinit.] ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA] Don't install gdb.PYTHONDIR if -nx 2010-11-30 5:16 ` Doug Evans @ 2010-11-30 18:19 ` Daniel Jacobowitz 2010-11-30 18:25 ` Doug Evans 0 siblings, 1 reply; 23+ messages in thread From: Daniel Jacobowitz @ 2010-11-30 18:19 UTC (permalink / raw) To: Doug Evans; +Cc: gdb-patches On Mon, Nov 29, 2010 at 09:16:33PM -0800, Doug Evans wrote: > On Mon, Nov 29, 2010 at 8:22 PM, Daniel Jacobowitz <dan@codesourcery.com> wrote: > > Why not an option to set gdb.PYTHONDIR > > before loading anything? > > Or rather an option to set data-directory? > [It might be tempting to do -x "set data-dir mumble" but -x is > processed too late for .gdbinit.] That would work for me. You'd need to make sure the build / testsuite set up something with the right layout (typical "staged install" problem; GCC has this issue too...). -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA] Don't install gdb.PYTHONDIR if -nx 2010-11-30 18:19 ` Daniel Jacobowitz @ 2010-11-30 18:25 ` Doug Evans 0 siblings, 0 replies; 23+ messages in thread From: Doug Evans @ 2010-11-30 18:25 UTC (permalink / raw) To: Doug Evans, gdb-patches On Tue, Nov 30, 2010 at 10:19 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote: > On Mon, Nov 29, 2010 at 09:16:33PM -0800, Doug Evans wrote: >> On Mon, Nov 29, 2010 at 8:22 PM, Daniel Jacobowitz <dan@codesourcery.com> wrote: >> > Why not an option to set gdb.PYTHONDIR >> > before loading anything? >> >> Or rather an option to set data-directory? >> [It might be tempting to do -x "set data-dir mumble" but -x is >> processed too late for .gdbinit.] > > That would work for me. You'd need to make sure the build / testsuite > set up something with the right layout (typical "staged install" > problem; GCC has this issue too...). Setting aside any system.gdbinit, that's already done: $obj/gdb/data-directory. ^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [RFA] Don't install gdb.PYTHONDIR if -nx 2010-11-30 4:22 ` [RFA] " Daniel Jacobowitz 2010-11-30 5:16 ` Doug Evans @ 2010-11-30 5:33 ` Jan Kratochvil 1 sibling, 0 replies; 23+ messages in thread From: Jan Kratochvil @ 2010-11-30 5:33 UTC (permalink / raw) To: gdb-patches; +Cc: Doug Evans On Tue, 30 Nov 2010 05:22:09 +0100, Daniel Jacobowitz wrote: > If this is the problem you're trying to solve, I think a new option is > better - but it's not -np. Why not an option to set gdb.PYTHONDIR > before loading anything? The -np could also delay the Python initialization. This would never initialize Python for non-gdb.python/ testcases, saving some cycles. But that is not implemented there by this patch and it is questiontable if it is worth coding with all the testsuite overhead. Thanks, Jan ^ 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 ` 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-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