* NEWS (--with-auto-load-dir): Prepend $debugdir to the default path.
	Describe it.
	* auto-load.c (auto_load_expand_dir_vars): New function.
	(auto_load_safe_path_vec_update): Use it, remove the
	substitute_path_component call thanks to it.
	(auto_load_objfile_script): Remove the debug_file_directory processing.
	Use auto_load_expand_dir_vars, remove the substitute_path_component
	call thanks to it.
	* configure: Regenerate.
	* configure.ac (--with-auto-load-dir): Prepend $debugdir to the default
	path.  Escape $ also for $debugdir.
	(--with_auto_load_safe_path): Escape $ also for $debugdir.
	* utils.c (substitute_path_component): Accept also DIRNAME_SEPARATOR.

gdb/doc/
	* gdb.texinfo (Separate Debug Files): New anchor debug-file-directory.
	Mention also --with-separate-debug-dir.
	(Auto-loading): Prepend $debugdir in the sample output.
	(Auto-loading safe path): Likewise.  Mention also $debugdir for the
	auto-load safe-path variable.
	(objfile-gdb.py file): Remove the extra debug-file-directory paragraph.
	Mention also $debugdir for 'set auto-load scripts-directory'.
This commit is contained in:
Jan Kratochvil 2012-05-20 20:35:19 +00:00
parent a3ec0bb1c4
commit 1564a2618d
8 changed files with 101 additions and 89 deletions

View file

@ -1,3 +1,19 @@
2012-05-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* NEWS (--with-auto-load-dir): Prepend $debugdir to the default path.
Describe it.
* auto-load.c (auto_load_expand_dir_vars): New function.
(auto_load_safe_path_vec_update): Use it, remove the
substitute_path_component call thanks to it.
(auto_load_objfile_script): Remove the debug_file_directory processing.
Use auto_load_expand_dir_vars, remove the substitute_path_component
call thanks to it.
* configure: Regenerate.
* configure.ac (--with-auto-load-dir): Prepend $debugdir to the default
path. Escape $ also for $debugdir.
(--with_auto_load_safe_path): Escape $ also for $debugdir.
* utils.c (substitute_path_component): Accept also DIRNAME_SEPARATOR.
2012-05-20 Doug Evans <dje@google.com> 2012-05-20 Doug Evans <dje@google.com>
* dwarf2read.c (recursively_find_pc_sect_symtab): Initialize "s" * dwarf2read.c (recursively_find_pc_sect_symtab): Initialize "s"

View file

@ -239,8 +239,10 @@ show dprintf-channel
--with-auto-load-dir --with-auto-load-dir
Configure default value for the 'set auto-load scripts-directory' Configure default value for the 'set auto-load scripts-directory'
setting above. It defaults to '$datadir/auto-load', $datadir setting above. It defaults to '$debugdir:$datadir/auto-load',
representing GDB's data directory (available via show data-directory). $debugdir representing global debugging info directories (available
via 'show debug-file-directory') and $datadir representing GDB's data
directory (available via 'show data-directory').
--with-auto-load-safe-path --with-auto-load-safe-path
Configure default value for the 'set auto-load safe-path' setting Configure default value for the 'set auto-load safe-path' setting

View file

