Fix in "set auto-load" patchset for SCL scripts inheritance (BZ 815910).

This commit is contained in:
Jan Kratochvil 2012-05-09 22:39:25 +02:00
parent 72cb82c2bf
commit de3a592768
24 changed files with 1105 additions and 323 deletions

28
gdb-autoload-17of22.patch Normal file
View File

@ -0,0 +1,28 @@
http://sourceware.org/ml/gdb-cvs/2012-05/msg00010.html
### src/gdb/ChangeLog 2012/05/02 17:13:39 1.14194
### src/gdb/ChangeLog 2012/05/02 20:00:31 1.14195
## -1,3 +1,8 @@
+2012-05-02 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Fix --without-auto-load-safe-path for MS-Windows host platform.
+ * auto-load.c (filename_is_in_dir): Return 1 for DIR_LEN 0.
+
2012-05-02 Eli Zaretskii <eliz@gnu.org>
* gdb_curses.h: Undefine KEY_EVENT before including curses
--- src/gdb/auto-load.c 2012/04/17 15:56:21 1.4
+++ src/gdb/auto-load.c 2012/05/02 20:00:36 1.5
@@ -231,6 +231,12 @@
while (dir_len && IS_DIR_SEPARATOR (dir[dir_len - 1]))
dir_len--;
+ /* Ensure auto_load_safe_path "/" matches any FILENAME. On MS-Windows
+ platform FILENAME even after gdb_realpath does not have to start with
+ IS_DIR_SEPARATOR character, such as the 'C:\x.exe' filename. */
+ if (dir_len == 0)
+ return 1;
+
return (filename_ncmp (dir, filename, dir_len) == 0
&& (IS_DIR_SEPARATOR (filename[dir_len])
|| filename[dir_len] == '\0'));

View File

