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

Doug Evans
2010-12-06T20:43:20Z

[-- 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.