@ -147,6 +147,30 @@ static char *auto_load_safe_path;
counterpart. */ counterpart. */
static VEC (char_ptr) *auto_load_safe_path_vec; static VEC (char_ptr) *auto_load_safe_path_vec;
/* Expand $datadir and $debugdir in STRING according to the rules of
substitute_path_component. Return vector from dirnames_to_char_ptr_vec,
this vector must be freed by free_char_ptr_vec by the caller. */
static VEC (char_ptr) *
auto_load_expand_dir_vars (const char *string)
{
VEC (char_ptr) *dir_vec;
char *s;
s = xstrdup (string);
substitute_path_component (&s, "$datadir", gdb_datadir);
substitute_path_component (&s, "$debugdir", debug_file_directory);
if (debug_auto_load && strcmp (s, string) != 0)
fprintf_unfiltered (gdb_stdlog,
_("auto-load: Expanded $-variables to \"%s\".\n"), s);
dir_vec = dirnames_to_char_ptr_vec (s);
xfree(s);
return dir_vec;
}
/* Update auto_load_safe_path_vec from current AUTO_LOAD_SAFE_PATH. */ /* Update auto_load_safe_path_vec from current AUTO_LOAD_SAFE_PATH. */
static void static void
@ -163,7 +187,7 @@ auto_load_safe_path_vec_update (void)
free_char_ptr_vec (auto_load_safe_path_vec); free_char_ptr_vec (auto_load_safe_path_vec);
auto_load_safe_path_vec = dirnames_to_char_ptr_vec (auto_load_safe_path); auto_load_safe_path_vec = auto_load_expand_dir_vars (auto_load_safe_path);
len = VEC_length (char_ptr, auto_load_safe_path_vec); len = VEC_length (char_ptr, auto_load_safe_path_vec);
/* Apply tilde_expand and gdb_realpath to each AUTO_LOAD_SAFE_PATH_VEC /* Apply tilde_expand and gdb_realpath to each AUTO_LOAD_SAFE_PATH_VEC
@ -171,16 +195,10 @@ auto_load_safe_path_vec_update (void)
for (ix = 0; ix < len; ix++) for (ix = 0; ix < len; ix++)
{ {
char *dir = VEC_index (char_ptr, auto_load_safe_path_vec, ix); char *dir = VEC_index (char_ptr, auto_load_safe_path_vec, ix);
char *ddir_subst, *expanded, *real_path; char *expanded = tilde_expand (dir);
char *real_path = gdb_realpath (expanded);
ddir_subst = xstrdup (dir); /* Ensure the current entry is at least tilde_expand-ed. */
substitute_path_component (&ddir_subst, "$datadir", 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
$datadir-expanded and tilde-expanded). */
VEC_replace (char_ptr, auto_load_safe_path_vec, ix, expanded); VEC_replace (char_ptr, auto_load_safe_path_vec, ix, expanded);
if (debug_auto_load) if (debug_auto_load)
@ -643,42 +661,6 @@ auto_load_objfile_script (struct objfile *objfile,
fprintf_unfiltered (gdb_stdlog, _("auto-load: Attempted file \"%s\" %s.\n"), fprintf_unfiltered (gdb_stdlog, _("auto-load: Attempted file \"%s\" %s.\n"),
debugfile, input ? _("exists") : _("does not exist")); debugfile, input ? _("exists") : _("does not exist"));
if (!input)
{
char *debugdir;
VEC (char_ptr) *debugdir_vec;
int ix;
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. */
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 (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) if (!input)
{ {
VEC (char_ptr) *vec; VEC (char_ptr) *vec;
@ -688,7 +670,7 @@ auto_load_objfile_script (struct objfile *objfile,
/* Also try the same file in a subdirectory of gdb's data /* Also try the same file in a subdirectory of gdb's data
directory. */ directory. */
vec = dirnames_to_char_ptr_vec (auto_load_dir); vec = auto_load_expand_dir_vars (auto_load_dir);
make_cleanup_free_char_ptr_vec (vec); make_cleanup_free_char_ptr_vec (vec);
if (debug_auto_load) if (debug_auto_load)
@ -698,10 +680,8 @@ auto_load_objfile_script (struct objfile *objfile,
for (ix = 0; VEC_iterate (char_ptr, vec, ix, dir); ++ix) for (ix = 0; VEC_iterate (char_ptr, vec, ix, dir); ++ix)
{ {
debugfile = xstrdup (dir); debugfile = xmalloc (strlen (dir) + strlen (filename) + 1);
substitute_path_component (&debugfile, "$datadir", gdb_datadir); strcpy (debugfile, dir);
debugfile = xrealloc (debugfile, (strlen (debugfile)
+ strlen (filename) + 1));
/* FILENAME is absolute, so we don't need a "/" here. */ /* FILENAME is absolute, so we don't need a "/" here. */
strcat (debugfile, filename); strcat (debugfile, filename);

8
gdb/configure vendored
View file

@ -1488,7 +1488,7 @@ Optional Packages:
automatically relocate this path for source files automatically relocate this path for source files
--with-auto-load-dir=PATH --with-auto-load-dir=PATH
directories from which to load auto-loaded scripts directories from which to load auto-loaded scripts
[$datadir/auto-load] [$debugdir:$datadir/auto-load]
--with-auto-load-safe-path=PATH --with-auto-load-safe-path=PATH
directories safe to hold auto-loaded files directories safe to hold auto-loaded files
[--with-auto-load-dir] [--with-auto-load-dir]
@ -4970,10 +4970,10 @@ $as_echo_n "checking for default auto-load directory... " >&6; }
if test "${with_auto_load_dir+set}" = set; then : if test "${with_auto_load_dir+set}" = set; then :
withval=$with_auto_load_dir; withval=$with_auto_load_dir;
else else
with_auto_load_dir='$datadir/auto-load' with_auto_load_dir='$debugdir:$datadir/auto-load'
fi fi
escape_dir=`echo $with_auto_load_dir | sed 's/[$]datadir\>/\\\\\\\\\\\\&/g'` escape_dir=`echo $with_auto_load_dir | sed 's/[$]\(datadir\|debugdir\)\>/\\\\\\\\\\\\&/g'`
test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$prefix" = xNONE && prefix="$ac_default_prefix"
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
@ -5000,7 +5000,7 @@ else
with_auto_load_safe_path="$with_auto_load_dir" with_auto_load_safe_path="$with_auto_load_dir"
fi fi
escape_dir=`echo $with_auto_load_safe_path | sed 's/[$]datadir\>/\\\\\\\\\\\\&/g'` escape_dir=`echo $with_auto_load_safe_path | sed 's/[$]\(datadir\|debugdir\)\>/\\\\\\\\\\\\&/g'`
test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$prefix" = xNONE && prefix="$ac_default_prefix"
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'

View file

@ -139,9 +139,9 @@ AS_HELP_STRING([--with-relocated-sources=PATH], [automatically relocate this pat
AC_MSG_CHECKING([for default auto-load directory]) AC_MSG_CHECKING([for default auto-load directory])
AC_ARG_WITH(auto-load-dir, AC_ARG_WITH(auto-load-dir,
AS_HELP_STRING([--with-auto-load-dir=PATH], AS_HELP_STRING([--with-auto-load-dir=PATH],
[directories from which to load auto-loaded scripts @<:@$datadir/auto-load@:>@]),, [directories from which to load auto-loaded scripts @<:@$debugdir:$datadir/auto-load@:>@]),,
[with_auto_load_dir='$datadir/auto-load']) [with_auto_load_dir='$debugdir:$datadir/auto-load'])
escape_dir=`echo $with_auto_load_dir | sed 's/[[$]]datadir\>/\\\\\\\\\\\\&/g'` escape_dir=`echo $with_auto_load_dir | sed 's/[[$]]\(datadir\|debugdir\)\>/\\\\\\\\\\\\&/g'`
AC_DEFINE_DIR(AUTO_LOAD_DIR, escape_dir, AC_DEFINE_DIR(AUTO_LOAD_DIR, escape_dir,
[Directories from which to load auto-loaded scripts.]) [Directories from which to load auto-loaded scripts.])
AC_MSG_RESULT([$with_auto_load_dir]) AC_MSG_RESULT([$with_auto_load_dir])
@ -156,7 +156,7 @@ AS_HELP_STRING([--without-auto-load-safe-path],
with_auto_load_safe_path="/" with_auto_load_safe_path="/"
fi], fi],
[with_auto_load_safe_path="$with_auto_load_dir"]) [with_auto_load_safe_path="$with_auto_load_dir"])
escape_dir=`echo $with_auto_load_safe_path | sed 's/[[$]]datadir\>/\\\\\\\\\\\\&/g'` escape_dir=`echo $with_auto_load_safe_path | sed 's/[[$]]\(datadir\|debugdir\)\>/\\\\\\\\\\\\&/g'`
AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir, AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir,
[Directories safe to hold auto-loaded files.]) [Directories safe to hold auto-loaded files.])
AC_MSG_RESULT([$with_auto_load_safe_path]) AC_MSG_RESULT([$with_auto_load_safe_path])

View file

@ -1,3 +1,13 @@
2012-05-20 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.texinfo (Separate Debug Files): New anchor debug-file-directory.
Mention also --with-separate-debug-dir.
(Auto-loading): Prepend $debugdir in the sample output.
(Auto-loading safe path): Likewise. Mention also $debugdir for the
auto-load safe-path variable.
(objfile-gdb.py file): Remove the extra debug-file-directory paragraph.
Mention also $debugdir for 'set auto-load scripts-directory'.
2012-05-19 Eli Zaretskii <eliz@gnu.org> 2012-05-19 Eli Zaretskii <eliz@gnu.org>
* gdb.texinfo (Continuing and Stepping, Selection, Byte Order) * gdb.texinfo (Continuing and Stepping, Selection, Byte Order)

View file

@ -16465,8 +16465,11 @@ debug information files, in the indicated order:
@file{/usr/lib/debug/usr/bin/ls.debug}. @file{/usr/lib/debug/usr/bin/ls.debug}.
@end itemize @end itemize
You can set the global debugging info directories, and view the @anchor{debug-file-directory}
list @value{GDBN} is currently using. Global debugging info directories default to what is set by @value{GDBN}
configure option @option{--with-separate-debug-dir}. During @value{GDBN} run
you can also set the global debugging info directories, and view the list
@value{GDBN} is currently using.
@table @code @table @code
@ -21232,9 +21235,9 @@ local-gdbinit: Auto-loading of .gdbinit script from current directory
is on. is on.
python-scripts: Auto-loading of Python scripts 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 safe-path: List of directories from which it is safe to auto-load files
is $datadir/auto-load. is $debugdir:$datadir/auto-load.
scripts-directory: List of directories from which to load auto-loaded scripts scripts-directory: List of directories from which to load auto-loaded scripts
is $datadir/auto-load. is $debugdir:$datadir/auto-load.
@end smallexample @end smallexample
@anchor{info auto-load} @anchor{info auto-load}
@ -21450,9 +21453,11 @@ get loaded:
$ ./gdb -q ./gdb $ ./gdb -q ./gdb
Reading symbols from /home/user/gdb/gdb...done. Reading symbols from /home/user/gdb/gdb...done.
warning: File "/home/user/gdb/gdb-gdb.gdb" auto-loading has been warning: File "/home/user/gdb/gdb-gdb.gdb" auto-loading has been
declined by your `auto-load safe-path' set to "$datadir/auto-load". declined by your `auto-load safe-path' set
to "$debugdir:$datadir/auto-load".
warning: File "/home/user/gdb/gdb-gdb.py" auto-loading has been warning: File "/home/user/gdb/gdb-gdb.py" auto-loading has been
declined by your `auto-load safe-path' set to "$datadir/auto-load". declined by your `auto-load safe-path' set
to "$debugdir:$datadir/auto-load".
@end smallexample @end smallexample
The list of trusted directories is controlled by the following commands: The list of trusted directories is controlled by the following commands:
@ -21485,11 +21490,10 @@ host platform path separator in use.
@end table @end table
This variable defaults to what @code{--with-auto-load-dir} has been configured This variable defaults to what @code{--with-auto-load-dir} has been configured
to (@pxref{with-auto-load-dir}). @file{$datadir} substituation applies the same to (@pxref{with-auto-load-dir}). @file{$debugdir} and @file{$datadir}
as for @xref{set auto-load scripts-directory}. substitution applies the same as for @ref{set auto-load scripts-directory}.
The default @code{set The default @code{set auto-load safe-path} value can be also overriden by
auto-load safe-path} value can be also overriden by @value{GDBN} configuration @value{GDBN} configuration option @option{--with-auto-load-safe-path}.
option @option{--with-auto-load-safe-path}.
Setting this variable to @file{/} disables this security protection, Setting this variable to @file{/} disables this security protection,
corresponding @value{GDBN} configuration option is corresponding @value{GDBN} configuration option is
@ -25701,12 +25705,7 @@ that the file name is absolute, following all symlinks, and resolving
@code{.} and @code{..} components. If this file exists and is @code{.} and @code{..} components. If this file exists and is
readable, @value{GDBN} will evaluate it as a Python script. readable, @value{GDBN} will evaluate it as a Python script.
If this file does not exist, and if the parameter If this file does not exist, then @value{GDBN} will look for
@code{debug-file-directory} is set (@pxref{Separate Debug Files}),
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
@var{script-name} file in all of the directories as specified below. @var{script-name} file in all of the directories as specified below.
Note that loading of this script file also requires accordingly configured Note that loading of this script file also requires accordingly configured
@ -25724,14 +25723,17 @@ Each entry here needs to be covered also by the security setting
@code{set auto-load safe-path} (@pxref{set auto-load safe-path}). @code{set auto-load safe-path} (@pxref{set auto-load safe-path}).
@anchor{with-auto-load-dir} @anchor{with-auto-load-dir}
This variable defaults to @file{$datadir/auto-load}. The default @code{set This variable defaults to @file{$debugdir:$datadir/auto-load}. The default
auto-load safe-path} value can be also overriden by @value{GDBN} configuration @code{set auto-load safe-path} value can be also overriden by @value{GDBN}
option @option{--with-auto-load-dir}. configuration option @option{--with-auto-load-dir}.
Any used string @file{$datadir} will get replaced by @var{data-directory} which Any reference to @file{$debugdir} will get replaced by
is determined at @value{GDBN} startup (@pxref{Data Files}). @file{$datadir} @var{debug-file-directory} value (@pxref{Separate Debug Files}) and any
must be placed as a directory component --- either alone or delimited by reference to @file{$datadir} will get replaced by @var{data-directory} which is
@file{/} or @file{\} directory separators, depending on the host platform. determined at @value{GDBN} startup (@pxref{Data Files}). @file{$debugdir} and
@file{$datadir} must 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 The list of directories uses path separator (@samp{:} on GNU and Unix
systems, @samp{;} on MS-Windows and MS-DOS) to separate directories, similarly systems, @samp{;} on MS-Windows and MS-DOS) to separate directories, similarly

View file

@ -3726,8 +3726,8 @@ dirnames_to_char_ptr_vec (const char *dirnames)
/* Substitute all occurences of string FROM by string TO in *STRINGP. *STRINGP /* Substitute all occurences of string FROM by string TO in *STRINGP. *STRINGP
must come from xrealloc-compatible allocator and it may be updated. FROM 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 needs to be delimited by IS_DIR_SEPARATOR or DIRNAME_SEPARATOR (or be
end of *STRINGP. */ located at the start or end of *STRINGP. */
void void
substitute_path_component (char **stringp, const char *from, const char *to) substitute_path_component (char **stringp, const char *from, const char *to)
@ -3742,8 +3742,10 @@ substitute_path_component (char **stringp, const char *from, const char *to)
if (s == NULL) if (s == NULL)
break; break;
if ((s == string || IS_DIR_SEPARATOR (s[-1])) if ((s == string || IS_DIR_SEPARATOR (s[-1])
&& (s[from_len] == '\0' || IS_DIR_SEPARATOR (s[from_len]))) || s[-1] == DIRNAME_SEPARATOR)
&& (s[from_len] == '\0' || IS_DIR_SEPARATOR (s[from_len])
|| s[from_len] == DIRNAME_SEPARATOR))
{ {
char *string_new; char *string_new;