@ -1,231 +0,0 @@
http://sourceware.org/ml/gdb-patches/2012-04/msg00758.html
Subject: [patch] auto-load safe-path default=$ddir/auto-load [Re: [patch] auto-load safe-path reset back by set ""]
On Sun, 22 Apr 2012 23:26:16 +0200, Doug Evans wrote:
> A thought occurred to me regarding the default value of auto-load-path
> = ${prefix}.
This is unrelated to this patch but thanks for the suggestion.
> So I was wondering if we really want security to be on by default,
> should the default value be gdb's data-directory (e.g.,
> $prefix/share/gdb) + $exec_prefix/lib{,32,64} + ???
Made it therefore $ddir/auto-load, on an ideal system/distro we can change all
the auto-loaded GDB files to be located under $ddir/auto-load. I have filed
for the only remaining violation (/usr/bin/mono-gdb.py) known to me:
https://bugzilla.redhat.com/show_bug.cgi?id=815501
(Sure I will ask about upstreaming of the change.)
> Plus, it seems like at least data-directory should be relocatable.
> Implementing this might be cumbersome unless data-directory was
> represented as something like "$ddir".
Done. Unfortunately this still does not fix the "./gdb" run for a newly built
GDB. Newly built GDB probably could use "-data-directory $PWD/data-directory"
(if GDB's program dir contains "data-directory" sort of relocation).
We could then change current
gdb-gdb.gdb.in -> gdb-gdb.gdb
to
gdb-gdb.gdb.in -> data-directory/auto-load/$PWD/gdb-gdb.gdb
and even install the file (with proper installation directories) as:
/usr/share/gdb/usr/bin/gdb-gdb.gdb
(additionally ensuring for example in Fedora - in its .spec file
@srcdir@ gets substituted right for Fedora *-debuginfo.rpm)
Would it make everyone happy?
Thanks,
Jan
gdb/
2012-04-23 Jan Kratochvil <jan.kratochvil@redhat.com>
Change auto-load safe-path default to $ddir/auto-load.
* auto-load.c (auto_load_safe_path_vec_update): Call
substitute_path_component for $ddir.
* configure: Regenerate.
* configure.ac (--with-auto-load-safe-path): Suggest $ddir syntax.
Change the default to \\\$ddir/auto-load.
* defs.h (substitute_path_component): New declaration.
* utils.c (substitute_path_component): New function.
gdb/doc/
2012-04-23 Jan Kratochvil <jan.kratochvil@redhat.com>
Change auto-load safe-path default to $ddir/auto-load.
* gdb.texinfo (Auto-loading): Change shown safe-path default to
$ddir/auto-load.
(Auto-loading safe path): Change the sample warning to $ddir/auto-load.
Twice. Mention the $ddir substitution.
Index: gdb-7.4.50.20120120/gdb/auto-load.c
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/auto-load.c 2012-04-24 18:12:21.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/auto-load.c 2012-04-24 18:12:38.819279574 +0200
@@ -141,8 +141,12 @@ auto_load_safe_path_vec_update (void)
for (ix = 0; ix < len; ix++)
{
char *dir = VEC_index (char_ptr, auto_load_safe_path_vec, ix);
- char *expanded = tilde_expand (dir);
- char *real_path = gdb_realpath (expanded);
+ char *expanded, *real_path;
+
+ expanded = tilde_expand (dir);
+ substitute_path_component (&expanded, "$ddir", gdb_datadir);
+
+ real_path = gdb_realpath (expanded);
/* Ensure the current entry is at least tilde_expand-ed. */
VEC_replace (char_ptr, auto_load_safe_path_vec, ix, expanded);
Index: gdb-7.4.50.20120120/gdb/configure
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/configure 2012-04-24 18:12:21.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/configure 2012-04-24 18:12:38.822279566 +0200
@@ -1668,7 +1668,8 @@ Optional Packages:
--with-rpm query rpm database for missing debuginfos (yes/no,
def. auto=librpm.so)
--with-auto-load-safe-path=PATH
- directories safe to hold auto-loaded files
+ directories safe to hold auto-loaded files, use
+ '\\\$ddir' for -data-directory
--without-auto-load-safe-path
do not restrict auto-loaded files locations
--with-libunwind use libunwind frame unwinding support
@@ -8491,7 +8492,7 @@ if test "${with_auto_load_safe_path+set}
with_auto_load_safe_path="/"
fi
else
- with_auto_load_safe_path="$prefix"
+ with_auto_load_safe_path='\\\$ddir/auto-load'
fi
Index: gdb-7.4.50.20120120/gdb/configure.ac
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/configure.ac 2012-04-24 18:12:21.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/configure.ac 2012-04-24 18:13:04.090216605 +0200
@@ -341,12 +341,13 @@ fi
AC_MSG_CHECKING([for default auto-load safe-path])
AC_ARG_WITH(auto-load-safe-path,
-AS_HELP_STRING([--with-auto-load-safe-path=PATH], [directories safe to hold auto-loaded files])
+AS_HELP_STRING([--with-auto-load-safe-path=PATH],
+ [directories safe to hold auto-loaded files, use '\\\$ddir' for -data-directory])
AS_HELP_STRING([--without-auto-load-safe-path], [do not restrict auto-loaded files locations]),
[if test "$with_auto_load_safe_path" = "no"; then
with_auto_load_safe_path="/"
fi],
-[with_auto_load_safe_path="$prefix"])
+[with_auto_load_safe_path='\\\$ddir/auto-load'])
AC_DEFINE_DIR(DEFAULT_AUTO_LOAD_SAFE_PATH, with_auto_load_safe_path,
[Directories safe to hold auto-loaded files.])
AC_MSG_RESULT([$with_auto_load_safe_path])
Index: gdb-7.4.50.20120120/gdb/defs.h
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/defs.h 2012-04-24 18:12:20.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/defs.h 2012-04-24 18:12:38.824279562 +0200
@@ -442,6 +442,9 @@ extern struct cleanup *make_bpstat_clear
extern int producer_is_gcc_ge_4 (const char *producer);
+extern void substitute_path_component (char **stringp, const char *from,
+ const char *to);
+
#ifdef HAVE_WAITPID
extern pid_t wait_to_die_with_timeout (pid_t pid, int *status, int timeout);
#endif
Index: gdb-7.4.50.20120120/gdb/doc/gdb.texinfo
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/doc/gdb.texinfo 2012-04-24 18:12:21.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/doc/gdb.texinfo 2012-04-24 18:13:38.233131533 +0200
@@ -20802,7 +20802,7 @@ libthread-db: Auto-loading of inferior
local-gdbinit: Auto-loading of .gdbinit script from current directory is on.
python-scripts: Auto-loading of Python scripts is on.
safe-path: List of directories from which it is safe to auto-load files
- is /usr/local.
+ is $ddir/auto-load.
@end smallexample
@anchor{info auto-load}
@@ -21004,9 +21004,9 @@ get loaded:
$ ./gdb -q ./gdb
Reading symbols from /home/user/gdb/gdb...done.
warning: File "/home/user/gdb/gdb-gdb.gdb" auto-loading has been
- declined by your `auto-load safe-path' set to "/usr/local".
+ declined by your `auto-load safe-path' set to "$ddir/auto-load".
warning: File "/home/user/gdb/gdb-gdb.py" auto-loading has been
- declined by your `auto-load safe-path' set to "/usr/local".
+ declined by your `auto-load safe-path' set to "$ddir/auto-load".
@end smallexample
The list of trusted directories is controlled by the following commands:
@@ -21038,6 +21038,11 @@ loading and execution of scripts. Multi
host platform directory separator in use.
@end table
+Any used string @file{$ddir} will get replaced by @var{data-directory} which is
+determined at @value{GDBN} startup (@pxref{Data Files}). @file{$ddir} must be
+be placed as a directory component - either alone or delimited by @file{/} or
+@file{\} directory separators, depending on the host platform.
+
Setting this variable to @file{/} disables this security
protection.
This variable is supposed to be set to the system directories writable by the
Index: gdb-7.4.50.20120120/gdb/utils.c
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/utils.c 2012-04-24 18:12:21.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/utils.c 2012-04-24 18:12:38.833279540 +0200
@@ -3925,6 +3925,48 @@ dirnames_to_char_ptr_vec (const char *di
return retval;
}
+/* Substitute all occurences of string FROM by string TO in *STRINGP. *STRINGP
+ must come from xrealloc-compatible allocator and it may be updated. FROM
+ needs to be delimited by IS_DIR_SEPARATOR (or be located at the start or
+ end of *STRINGP. */
+
+void
+substitute_path_component (char **stringp, const char *from, const char *to)
+{
+ char *string = *stringp, *s;
+ const size_t from_len = strlen (from);
+ const size_t to_len = strlen (to);
+
+ for (s = string;;)
+ {
+ s = strstr (s, from);
+ if (s == NULL)
+ break;
+
+ if ((s == string || IS_DIR_SEPARATOR (s[-1]))
+ && (s[from_len] == '\0' || IS_DIR_SEPARATOR (s[from_len])))
+ {
+ char *string_new;
+
+ string_new = xrealloc (string, (strlen (string) + to_len + 1));
+
+ /* Relocate the current S pointer. */
+ s = s - string + string_new;
+ string = string_new;
+
+ /* Replace from by to. */
+ memmove (&s[to_len], &s[from_len], strlen (&s[from_len]) + 1);
+ memcpy (s, to, to_len);
+
+ s += to_len;
+ }
+ else
+ s++;
+ }
+
+ *stringp = string;
+}
+
#ifdef HAVE_WAITPID
#ifdef SIGALRM

View File

@ -1,51 +1,25 @@
http://sourceware.org/ml/gdb-patches/2012-04/msg00756.html
Subject: Re: [patch] auto-load safe-path reset back by set ""
- Patched out "(without the quotes)".
http://sourceware.org/ml/gdb-cvs/2012-05/msg00038.html
On Sun, 22 Apr 2012 22:16:32 +0200, Eli Zaretskii wrote:
> > +@item set auto-load safe-path [@var{directories}]
>
> You need @r{} around [ and ].
>
> > +Setting this variable to @code{"/"} (without the quotes) disables this security
> ^^^^^^^^^^
> Why not @file{/}? The quotes are not needed in any case.
done.
In fact this patch is unrelated to the Doug's suggestion, reposting it only
with the doc update.
Thanks,
Jan
gdb/
2012-04-23 Jan Kratochvil <jan.kratochvil@redhat.com>
* auto-load.c (set_auto_load_safe_path): Reset AUTO_LOAD_SAFE_PATH
back to DEFAULT_AUTO_LOAD_SAFE_PATH if it is being set to "".
(show_auto_load_safe_path): Check any-directory by comparison with "/".
(add_auto_load_safe_path): Change the error message.
(_initialize_auto_load): Change the "safe-path" help text.
* configure: Regenerate
* configure.ac (--without-auto-load-safe-path): Set
WITH_AUTO_LOAD_SAFE_PATH to /.
gdb/doc/
2012-04-23 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.texinfo (Auto-loading safe path): Make 'directories'
for 'set auto-load safe-path' optional. Mention if it is omitted.
Change disabling security protection condition to "/", twice.
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 9d19179..6c1309f 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -181,6 +181,12 @@ auto_load_safe_path_vec_update (void)
### src/gdb/ChangeLog 2012/05/05 05:36:23 1.14211
### src/gdb/ChangeLog 2012/05/06 15:30:59 1.14212
## -1,3 +1,14 @@
+2012-05-06 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * auto-load.c (set_auto_load_safe_path): Reset AUTO_LOAD_SAFE_PATH
+ back to DEFAULT_AUTO_LOAD_SAFE_PATH if it is being set to "".
+ (show_auto_load_safe_path): Check any-directory by comparison with "/".
+ (add_auto_load_safe_path): Change the error message.
+ (_initialize_auto_load): Change the "safe-path" help text.
+ * configure: Regenerate
+ * configure.ac (--without-auto-load-safe-path): Set
+ WITH_AUTO_LOAD_SAFE_PATH to /.
+
2012-05-05 Sergio Durigan Junior <sergiodj@redhat.com>
* stap-probe.h: Do not include unecessary `probe.h'.
--- src/gdb/auto-load.c 2012/05/02 20:00:36 1.5
+++ src/gdb/auto-load.c 2012/05/06 15:31:02 1.6
@@ -181,6 +181,12 @@
static void
set_auto_load_safe_path (char *args, int from_tty, struct cmd_list_element *c)
{
@ -58,7 +32,7 @@ index 9d19179..6c1309f 100644
auto_load_safe_path_vec_update ();
}
@@ -190,7 +196,7 @@ static void
@@ -190,7 +196,7 @@
show_auto_load_safe_path (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
@ -67,7 +41,7 @@ index 9d19179..6c1309f 100644
fprintf_filtered (file, _("Auto-load files are safe to load from any "
"directory.\n"));
else
@@ -209,8 +215,9 @@ add_auto_load_safe_path (char *args, int from_tty)
@@ -209,8 +215,9 @@
if (args == NULL || *args == 0)
error (_("\
@ -79,7 +53,7 @@ index 9d19179..6c1309f 100644
s = xstrprintf ("%s%c%s", auto_load_safe_path, DIRNAME_SEPARATOR, args);
xfree (auto_load_safe_path);
@@ -1023,8 +1030,10 @@ Set the list of directories from which it is safe to auto-load files."), _("\
@@ -1029,8 +1036,10 @@
Show the list of directories from which it is safe to auto-load files."), _("\
Various files loaded automatically for the 'set auto-load ...' options must\n\
be located in one of the directories listed by this option. Warning will be\n\
@ -92,11 +66,9 @@ index 9d19179..6c1309f 100644
This option is ignored for the kinds of files having 'set auto-load ... off'.\n\
This options has security implications for untrusted inferiors."),
set_auto_load_safe_path,
diff --git a/gdb/configure b/gdb/configure
index 54c2399..42d2fbd 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -4949,7 +4949,7 @@ $as_echo_n "checking for default auto-load safe-path... " >&6; }
--- src/gdb/configure 2012/04/27 20:47:52 1.360
+++ src/gdb/configure 2012/05/06 15:31:02 1.361
@@ -4964,7 +4964,7 @@
# Check whether --with-auto-load-safe-path was given.
if test "${with_auto_load_safe_path+set}" = set; then :
withval=$with_auto_load_safe_path; if test "$with_auto_load_safe_path" = "no"; then
@ -105,11 +77,9 @@ index 54c2399..42d2fbd 100755
fi
else
with_auto_load_safe_path="$prefix"
diff --git a/gdb/configure.ac b/gdb/configure.ac
index a40c2e5..9bde18f 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -140,7 +140,7 @@ AC_ARG_WITH(auto-load-safe-path,
--- src/gdb/configure.ac 2012/04/27 20:47:53 1.171
+++ src/gdb/configure.ac 2012/05/06 15:31:03 1.172
@@ -141,7 +141,7 @@
AS_HELP_STRING([--with-auto-load-safe-path=PATH], [directories safe to hold auto-loaded files])
AS_HELP_STRING([--without-auto-load-safe-path], [do not restrict auto-loaded files locations]),
[if test "$with_auto_load_safe_path" = "no"; then
@ -118,11 +88,21 @@ index a40c2e5..9bde18f 100644
fi],
[with_auto_load_safe_path="$prefix"])
AC_DEFINE_DIR(DEFAULT_AUTO_LOAD_SAFE_PATH, with_auto_load_safe_path,
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index a2a4eb3..46dde27 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -21105,9 +21105,12 @@ The list of trusted directories is controlled by the following commands:
### src/gdb/doc/ChangeLog 2012/05/03 07:07:24 1.1308
### src/gdb/doc/ChangeLog 2012/05/06 15:31:04 1.1309
## -1,3 +1,9 @@
+2012-05-06 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.texinfo (Auto-loading safe path): Make 'directories'
+ for 'set auto-load safe-path' optional. Mention if it is omitted.
+ Change disabling security protection condition to "/", twice.
+
2012-05-03 Siva Chandra Reddy <sivachandra@google.com>
* gdb.texinfo (Symbol Tables In Python): Add documentation about
--- src/gdb/doc/gdb.texinfo 2012/05/03 07:07:24 1.954
+++ src/gdb/doc/gdb.texinfo 2012/05/06 15:31:04 1.955
@@ -21219,9 +21219,12 @@
@table @code
@anchor{set auto-load safe-path}
@kindex set auto-load safe-path
@ -136,17 +116,16 @@ index a2a4eb3..46dde27 100644
The list of directories uses directory separator (@samp{:} on GNU and Unix
systems, @samp{;} on MS-Windows and MS-DOS) to separate directories, similarly
to the @env{PATH} environment variable.
@@ -21126,7 +21129,8 @@ loading and execution of scripts. Multiple entries may be delimited by the
@@ -21240,7 +21243,7 @@
host platform directory separator in use.
@end table
-Setting this variable to an empty string disables this security protection.
+Setting this variable to @file{/} disables this security
+protection.
+Setting this variable to @file{/} disables this security protection.
This variable is supposed to be set to the system directories writable by the
system superuser only. Users can add their source directories in init files in
their home directories (@pxref{Home Directory Init File}). See also deprecated
@@ -21146,7 +21150,7 @@ by @samp{show auto-load safe-path} (such as @samp{/usr:/bin} in this example).
@@ -21260,7 +21263,7 @@
Specify this directory as in the previous case but just for a single
@value{GDBN} session.
@ -155,4 +134,3 @@ index a2a4eb3..46dde27 100644
Disable auto-loading safety for a single @value{GDBN} session.
This assumes all the files you debug during this @value{GDBN} session will come
from trusted sources.

35
gdb-autoload-19of22.patch Normal file
View File

@ -0,0 +1,35 @@
http://sourceware.org/ml/gdb-cvs/2012-05/msg00059.html
### src/gdb/doc/ChangeLog 2012/05/06 15:31:04 1.1309
### src/gdb/doc/ChangeLog 2012/05/09 18:15:58 1.1310
## -1,3 +1,8 @@
+2012-05-09 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.texinfo (Auto-loading): Wrap too long lines in @smallexample.
+ Twice.
+
2012-05-06 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.texinfo (Auto-loading safe path): Make 'directories'
--- src/gdb/doc/gdb.texinfo 2012/05/06 15:31:04 1.955
+++ src/gdb/doc/gdb.texinfo 2012/05/09 18:15:58 1.956
@@ -21004,7 +21004,8 @@
(gdb) show auto-load
gdb-scripts: Auto-loading of canned sequences of commands scripts is on.
libthread-db: Auto-loading of inferior specific libthread_db is on.
-local-gdbinit: Auto-loading of .gdbinit script from current directory is on.
+local-gdbinit: Auto-loading of .gdbinit script from current directory
+ is on.
python-scripts: Auto-loading of Python scripts is on.
safe-path: List of directories from which it is safe to auto-load files
is /usr/local.
@@ -21022,7 +21023,8 @@
Loaded Script
Yes /home/user/gdb/gdb-gdb.gdb
libthread-db: No auto-loaded libthread-db.
-local-gdbinit: Local .gdbinit file "/home/user/gdb/.gdbinit" has been loaded.
+local-gdbinit: Local .gdbinit file "/home/user/gdb/.gdbinit" has been
+ loaded.
python-scripts:
Loaded Script
Yes /home/user/gdb/gdb-gdb.py

76
gdb-autoload-20of22.patch Normal file
View File

@ -0,0 +1,76 @@
http://sourceware.org/ml/gdb-patches/2012-05/msg00180.html
Subject: [patch] auto-load fix multi-dir debug-file-directory
Hi,
I forgot to fix this case myself, Python auto-load was implemented by:
commit 1e5e2afd7cfa6bb62abb9493a514c70489e19c32
Author: Tom Tromey <tromey@redhat.com>
Date: Thu May 28 00:40:23 2009 +0000
while multi-dir debug-file-directory was implemented by
commit 36ae52d16cc9d38cfe317a79bb5d63c624359154
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Mon Nov 2 14:59:48 2009 +0000
No regressions on {x86_64,x86_64-m32,i686}-fedora17-linux-gnu.
And debug_file_directory really cannot be NULL after GDB initialization code.
Thanks,
Jan
gdb/
2012-05-07 Jan Kratochvil <jan.kratochvil@redhat.com>
Make auto-load handle multiple components of DEBUG_FILE_DIRECTORY.
* auto-load.c (auto_load_objfile_script): Remove check for NULL
DEBUG_FILE_DIRECTORY. Handle multiple components of
DEBUG_FILE_DIRECTORY.
Diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 9d4d0bc..254de3b 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -587,17 +587,29 @@ auto_load_objfile_script (struct objfile *objfile,
input = fopen (filename, "r");
debugfile = filename;
- if (!input && debug_file_directory)
+ if (!input)
{
- /* Also try the same file in the separate debug info directory. */
- debugfile = xmalloc (strlen (filename)
- + strlen (debug_file_directory) + 1);
- strcpy (debugfile, debug_file_directory);
- /* FILENAME is absolute, so we don't need a "/" here. */
- strcat (debugfile, filename);
+ char *debugdir;
+ VEC (char_ptr) *debugdir_vec;
+ int ix;
- make_cleanup (xfree, debugfile);
- input = fopen (debugfile, "r");
+ debugdir_vec = dirnames_to_char_ptr_vec (debug_file_directory);
+ make_cleanup_free_char_ptr_vec (debugdir_vec);
+
+ for (ix = 0; VEC_iterate (char_ptr, debugdir_vec, ix, debugdir); ++ix)
+ {
+ /* Also try the same file in the separate debug info directory. */
+ debugfile = xmalloc (strlen (debugdir) + strlen (filename) + 1);
+ strcpy (debugfile, debugdir);
+
+ /* FILENAME is absolute, so we don't need a "/" here. */
+ strcat (debugfile, filename);
+
+ make_cleanup (xfree, debugfile);
+ input = fopen (debugfile, "r");
+ if (input != NULL)
+ break;
+ }
}
if (!input && gdb_datadir)

403
gdb-autoload-21of22.patch Normal file
View File

@ -0,0 +1,403 @@
http://sourceware.org/ml/gdb-patches/2012-05/msg00303.html
Subject: Re: [patch 1/2] Provide $ddir substitution for --with-auto-load-safe-path
On Wed, 09 May 2012 19:41:08 +0200, Eli Zaretskii wrote:
> Okay with that. Thanks.
Updated just the doc.
Thanks,
Jan
gdb/
2012-05-09 Jan Kratochvil <jan.kratochvil@redhat.com>
Provide $ddir substitution for --with-auto-load-safe-path.
* NEWS (--with-auto-load-safe-path, --without-auto-load-safe-path): New
entries.
* auto-load.c: Include observer.h.
(auto_load_safe_path_vec_update): Call substitute_path_component for
each component. New variable ddir_subst.
(auto_load_gdb_datadir_changed): New function.
(set_auto_load_safe_path): Rename DEFAULT_AUTO_LOAD_SAFE_PATH to
AUTO_LOAD_SAFE_PATH. New comment.
(_initialize_auto_load): Rename DEFAULT_AUTO_LOAD_SAFE_PATH to
AUTO_LOAD_SAFE_PATH. Install auto_load_gdb_datadir_changed.
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac (--auto-load-safe-path): Rename
DEFAULT_AUTO_LOAD_SAFE_PATH to AUTO_LOAD_SAFE_PATH. Default to
GDB_DATADIR/auto-load.
* defs.h (substitute_path_component): New declaration.
* top.c: Include observer.h.
(set_gdb_datadir): New function.
(init_main): Install it for "set data-directory".
* utils.c (substitute_path_component): New function.
gdb/doc/
2012-05-09 Jan Kratochvil <jan.kratochvil@redhat.com>
Provide $ddir substitution for --with-auto-load-safe-path.
* gdb.texinfo (Auto-loading): Replace /usr/local by $ddir/auto-load.
(Auto-loading safe path): Likewise. Mention the default value,
$ddir substitution, --with-auto-load-safe-path and
--without-auto-load-safe-path.
* observer.texi (gdb_datadir_changed): New.
Index: gdb-7.4.50.20120120/gdb/NEWS
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/NEWS 2012-05-09 22:13:58.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/NEWS 2012-05-09 22:14:29.091183190 +0200
@@ -76,6 +76,17 @@ set debug auto-load on|off
show debug auto-load
Control display of debugging info for auto-loading the files above.
+* New configure options
+
+--with-auto-load-safe-path
+ Configure default value for the 'set auto-load safe-path' setting
+ above. It defaults to '$ddir/auto-load', $ddir representing the value
+ of configure option --with-gdb-datadir.
+
+--without-auto-load-safe-path
+ Set 'set auto-load safe-path' to '/', effectively disabling this
+ security feature.
+
* New command line options
--init-command=FILE, -ix Like --command, -x but execute it
Index: gdb-7.4.50.20120120/gdb/auto-load.c
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/auto-load.c 2012-05-09 22:13:58.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/auto-load.c 2012-05-09 22:14:04.812222226 +0200
@@ -35,6 +35,7 @@
#include "gdb_vecs.h"
#include "readline/tilde.h"
#include "completer.h"
+#include "observer.h"
/* The suffix of per-objfile scripts to auto-load as non-Python command files.
E.g. When the program loads libfoo.so, look for libfoo-gdb.gdb. */
@@ -141,10 +142,16 @@ auto_load_safe_path_vec_update (void)
for (ix = 0; ix < len; ix++)
{
char *dir = VEC_index (char_ptr, auto_load_safe_path_vec, ix);
- char *expanded = tilde_expand (dir);
- char *real_path = gdb_realpath (expanded);
+ char *ddir_subst, *expanded, *real_path;
- /* Ensure the current entry is at least tilde_expand-ed. */
+ ddir_subst = xstrdup (dir);
+ substitute_path_component (&ddir_subst, "$ddir", gdb_datadir);
+ expanded = tilde_expand (ddir_subst);
+ xfree (ddir_subst);
+ real_path = gdb_realpath (expanded);
+
+ /* Ensure the current entry is at least a valid path (therefore
+ $ddir-expanded and tilde-expanded). */
VEC_replace (char_ptr, auto_load_safe_path_vec, ix, expanded);
if (debug_auto_load)
@@ -176,15 +183,24 @@ auto_load_safe_path_vec_update (void)
}
}
+/* Variable gdb_datadir has been set. Update content depending on $ddir. */
+
+static void
+auto_load_gdb_datadir_changed (void)
+{
+ auto_load_safe_path_vec_update ();
+}
+
/* "set" command for the auto_load_safe_path configuration variable. */
static void
set_auto_load_safe_path (char *args, int from_tty, struct cmd_list_element *c)
{
+ /* Setting the variable to "" resets it to the compile time defaults. */
if (auto_load_safe_path[0] == '\0')
{
xfree (auto_load_safe_path);
- auto_load_safe_path = xstrdup (DEFAULT_AUTO_LOAD_SAFE_PATH);
+ auto_load_safe_path = xstrdup (AUTO_LOAD_SAFE_PATH);
}
auto_load_safe_path_vec_update ();
@@ -1040,7 +1056,7 @@ This options has security implications f
Usage: info auto-load local-gdbinit"),
auto_load_info_cmdlist_get ());
- auto_load_safe_path = xstrdup (DEFAULT_AUTO_LOAD_SAFE_PATH);
+ auto_load_safe_path = xstrdup (AUTO_LOAD_SAFE_PATH);
auto_load_safe_path_vec_update ();
add_setshow_optional_filename_cmd ("safe-path", class_support,
&auto_load_safe_path, _("\
@@ -1058,6 +1074,7 @@ This options has security implications f
show_auto_load_safe_path,
auto_load_set_cmdlist_get (),
auto_load_show_cmdlist_get ());
+ observer_attach_gdb_datadir_changed (auto_load_gdb_datadir_changed);
cmd = add_cmd ("add-auto-load-safe-path", class_support,
add_auto_load_safe_path,
Index: gdb-7.4.50.20120120/gdb/config.in
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config.in 2012-05-09 22:13:58.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/config.in 2012-05-09 22:14:04.812222226 +0200
@@ -7,6 +7,9 @@
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
+/* Directories safe to hold auto-loaded files. */
+#undef AUTO_LOAD_SAFE_PATH
+
/* Directory of programs. */
#undef BINDIR
@@ -43,9 +46,6 @@
moved. */
#undef DEBUGDIR_RELOCATABLE
-/* Directories safe to hold auto-loaded files. */
-#undef DEFAULT_AUTO_LOAD_SAFE_PATH
-
/* Define to BFD's default architecture. */
#undef DEFAULT_BFD_ARCH
Index: gdb-7.4.50.20120120/gdb/configure
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/configure 2012-05-09 22:13:58.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/configure 2012-05-09 22:16:19.877005083 +0200
@@ -1668,7 +1668,8 @@ Optional Packages:
--with-rpm query rpm database for missing debuginfos (yes/no,
def. auto=librpm.so)
--with-auto-load-safe-path=PATH
- directories safe to hold auto-loaded files
+ directories safe to hold auto-loaded files, use
+ $ddir for --with-gdb-datadir path [$ddir/auto-load]
--without-auto-load-safe-path
do not restrict auto-loaded files locations
--with-libunwind use libunwind frame unwinding support
@@ -8488,20 +8489,21 @@ $as_echo_n "checking for default auto-lo
# Check whether --with-auto-load-safe-path was given.
if test "${with_auto_load_safe_path+set}" = set; then :
withval=$with_auto_load_safe_path; if test "$with_auto_load_safe_path" = "no"; then
- with_auto_load_safe_path="/"
- fi
+ with_auto_load_safe_path="/"
+ fi
else
- with_auto_load_safe_path="$prefix"
+ with_auto_load_safe_path='$ddir/auto-load'
fi
+escape_dir=`echo $with_auto_load_safe_path | sed 's/[$]ddir\>/\\\\\\\\\\\\&/g'`
test "x$prefix" = xNONE && prefix="$ac_default_prefix"
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
- ac_define_dir=`eval echo $with_auto_load_safe_path`
+ ac_define_dir=`eval echo $escape_dir`
ac_define_dir=`eval echo $ac_define_dir`
cat >>confdefs.h <<_ACEOF
-#define DEFAULT_AUTO_LOAD_SAFE_PATH "$ac_define_dir"
+#define AUTO_LOAD_SAFE_PATH "$ac_define_dir"
_ACEOF
Index: gdb-7.4.50.20120120/gdb/configure.ac
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/configure.ac 2012-05-09 22:13:58.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/configure.ac 2012-05-09 22:16:10.592020012 +0200
@@ -341,13 +341,16 @@ fi
AC_MSG_CHECKING([for default auto-load safe-path])
AC_ARG_WITH(auto-load-safe-path,
-AS_HELP_STRING([--with-auto-load-safe-path=PATH], [directories safe to hold auto-loaded files])
-AS_HELP_STRING([--without-auto-load-safe-path], [do not restrict auto-loaded files locations]),
-[if test "$with_auto_load_safe_path" = "no"; then
- with_auto_load_safe_path="/"
- fi],
-[with_auto_load_safe_path="$prefix"])
-AC_DEFINE_DIR(DEFAULT_AUTO_LOAD_SAFE_PATH, with_auto_load_safe_path,
+AS_HELP_STRING([--with-auto-load-safe-path=PATH],
+ [directories safe to hold auto-loaded files, use $ddir for --with-gdb-datadir path @<:@$ddir/auto-load@:>@])
+AS_HELP_STRING([--without-auto-load-safe-path],
+ [do not restrict auto-loaded files locations]),
+ [if test "$with_auto_load_safe_path" = "no"; then
+ with_auto_load_safe_path="/"
+ fi],
+[with_auto_load_safe_path='$ddir/auto-load'])
+escape_dir=`echo $with_auto_load_safe_path | sed 's/[[$]]ddir\>/\\\\\\\\\\\\&/g'`
+AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir,
[Directories safe to hold auto-loaded files.])
AC_MSG_RESULT([$with_auto_load_safe_path])
Index: gdb-7.4.50.20120120/gdb/defs.h
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/defs.h 2012-05-09 22:13:57.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/defs.h 2012-05-09 22:14:04.816222220 +0200
@@ -442,6 +442,9 @@ extern struct cleanup *make_bpstat_clear
extern int producer_is_gcc_ge_4 (const char *producer);
+extern void substitute_path_component (char **stringp, const char *from,
+ const char *to);
+
#ifdef HAVE_WAITPID
extern pid_t wait_to_die_with_timeout (pid_t pid, int *status, int timeout);
#endif
Index: gdb-7.4.50.20120120/gdb/doc/gdb.texinfo
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/doc/gdb.texinfo 2012-05-09 22:13:58.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/doc/gdb.texinfo 2012-05-09 22:16:43.759966688 +0200
@@ -20803,7 +20803,7 @@ local-gdbinit: Auto-loading of .gdbinit
is on.
python-scripts: Auto-loading of Python scripts is on.
safe-path: List of directories from which it is safe to auto-load files
- is /usr/local.
+ is $ddir/auto-load.
@end smallexample
@anchor{info auto-load}
@@ -21006,9 +21006,9 @@ get loaded:
$ ./gdb -q ./gdb
Reading symbols from /home/user/gdb/gdb...done.
warning: File "/home/user/gdb/gdb-gdb.gdb" auto-loading has been
- declined by your `auto-load safe-path' set to "/usr/local".
+ declined by your `auto-load safe-path' set to "$ddir/auto-load".
warning: File "/home/user/gdb/gdb-gdb.py" auto-loading has been
- declined by your `auto-load safe-path' set to "/usr/local".
+ declined by your `auto-load safe-path' set to "$ddir/auto-load".
@end smallexample
The list of trusted directories is controlled by the following commands:
@@ -21040,7 +21040,18 @@ loading and execution of scripts. Multi
host platform directory separator in use.
@end table
-Setting this variable to @file{/} disables this security protection.
+This variable defaults to @file{$ddir/auto-load}. The default @code{set
+auto-load safe-path} value can be also overriden by @value{GDBN} configuration
+option @option{--with-auto-load-safe-path}.
+
+Any used string @file{$ddir} will get replaced by @var{data-directory} which is
+determined at @value{GDBN} startup (@pxref{Data Files}). @file{$ddir} must be
+be placed as a directory component --- either alone or delimited by @file{/} or
+@file{\} directory separators, depending on the host platform.
+
+Setting this variable to @file{/} disables this security protection,
+corresponding @value{GDBN} configuration option is
+@option{--without-auto-load-safe-path}.
This variable is supposed to be set to the system directories writable by the
system superuser only. Users can add their source directories in init files in
their home directories (@pxref{Home Directory Init File}). See also deprecated
Index: gdb-7.4.50.20120120/gdb/doc/observer.texi
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/doc/observer.texi 2012-05-09 22:13:56.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/doc/observer.texi 2012-05-09 22:17:04.118933948 +0200
@@ -231,6 +231,10 @@ the current top-level prompt.
@c collector pass. Currently only @code{type_mark_used} marker is supported.
@c @end deftypefun
+@deftypefun void gdb_datadir_changed (void)
+Variable gdb_datadir has been set. The value may not necessarily change.
+@end deftypefun
+
@deftypefun void test_notification (int @var{somearg})
This observer is used for internal testing. Do not use.
See testsuite/gdb.gdb/observer.exp.
Index: gdb-7.4.50.20120120/gdb/top.c
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/top.c 2012-05-09 22:13:57.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/top.c 2012-05-09 22:14:04.823222208 +0200
@@ -47,6 +47,7 @@
#include "gdbthread.h"
#include "python/python.h"
#include "interps.h"
+#include "observer.h"
/* readline include files. */
#include "readline/readline.h"
@@ -1561,6 +1562,15 @@ show_exec_done_display_p (struct ui_file
"asynchronous execution commands is %s.\n"),
value);
}
+
+/* "set" command for the gdb_datadir configuration variable. */
+
+static void
+set_gdb_datadir (char *args, int from_tty, struct cmd_list_element *c)
+{
+ observer_notify_gdb_datadir_changed ();
+}
+
static void
init_main (void)
{
@@ -1668,7 +1678,7 @@ Use \"on\" to enable the notification, a
_("Show GDB's data directory."),
_("\
When set, GDB uses the specified path to search for data files."),
- NULL, NULL,
+ set_gdb_datadir, NULL,
&setlist,
&showlist);
}
Index: gdb-7.4.50.20120120/gdb/utils.c
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/utils.c 2012-05-09 22:13:57.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/utils.c 2012-05-09 22:14:04.824222206 +0200
@@ -3925,6 +3925,48 @@ dirnames_to_char_ptr_vec (const char *di
return retval;
}
+/* Substitute all occurences of string FROM by string TO in *STRINGP. *STRINGP
+ must come from xrealloc-compatible allocator and it may be updated. FROM
+ needs to be delimited by IS_DIR_SEPARATOR (or be located at the start or
+ end of *STRINGP. */
+
+void
+substitute_path_component (char **stringp, const char *from, const char *to)
+{
+ char *string = *stringp, *s;
+ const size_t from_len = strlen (from);
+ const size_t to_len = strlen (to);
+
+ for (s = string;;)
+ {
+ s = strstr (s, from);
+ if (s == NULL)
+ break;
+
+ if ((s == string || IS_DIR_SEPARATOR (s[-1]))
+ && (s[from_len] == '\0' || IS_DIR_SEPARATOR (s[from_len])))
+ {
+ char *string_new;
+
+ string_new = xrealloc (string, (strlen (string) + to_len + 1));
+
+ /* Relocate the current S pointer. */
+ s = s - string + string_new;
+ string = string_new;
+
+ /* Replace from by to. */
+ memmove (&s[to_len], &s[from_len], strlen (&s[from_len]) + 1);
+ memcpy (s, to, to_len);
+
+ s += to_len;
+ }
+ else
+ s++;
+ }
+
+ *stringp = string;
+}
+
#ifdef HAVE_WAITPID
#ifdef SIGALRM

482
gdb-autoload-22of22.patch Normal file
View File

@ -0,0 +1,482 @@
http://sourceware.org/ml/gdb-patches/2012-05/msg00301.html
Subject: Re: [patch 2/2] Implement multi-component --with-auto-load-dir
On Wed, 09 May 2012 19:47:07 +0200, Eli Zaretskii wrote:
> > Date: Wed, 9 May 2012 17:48:47 +0200
> > From: Jan Kratochvil <jan.kratochvil@redhat.com>
> >
> > +set auto-load scripts-directory <dir1>[:<dir2>...]
> > + Set a list of directories with auto-loaded scripts. Automatically
>
> "Set a list of directories from which to load auto-loaded scripts."
OK.
> > +Set the list of directories with auto-loaded scripts."), _("\
> > +Show the list of directories with auto-loaded scripts."), _("\
>
> Likewise here.
But used "the", "the" is present/reviewed in many other locations in code.
> > +may be delimited by the host platform directory separator in use.
>
> I believe the correct term is "path separator".
done.
> I suggest to say
>
> (@samp{:} on Unix, @samp{;} on Windows and DOS)
>
> for clarity here, and not further down.
Used, with MS- prefixes.
>
> > +Each entry here needs to be covered also by the security setting
> > +@xref{set auto-load safe-path}.
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> You want "(@pxref{...})" here.
Used:
Each entry here needs to be covered also by the security setting
@code{set auto-load safe-path} (@pxref{set auto-load safe-path}).
Thanks,
Jan
gdb/
2012-05-09 Jan Kratochvil <jan.kratochvil@redhat.com>
Implement multi-component --with-auto-load-dir.
* NEWS (set auto-load scripts-directory, --with-auto-load-dir): New
entries.
(--with-auto-load-safe-path): Update the default value description.
* auto-load.c (auto_load_dir, set_auto_load_dir, show_auto_load_dir):
New.
(auto_load_objfile_script): Add DEBUG_AUTO_LOAD output. Remove
GDB_DATADIR NULL check. Replace GDB_DATADIR/auto-load by
AUTO_LOAD_DIR. Support $ddir and multiple components in it.
(_initialize_auto_load): Initialize also auto_load_dir. Install new
"set auto-load scripts-directory".
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac (--with-auto-load-dir): New configure option.
(--auto-load-safe-path): Change the default to --with-auto-load-dir.
gdb/doc/
2012-05-09 Jan Kratochvil <jan.kratochvil@redhat.com>
Implement multi-component --with-auto-load-dir.
* gdb.texinfo (Auto-loading): New references
for 'set auto-load scripts-directory'
and 'show auto-load scripts-directory'.
(Auto-loading safe path): Describe the new default. Move $ddir
substituation reference to 'objfile-gdb.py file'.
(objfile-gdb.py file): Describe script-name alias. Change real-name to
script-name. Describe new 'set auto-load scripts-directory'
and 'show auto-load scripts-directory'.
Index: gdb-7.4.50.20120120/gdb/NEWS
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/NEWS 2012-05-09 22:14:29.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/NEWS 2012-05-09 22:17:16.416914184 +0200
@@ -67,6 +67,12 @@ set auto-load libthread-db on|off
show auto-load libthread-db
Control auto-loading of inferior specific thread debugging shared library.
+set auto-load scripts-directory <dir1>[:<dir2>...]
+ Set a list of directories from which to load auto-loaded scripts.
+ Automatically loaded Python scripts and GDB scripts are located in one
+ of the directories listed by this option.
+ The delimiter (':' above) may differ according to the host platform.
+
set auto-load safe-path <dir1>[:<dir2>...]
show auto-load safe-path
Set a list of directories from which it is safe to auto-load files.
@@ -78,10 +84,14 @@ show debug auto-load
* New configure options
+--with-auto-load-dir
+ Configure default value for the 'set auto-load scripts-directory'
+ setting above. It defaults to '$ddir/auto-load', $ddir representing
+ the value of configure option --with-gdb-datadir.
+
--with-auto-load-safe-path
Configure default value for the 'set auto-load safe-path' setting
- above. It defaults to '$ddir/auto-load', $ddir representing the value
- of configure option --with-gdb-datadir.
+ above. It defaults to the --with-auto-load-dir setting.
--without-auto-load-safe-path
Set 'set auto-load safe-path' to '/', effectively disabling this
Index: gdb-7.4.50.20120120/gdb/auto-load.c
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/auto-load.c 2012-05-09 22:14:04.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/auto-load.c 2012-05-09 22:17:16.417914182 +0200
@@ -108,6 +108,35 @@ show_auto_load_local_gdbinit (struct ui_
value);
}
+/* Directory list from which to load auto-loaded scripts. It is not checked
+ for absolute paths but they are strongly recommended. It is initialized by
+ _initialize_auto_load. */
+static char *auto_load_dir;
+
+/* "set" command for the auto_load_dir configuration variable. */
+
+static void
+set_auto_load_dir (char *args, int from_tty, struct cmd_list_element *c)
+{
+ /* Setting the variable to "" resets it to the compile time defaults. */
+ if (auto_load_dir[0] == '\0')
+ {
+ xfree (auto_load_dir);
+ auto_load_dir = xstrdup (AUTO_LOAD_DIR);
+ }
+}
+
+/* "show" command for the auto_load_dir configuration variable. */
+
+static void
+show_auto_load_dir (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ fprintf_filtered (file, _("List of directories from which to load "
+ "auto-loaded scripts is %s.\n"),
+ value);
+}
+
/* Directory list safe to hold auto-loaded files. It is not checked for
absolute paths but they are strongly recommended. It is initialized by
_initialize_auto_load. */
@@ -602,6 +631,9 @@ auto_load_objfile_script (struct objfile
input = fopen (filename, "r");
debugfile = filename;
+ if (debug_auto_load)
+ fprintf_unfiltered (gdb_stdlog, _("auto-load: Attempted file \"%s\" %s.\n"),
+ debugfile, input ? _("exists") : _("does not exist"));
if (!input)
{
@@ -612,6 +644,12 @@ auto_load_objfile_script (struct objfile
debugdir_vec = dirnames_to_char_ptr_vec (debug_file_directory);
make_cleanup_free_char_ptr_vec (debugdir_vec);
+ if (debug_auto_load)
+ fprintf_unfiltered (gdb_stdlog,
+ _("auto-load: Searching 'set debug-file-directory' "
+ "path \"%s\".\n"),
+ debug_file_directory);
+
for (ix = 0; VEC_iterate (char_ptr, debugdir_vec, ix, debugdir); ++ix)
{
/* Also try the same file in the separate debug info directory. */
@@ -623,24 +661,53 @@ auto_load_objfile_script (struct objfile
make_cleanup (xfree, debugfile);
input = fopen (debugfile, "r");
+ if (debug_auto_load)
+ fprintf_unfiltered (gdb_stdlog, _("auto-load: Attempted file "
+ "\"%s\" %s.\n"),
+ debugfile,
+ input ? _("exists") : _("does not exist"));
if (input != NULL)
break;
}
}
- if (!input && gdb_datadir)
+ if (!input)
{
+ VEC (char_ptr) *vec;
+ int ix;
+ char *dir;
+
/* Also try the same file in a subdirectory of gdb's data
directory. */
- debugfile = xmalloc (strlen (gdb_datadir) + strlen (filename)
- + strlen ("/auto-load") + 1);
- strcpy (debugfile, gdb_datadir);
- strcat (debugfile, "/auto-load");
- /* FILENAME is absolute, so we don't need a "/" here. */
- strcat (debugfile, filename);
- make_cleanup (xfree, debugfile);
- input = fopen (debugfile, "r");
+ vec = dirnames_to_char_ptr_vec (auto_load_dir);
+ make_cleanup_free_char_ptr_vec (vec);
+
+ if (debug_auto_load)
+ fprintf_unfiltered (gdb_stdlog, _("auto-load: Searching 'set auto-load "
+ "scripts-directory' path \"%s\".\n"),
+ auto_load_dir);
+
+ for (ix = 0; VEC_iterate (char_ptr, vec, ix, dir); ++ix)
+ {
+ debugfile = xstrdup (dir);
+ substitute_path_component (&debugfile, "$ddir", gdb_datadir);
+ debugfile = xrealloc (debugfile, (strlen (debugfile)
+ + strlen (filename) + 1));
+
+ /* FILENAME is absolute, so we don't need a "/" here. */
+ strcat (debugfile, filename);
+
+ make_cleanup (xfree, debugfile);
+ input = fopen (debugfile, "r");
+ if (debug_auto_load)
+ fprintf_unfiltered (gdb_stdlog, _("auto-load: Attempted file "
+ "\"%s\" %s.\n"),
+ debugfile,
+ input ? _("exists") : _("does not exist"));
+ if (input != NULL)
+ break;
+ }
}
if (input)
@@ -1056,6 +1123,19 @@ This options has security implications f
Usage: info auto-load local-gdbinit"),
auto_load_info_cmdlist_get ());
+ auto_load_dir = xstrdup (AUTO_LOAD_DIR);
+ add_setshow_optional_filename_cmd ("scripts-directory", class_support,
+ &auto_load_dir, _("\
+Set the list of directories from which to load auto-loaded scripts."), _("\
+Show the list of directories from which to load auto-loaded scripts."), _("\
+Automatically loaded Python scripts and GDB scripts are located in one of the\n\
+directories listed by this option. This option is ignored for the kinds of\n\
+scripts having 'set auto-load ... off'. Directories listed here need to be\n\
+present also in the 'set auto-load safe-path' option."),
+ set_auto_load_dir, show_auto_load_dir,
+ auto_load_set_cmdlist_get (),
+ auto_load_show_cmdlist_get ());
+
auto_load_safe_path = xstrdup (AUTO_LOAD_SAFE_PATH);
auto_load_safe_path_vec_update ();
add_setshow_optional_filename_cmd ("safe-path", class_support,
Index: gdb-7.4.50.20120120/gdb/config.in
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/config.in 2012-05-09 22:14:04.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/config.in 2012-05-09 22:17:16.417914182 +0200
@@ -7,6 +7,9 @@
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
+/* Directories from which to load auto-loaded scripts. */
+#undef AUTO_LOAD_DIR
+
/* Directories safe to hold auto-loaded files. */
#undef AUTO_LOAD_SAFE_PATH
Index: gdb-7.4.50.20120120/gdb/configure
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/configure 2012-05-09 22:16:19.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/configure 2012-05-09 22:19:19.192716798 +0200
@@ -955,6 +955,7 @@ with_separate_debug_dir
with_gdb_datadir
with_relocated_sources
with_rpm
+with_auto_load_dir
with_auto_load_safe_path
enable_targets
enable_64_bit_bfd
@@ -1667,9 +1668,13 @@ Optional Packages:
automatically relocate this path for source files
--with-rpm query rpm database for missing debuginfos (yes/no,
def. auto=librpm.so)
+ --with-auto-load-dir=PATH
+ directories from which to load auto-loaded scripts,
+ use '$ddir' for -data-directory [$ddir/auto-load]
--with-auto-load-safe-path=PATH
directories safe to hold auto-loaded files, use
- $ddir for --with-gdb-datadir path [$ddir/auto-load]
+ $ddir for --with-gdb-datadir path
+ [--with-auto-load-dir]
--without-auto-load-safe-path
do not restrict auto-loaded files locations
--with-libunwind use libunwind frame unwinding support
@@ -8483,6 +8488,31 @@ $as_echo "$as_me: WARNING: $RPM_PKG_ERRO
fi
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for default auto-load directory" >&5
+$as_echo_n "checking for default auto-load directory... " >&6; }
+
+# Check whether --with-auto-load-dir was given.
+if test "${with_auto_load_dir+set}" = set; then :
+ withval=$with_auto_load_dir;
+else
+ with_auto_load_dir='$ddir/auto-load'
+fi
+
+escape_dir=`echo $with_auto_load_dir | sed 's/[$]ddir\>/\\\\\\\\\\\\&/g'`
+
+ test "x$prefix" = xNONE && prefix="$ac_default_prefix"
+ test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+ ac_define_dir=`eval echo $escape_dir`
+ ac_define_dir=`eval echo $ac_define_dir`
+
+cat >>confdefs.h <<_ACEOF
+#define AUTO_LOAD_DIR "$ac_define_dir"
+_ACEOF
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_dir" >&5
+$as_echo "$with_auto_load_dir" >&6; }
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for default auto-load safe-path" >&5
$as_echo_n "checking for default auto-load safe-path... " >&6; }
@@ -8492,7 +8522,7 @@ if test "${with_auto_load_safe_path+set}
with_auto_load_safe_path="/"
fi
else
- with_auto_load_safe_path='$ddir/auto-load'
+ with_auto_load_safe_path="$with_auto_load_dir"
fi
escape_dir=`echo $with_auto_load_safe_path | sed 's/[$]ddir\>/\\\\\\\\\\\\&/g'`
Index: gdb-7.4.50.20120120/gdb/configure.ac
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/configure.ac 2012-05-09 22:16:10.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/configure.ac 2012-05-09 22:19:08.390734167 +0200
@@ -339,16 +339,26 @@ extern rpmdbMatchIterator rpmtsInitItera
fi
fi
+AC_MSG_CHECKING([for default auto-load directory])
+AC_ARG_WITH(auto-load-dir,
+AS_HELP_STRING([--with-auto-load-dir=PATH],
+ [directories from which to load auto-loaded scripts, use '$ddir' for -data-directory @<:@$ddir/auto-load@:>@]),,
+ [with_auto_load_dir='$ddir/auto-load'])
+escape_dir=`echo $with_auto_load_dir | sed 's/[[$]]ddir\>/\\\\\\\\\\\\&/g'`
+AC_DEFINE_DIR(AUTO_LOAD_DIR, escape_dir,
+ [Directories from which to load auto-loaded scripts.])
+AC_MSG_RESULT([$with_auto_load_dir])
+
AC_MSG_CHECKING([for default auto-load safe-path])
AC_ARG_WITH(auto-load-safe-path,
AS_HELP_STRING([--with-auto-load-safe-path=PATH],
- [directories safe to hold auto-loaded files, use $ddir for --with-gdb-datadir path @<:@$ddir/auto-load@:>@])
+ [directories safe to hold auto-loaded files, use $ddir for --with-gdb-datadir path @<:@--with-auto-load-dir@:>@])
AS_HELP_STRING([--without-auto-load-safe-path],
[do not restrict auto-loaded files locations]),
[if test "$with_auto_load_safe_path" = "no"; then
with_auto_load_safe_path="/"
fi],
-[with_auto_load_safe_path='$ddir/auto-load'])
+[with_auto_load_safe_path="$with_auto_load_dir"])
escape_dir=`echo $with_auto_load_safe_path | sed 's/[[$]]ddir\>/\\\\\\\\\\\\&/g'`
AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir,
[Directories safe to hold auto-loaded files.])
Index: gdb-7.4.50.20120120/gdb/doc/gdb.texinfo
===================================================================
--- gdb-7.4.50.20120120.orig/gdb/doc/gdb.texinfo 2012-05-09 22:16:43.000000000 +0200
+++ gdb-7.4.50.20120120/gdb/doc/gdb.texinfo 2012-05-09 22:18:38.294782549 +0200
@@ -20804,6 +20804,8 @@ local-gdbinit: Auto-loading of .gdbinit
python-scripts: Auto-loading of Python scripts is on.
safe-path: List of directories from which it is safe to auto-load files
is $ddir/auto-load.
+scripts-directory: List of directories from which to load auto-loaded scripts
+ is $ddir/auto-load.
@end smallexample
@anchor{info auto-load}
@@ -20864,6 +20866,10 @@ These are @value{GDBN} control commands
@tab Show setting of @value{GDBN} Python scripts.
@item @xref{info auto-load python-scripts}.
@tab Show state of @value{GDBN} Python scripts.
+@item @xref{set auto-load scripts-directory}.
+@tab Control for @value{GDBN} auto-loaded scripts location.
+@item @xref{show auto-load scripts-directory}.
+@tab Show @value{GDBN} auto-loaded scripts location.
@item @xref{set auto-load local-gdbinit}.
@tab Control for init file in the current directory.
@item @xref{show auto-load local-gdbinit}.
@@ -21040,15 +21046,13 @@ loading and execution of scripts. Multi
host platform directory separator in use.
@end table
-This variable defaults to @file{$ddir/auto-load}. The default @code{set
+This variable defaults to what @code{--with-auto-load-dir} has been configured
+to (@pxref{with-auto-load-dir}). @file{$ddir} substituation applies the same
+as for @xref{set auto-load scripts-directory}.
+The default @code{set
auto-load safe-path} value can be also overriden by @value{GDBN} configuration
option @option{--with-auto-load-safe-path}.
-Any used string @file{$ddir} will get replaced by @var{data-directory} which is
-determined at @value{GDBN} startup (@pxref{Data Files}). @file{$ddir} must be
-be placed as a directory component --- either alone or delimited by @file{/} or
-@file{\} directory separators, depending on the host platform.
-
Setting this variable to @file{/} disables this security protection,
corresponding @value{GDBN} configuration option is
@option{--without-auto-load-safe-path}.
@@ -25135,7 +25139,7 @@ registering objfile-specific pretty-prin
@cindex @file{@var{objfile}-gdb.py}
When a new object file is read, @value{GDBN} looks for
-a file named @file{@var{objfile}-gdb.py},
+a file named @file{@var{objfile}-gdb.py} (we call it @var{script-name} below),
where @var{objfile} is the object file's real name, formed by ensuring
that the file name is absolute, following all symlinks, and resolving
@code{.} and @code{..} components. If this file exists and is
@@ -25143,14 +25147,42 @@ readable, @value{GDBN} will evaluate it
If this file does not exist, and if the parameter
@code{debug-file-directory} is set (@pxref{Separate Debug Files}),
-then @value{GDBN} will look for @var{real-name} in all of the
+then @value{GDBN} will look for @var{script-name} in all of the
directories mentioned in the value of @code{debug-file-directory}.
Finally, if this file does not exist, then @value{GDBN} will look for
-a file named @file{@var{data-directory}/python/auto-load/@var{real-name}}, where
-@var{data-directory} is @value{GDBN}'s data directory (available via
-@code{show data-directory}, @pxref{Data Files}), and @var{real-name}
-is the object file's real name, as described above.
+@var{script-name} file in all of the directories specified by:
+
+@table @code
+@anchor{set auto-load scripts-directory}
+@kindex set auto-load scripts-directory
+@item set auto-load scripts-directory @r{[}@var{directories}@r{]}
+Control @value{GDBN} auto-loaded scripts location. Multiple directory entries
+may be delimited by the host platform path separator in use
+(@samp{:} on Unix, @samp{;} on MS-Windows and MS-DOS).
+
+Each entry here needs to be covered also by the security setting
+@code{set auto-load safe-path} (@pxref{set auto-load safe-path}).
+
+@anchor{with-auto-load-dir}
+This variable defaults to @file{$ddir/auto-load}. The default @code{set
+auto-load safe-path} value can be also overriden by @value{GDBN} configuration
+option @option{--with-auto-load-dir}.
+
+Any used string @file{$ddir} will get replaced by @var{data-directory} which is
+determined at @value{GDBN} startup (@pxref{Data Files}). @file{$ddir} must be
+be placed as a directory component --- either alone or delimited by @file{/} or
+@file{\} directory separators, depending on the host platform.
+
+The list of directories uses path separator (@samp{:} on GNU and Unix
+systems, @samp{;} on MS-Windows and MS-DOS) to separate directories, similarly
+to the @env{PATH} environment variable.
+
+@anchor{show auto-load scripts-directory}
+@kindex show auto-load scripts-directory
+@item show auto-load scripts-directory
+Show @value{GDBN} auto-loaded scripts location.
+@end table
@value{GDBN} does not track which files it has already auto-loaded this way.
@value{GDBN} will load the associated script every time the corresponding

View File

@ -35,7 +35,7 @@ Version: 7.4.50.%{snap}
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
Release: 43%{?dist}
Release: 44%{?dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and BSD and Public Domain
Group: Development/Debuggers
@ -590,24 +590,28 @@ Patch661: gdb-stale-frame_info.patch
# Security fix for loading untrusted inferiors, see "set auto-load" (BZ 756117).
#=push
Patch662: gdb-autoload-01of18.patch
Patch663: gdb-autoload-02of18.patch
Patch664: gdb-autoload-03of18.patch
Patch665: gdb-autoload-04of18.patch
Patch666: gdb-autoload-05of18.patch
Patch667: gdb-autoload-06of18.patch
Patch668: gdb-autoload-07of18.patch
Patch669: gdb-autoload-08of18.patch
Patch670: gdb-autoload-09of18.patch
Patch671: gdb-autoload-10of18.patch
Patch672: gdb-autoload-11of18.patch
Patch673: gdb-autoload-12of18.patch
Patch674: gdb-autoload-13of18.patch
Patch675: gdb-autoload-14of18.patch
Patch676: gdb-autoload-15of18.patch
Patch677: gdb-autoload-16of18.patch
Patch678: gdb-autoload-17of18.patch
Patch679: gdb-autoload-18of18.patch
Patch662: gdb-autoload-01of22.patch
Patch663: gdb-autoload-02of22.patch
Patch664: gdb-autoload-03of22.patch
Patch665: gdb-autoload-04of22.patch
Patch666: gdb-autoload-05of22.patch
Patch667: gdb-autoload-06of22.patch
Patch668: gdb-autoload-07of22.patch
Patch669: gdb-autoload-08of22.patch
Patch670: gdb-autoload-09of22.patch
Patch671: gdb-autoload-10of22.patch
Patch672: gdb-autoload-11of22.patch
Patch673: gdb-autoload-12of22.patch
Patch674: gdb-autoload-13of22.patch
Patch675: gdb-autoload-14of22.patch
Patch676: gdb-autoload-15of22.patch
Patch677: gdb-autoload-16of22.patch
Patch678: gdb-autoload-17of22.patch
Patch679: gdb-autoload-18of22.patch
Patch680: gdb-autoload-19of22.patch
Patch681: gdb-autoload-20of22.patch
Patch682: gdb-autoload-21of22.patch
Patch683: gdb-autoload-22of22.patch
%if 0%{!?rhel:1} || 0%{?rhel} > 6
# RL_STATE_FEDORA_GDB would not be found for:
@ -917,6 +921,10 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
%patch677 -p1
%patch678 -p1
%patch679 -p1
%patch680 -p1
%patch681 -p1
%patch682 -p1
%patch683 -p1
%patch393 -p1
%if 0%{!?el5:1} || 0%{?scl:1}
@ -1038,9 +1046,9 @@ $(: RHEL-5 librpm has incompatible API. ) \
%else
--disable-inprocess-agent \
%endif
$(: %{_bindir}/mono-gdb.py is workaround for mono BZ 815501. ) \
$(: for the scl part see unfixed BZ 815910. ) \
--with-auto-load-safe-path=%{_datadir}/gdb/auto-load:/usr/lib/debug%{?scl::%{_root_datadir}/gdb/auto-load}:%{_root_bindir}/mono-gdb.py \
$(: %{_bindir}/mono-gdb.py is workaround for mono BZ 815501. ) \
--with-auto-load-dir='$ddir/auto-load%{?scl::%{_root_datadir}/gdb/auto-load}' \
--with-auto-load-safe-path='$ddir/auto-load%{?scl::%{_root_datadir}/gdb/auto-load}:/usr/lib/debug:%{_root_bindir}/mono-gdb.py' \
%ifarch sparc sparcv9
sparc-%{_vendor}-%{_target_os}%{?_gnu}
%else
@ -1401,6 +1409,9 @@ fi
%endif # 0%{!?el5:1} || "%{_target_cpu}" == "noarch"
%changelog
* Wed May 9 2012 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.4.50.20120120-44.fc17
- Fix in "set auto-load" patchset for SCL scripts inheritance (BZ 815910).
* Wed Apr 25 2012 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.4.50.20120120-43.fc17
- [RHEL5] Workaround kernel for detaching SIGSTOPped processes (BZ 809382).