Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch 2/2] Implement multi-component --with-auto-load-dir
@ 2012-05-09 15:49 Jan Kratochvil
  2012-05-09 17:50 ` Eli Zaretskii
  2012-05-09 20:18 ` Joel Brobecker
  0 siblings, 2 replies; 14+ messages in thread
From: Jan Kratochvil @ 2012-05-09 15:49 UTC (permalink / raw)
  To: gdb-patches

Hi,

currently GDB has hard-coded GDB_DATADIR/auto-load for the auto-loaded
scripts.  The problem is one may need more of such directories as you may have
multiple package sets / packages on the same system in different
subdirectories overriding each other in some order.

Therefore created 'set auto-load scripts-directory' for it.  There are some
discrepancies that --with-auto-load-dir is "auto-load" in general while
'set auto-load scripts-directory' looks scripts-specific.  GDB currently
already uses "auto-load" directory name so the general form looks more logical
but I found 'set auto-load directory' not clear enough in the list

(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.
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:/tmp/foo.
scripts-directory:  List of directories with auto-loaded scripts is $ddir/auto-load.

that it really applies just to gdb-scripts and python-scripts there.
Maybe 'set libthread-db-search-path' could be renamed
to 'set auto-load libthread-db-directory' etc., I did not go so far.

I am sorry I have made a bit "kitchen sink" even this patch, such as the
debug_auto_load output and some docs fixes.  I find it all just to be fix ups
of the already checked-in auto-load patchset.

No regressions on {x86_64,x86_64-m32,i686}-fedora17-linux-gnu.


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

--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -172,6 +172,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 with 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.
@@ -183,10 +189,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
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -108,6 +108,35 @@ show_auto_load_local_gdbinit (struct ui_file *file, int from_tty,
 		    value);
 }
 
+/* Directory list with 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 with 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 *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 *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 *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 for untrusted inferiors."),
 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 with auto-loaded scripts."), _("\
+Show the list of directories with 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,
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -3,6 +3,9 @@
 /* Define if building universal (internal helper macro) */
 #undef AC_APPLE_UNIVERSAL_BUILD
 
+/* Directories with auto-loaded scripts. */
+#undef AUTO_LOAD_DIR
+
 /* Directories safe to hold auto-loaded files. */
 #undef AUTO_LOAD_SAFE_PATH
 
--- a/gdb/configure
+++ b/gdb/configure
@@ -778,6 +778,7 @@ enable_largefile
 with_separate_debug_dir
 with_gdb_datadir
 with_relocated_sources
+with_auto_load_dir
 with_auto_load_safe_path
 enable_targets
 enable_64_bit_bfd
@@ -1485,9 +1486,13 @@ Optional Packages:
                           [DATADIR/gdb]
   --with-relocated-sources=PATH
                           automatically relocate this path for source files
+  --with-auto-load-dir=PATH
+                          directories with 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-ia64   use libunwind frame unwinding for ia64 targets
@@ -4959,6 +4964,31 @@ _ACEOF
 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; }
 
@@ -4968,7 +4998,7 @@ if test "${with_auto_load_safe_path+set}" = set; then :
      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'`
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -136,16 +136,26 @@ AS_HELP_STRING([--with-relocated-sources=PATH], [automatically relocate this pat
               [Relocated directory for source files. ])
 ])
 
+AC_MSG_CHECKING([for default auto-load directory])
+AC_ARG_WITH(auto-load-dir,
+AS_HELP_STRING([--with-auto-load-dir=PATH],
+  [directories with 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 with 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.])
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -21008,6 +21008,8 @@ 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 $ddir/auto-load.
+scripts-directory:  List of directories with auto-loaded scripts
+                    is $ddir/auto-load.
 @end smallexample
 
 @anchor{info auto-load}
@@ -21067,6 +21069,10 @@ These are @value{GDBN} control commands for the auto-loading:
 @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}.
@@ -21243,15 +21249,13 @@ loading and execution of scripts.  Multiple entries may be delimited by the
 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}.
@@ -25447,7 +25451,7 @@ registering objfile-specific pretty-printers.
 @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
@@ -25455,14 +25459,41 @@ readable, @value{GDBN} will evaluate it as a Python script.
 
 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}/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 directory separator in use.
+
+Each entry here needs to be covered also by the security setting
+@xref{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 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.
+
+@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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 2/2] Implement multi-component --with-auto-load-dir
  2012-05-09 15:49 [patch 2/2] Implement multi-component --with-auto-load-dir Jan Kratochvil
@ 2012-05-09 17:50 ` Eli Zaretskii
  2012-05-09 18:04   ` Jan Kratochvil
                     ` (2 more replies)
  2012-05-09 20:18 ` Joel Brobecker
  1 sibling, 3 replies; 14+ messages in thread
From: Eli Zaretskii @ 2012-05-09 17:50 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

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

> +Set the list of directories with auto-loaded scripts."), _("\
> +Show the list of directories with auto-loaded scripts."), _("\

Likewise here.

> +may be delimited by the host platform directory separator in use.

I believe the correct term is "path separator".  I suggest to say

  (@samp{:} on Unix, @samp{;} on Windows and DOS)

for clarity here, and not further down.

> +Each entry here needs to be covered also by the security setting
> +@xref{set auto-load safe-path}.
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You want "(@pxref{...})" here.

OK with these changes.

Thanks.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 2/2] Implement multi-component --with-auto-load-dir
  2012-05-09 17:50 ` Eli Zaretskii
@ 2012-05-09 18:04   ` Jan Kratochvil
  2012-05-09 18:45     ` Eli Zaretskii
  2012-05-09 18:44   ` [doc patch] path vs. directory separator [Re: [patch 2/2] Implement multi-component --with-auto-load-dir] Jan Kratochvil
  2012-05-09 18:55   ` [patch 2/2] Implement multi-component --with-auto-load-dir Jan Kratochvil
  2 siblings, 1 reply; 14+ messages in thread
From: Jan Kratochvil @ 2012-05-09 18:04 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On Wed, 09 May 2012 19:47:07 +0200, Eli Zaretskii wrote:
> > +Each entry here needs to be covered also by the security setting
> > +@xref{set auto-load safe-path}.
>    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> You want "(@pxref{...})" here.

This sentence would not be terminated:
	Each entry here needs to be covered also by the security setting
	(@pxref{set auto-load safe-path}).

I assume you mean:
	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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [doc patch] path vs. directory separator  [Re: [patch 2/2] Implement multi-component --with-auto-load-dir]
  2012-05-09 17:50 ` Eli Zaretskii
  2012-05-09 18:04   ` Jan Kratochvil
@ 2012-05-09 18:44   ` Jan Kratochvil
  2012-05-09 19:21     ` Eli Zaretskii
  2012-05-09 18:55   ` [patch 2/2] Implement multi-component --with-auto-load-dir Jan Kratochvil
  2 siblings, 1 reply; 14+ messages in thread
From: Jan Kratochvil @ 2012-05-09 18:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On Wed, 09 May 2012 19:47:07 +0200, Eli Zaretskii wrote:
> > +may be delimited by the host platform directory separator in use.
> 
> I believe the correct term is "path separator".  I suggest to say
> 
>   (@samp{:} on Unix, @samp{;} on Windows and DOS)
> 
> for clarity here, and not further down.

This means current doc needs there fixes, doesn't it?


Thanks,
Jan


gdb/doc/
2012-05-09  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.texinfo (Separate Debug Files, Auto-loading safe path): Replace
	directory separator by path separator.

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index ad9edac..dac3a8d 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -1,39864 +1,39864 @@
 @node Separate Debug Files
-information files to @var{directory}.  Multiple directory components can be set
-concatenating them by a directory separator.
+information files to @var{directory}.  Multiple path components can be set
+concatenating them by a path separator.
 @node Auto-loading safe path
-The list of directories uses directory separator (@samp{:} on GNU and Unix
+The list of directories uses path separator (@samp{:} on GNU and Unix
-host platform directory separator in use.
+host platform path separator in use.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 2/2] Implement multi-component --with-auto-load-dir
  2012-05-09 18:04   ` Jan Kratochvil
@ 2012-05-09 18:45     ` Eli Zaretskii
  0 siblings, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2012-05-09 18:45 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

> Date: Wed, 9 May 2012 20:03:35 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: gdb-patches@sourceware.org
> 
> On Wed, 09 May 2012 19:47:07 +0200, Eli Zaretskii wrote:
> > > +Each entry here needs to be covered also by the security setting
> > > +@xref{set auto-load safe-path}.
> >    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > You want "(@pxref{...})" here.
> 
> This sentence would not be terminated:
> 	Each entry here needs to be covered also by the security setting
> 	(@pxref{set auto-load safe-path}).

Yes, it would; it just will have a different meaning from what you
evidently intended to say ;-)

> I assume you mean:
> 	Each entry here needs to be covered also by the security setting
> 	@code{set auto-load safe-path} (@pxref{set auto-load safe-path}).

I assume you meant that ;-)


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 2/2] Implement multi-component --with-auto-load-dir
  2012-05-09 17:50 ` Eli Zaretskii
  2012-05-09 18:04   ` Jan Kratochvil
  2012-05-09 18:44   ` [doc patch] path vs. directory separator [Re: [patch 2/2] Implement multi-component --with-auto-load-dir] Jan Kratochvil
@ 2012-05-09 18:55   ` Jan Kratochvil
  2012-05-09 19:23     ` Eli Zaretskii
  2012-05-11 18:21     ` [commit] " Jan Kratochvil
  2 siblings, 2 replies; 14+ messages in thread
From: Jan Kratochvil @ 2012-05-09 18:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

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

--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -172,6 +172,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.
@@ -183,10 +189,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
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -108,6 +108,35 @@ show_auto_load_local_gdbinit (struct ui_file *file, int from_tty,
 		    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 *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 *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 *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 for untrusted inferiors."),
 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,
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -3,6 +3,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
 
--- a/gdb/configure
+++ b/gdb/configure
@@ -778,6 +778,7 @@ enable_largefile
 with_separate_debug_dir
 with_gdb_datadir
 with_relocated_sources
+with_auto_load_dir
 with_auto_load_safe_path
 enable_targets
 enable_64_bit_bfd
@@ -1485,9 +1486,13 @@ Optional Packages:
                           [DATADIR/gdb]
   --with-relocated-sources=PATH
                           automatically relocate this path for source files
+  --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-ia64   use libunwind frame unwinding for ia64 targets
@@ -4959,6 +4964,31 @@ _ACEOF
 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; }
 
@@ -4968,7 +4998,7 @@ if test "${with_auto_load_safe_path+set}" = set; then :
      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'`
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -136,16 +136,26 @@ AS_HELP_STRING([--with-relocated-sources=PATH], [automatically relocate this pat
               [Relocated directory for source files. ])
 ])
 
+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.])
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -21008,6 +21008,8 @@ 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 $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}
@@ -21067,6 +21069,10 @@ These are @value{GDBN} control commands for the auto-loading:
 @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}.
@@ -21243,15 +21249,13 @@ loading and execution of scripts.  Multiple entries may be delimited by the
 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}.
@@ -25447,7 +25451,7 @@ registering objfile-specific pretty-printers.
 @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
@@ -25455,14 +25459,42 @@ readable, @value{GDBN} will evaluate it as a Python script.
 
 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}/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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [doc patch] path vs. directory separator  [Re: [patch 2/2] Implement multi-component --with-auto-load-dir]
  2012-05-09 18:44   ` [doc patch] path vs. directory separator [Re: [patch 2/2] Implement multi-component --with-auto-load-dir] Jan Kratochvil
@ 2012-05-09 19:21     ` Eli Zaretskii
  2012-05-09 19:30       ` [commit] " Jan Kratochvil
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2012-05-09 19:21 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

> Date: Wed, 9 May 2012 20:43:41 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: gdb-patches@sourceware.org
> 
> On Wed, 09 May 2012 19:47:07 +0200, Eli Zaretskii wrote:
> > > +may be delimited by the host platform directory separator in use.
> > 
> > I believe the correct term is "path separator".  I suggest to say
> > 
> >   (@samp{:} on Unix, @samp{;} on Windows and DOS)
> > 
> > for clarity here, and not further down.
> 
> This means current doc needs there fixes, doesn't it?

Yes, please.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 2/2] Implement multi-component --with-auto-load-dir
  2012-05-09 18:55   ` [patch 2/2] Implement multi-component --with-auto-load-dir Jan Kratochvil
@ 2012-05-09 19:23     ` Eli Zaretskii
  2012-05-11 18:21     ` [commit] " Jan Kratochvil
  1 sibling, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2012-05-09 19:23 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

> Date: Wed, 9 May 2012 20:54:29 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: gdb-patches@sourceware.org
> 
> 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.

Using "the" is fine; my comment was about the "directories with
scripts" part.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [commit] [doc patch] path vs. directory separator  [Re: [patch 2/2] Implement multi-component --with-auto-load-dir]
  2012-05-09 19:21     ` Eli Zaretskii
@ 2012-05-09 19:30       ` Jan Kratochvil
  0 siblings, 0 replies; 14+ messages in thread
From: Jan Kratochvil @ 2012-05-09 19:30 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On Wed, 09 May 2012 21:18:17 +0200, Eli Zaretskii wrote:
> > This means current doc needs there fixes, doesn't it?
> 
> Yes, please.

Checked in.


Thanks,
Jan


http://sourceware.org/ml/gdb-cvs/2012-05/msg00060.html

--- src/gdb/doc/ChangeLog	2012/05/09 18:15:58	1.1310
+++ src/gdb/doc/ChangeLog	2012/05/09 19:29:25	1.1311
@@ -3,6 +3,9 @@
 	* gdb.texinfo (Auto-loading): Wrap too long lines in @smallexample.
 	Twice.
 
+	* gdb.texinfo (Separate Debug Files, Auto-loading safe path): Replace
+	directory separator by path separator.
+
 2012-05-06  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
 	* gdb.texinfo (Auto-loading safe path): Make 'directories'
--- src/gdb/doc/gdb.texinfo	2012/05/09 18:15:58	1.956
+++ src/gdb/doc/gdb.texinfo	2012/05/09 19:29:25	1.957
@@ -16285,8 +16285,8 @@
 @kindex set debug-file-directory
 @item set debug-file-directory @var{directories}
 Set the directories which @value{GDBN} searches for separate debugging
-information files to @var{directory}.  Multiple directory components can be set
-concatenating them by a directory separator.
+information files to @var{directory}.  Multiple path components can be set
+concatenating them by a path separator.
 
 @kindex show debug-file-directory
 @item show debug-file-directory
@@ -21227,7 +21227,7 @@
 If you omit @var{directories}, @samp{auto-load safe-path} will be reset to
 its default value as specified during @value{GDBN} compilation.
 
-The list of directories uses directory 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
 to the @env{PATH} environment variable.
 
@@ -21242,7 +21242,7 @@
 @item add-auto-load-safe-path
 Add an entry (or list of entries) the list of directories trusted for automatic
 loading and execution of scripts.  Multiple entries may be delimited by the
-host platform directory separator in use.
+host platform path separator in use.
 @end table
 
 Setting this variable to @file{/} disables this security protection.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 2/2] Implement multi-component --with-auto-load-dir
  2012-05-09 15:49 [patch 2/2] Implement multi-component --with-auto-load-dir Jan Kratochvil
  2012-05-09 17:50 ` Eli Zaretskii
@ 2012-05-09 20:18 ` Joel Brobecker
  2012-05-09 20:34   ` Jan Kratochvil
  1 sibling, 1 reply; 14+ messages in thread
From: Joel Brobecker @ 2012-05-09 20:18 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

Hi Jan,

> currently GDB has hard-coded GDB_DATADIR/auto-load for the auto-loaded
> scripts.  The problem is one may need more of such directories as you may have
> multiple package sets / packages on the same system in different
> subdirectories overriding each other in some order.
> 
> Therefore created 'set auto-load scripts-directory' for it.

I really do not understand what this new setting is about.  Can you
just give me a quick concrete example of what wouldn't work with
the current code, and how this gets solved by the new setting?

I was hoping at some point that this would allow us to have auto-loaded
scripts without having to have the same path structure in the auto-load
directory as in the executable (by that, I mean that if you are
debugging /work/build/gcc-feature-a/gcc/cc1, you don't need to have
cc1-gdb.gdb defined in your auto-load directory as
auto-load/work/build/gcc-feature-a/gcc/cc1-gdb.gdb. It'd just be
sufficient to have cc1-gdb.gdb defined in your scripts-directory.
But looking at the code, I don't think that this is what we are
talking about.

-- 
Joel


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 2/2] Implement multi-component --with-auto-load-dir
  2012-05-09 20:18 ` Joel Brobecker
@ 2012-05-09 20:34   ` Jan Kratochvil
  2012-05-09 20:51     ` Joel Brobecker
  0 siblings, 1 reply; 14+ messages in thread
From: Jan Kratochvil @ 2012-05-09 20:34 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

Hi Joel,

On Wed, 09 May 2012 22:17:43 +0200, Joel Brobecker wrote:
> I really do not understand what this new setting is about.  Can you
> just give me a quick concrete example of what wouldn't work with
> the current code, and how this gets solved by the new setting?

With Fedora scl-utils ("alternative packaging") you have both regular
	/usr/share/gdb/auto-load/
and also the "alternative"
	/opt/rh/upgradeset/root/usr/share/gdb/auto-load/

as there is both regular GDB and the "upgradeset" (=newer) GDB.
While for example libstdc++ Pretty Printers is located in both
(coincidentally, because it is bundled with GDB in some versions):
	/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.16-gdb.py
	/opt/rh/upgradeset/root/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.16-gdb.py

with the latter variant having more recent GDB macros and therefore preferred
by newer GDB located in
	/opt/rh/upgradeset/root/usr/bin/gdb
which is using its default configured
	/opt/rh/upgradeset/root/usr/share/gdb/auto-load/

it will be a problem that
	/usr/share/gdb/auto-load/lib64/libglib-2.0.so.0.3000.3-gdb.py

is not loaded at all because it does not have any "upgradeset" variant in
	/opt/rh/upgradeset/root/usr/share/gdb/auto-load/
.

This means we need multiple auto-load/ directories (unless we want to
introduce some shell scripting symlinks magic etc.).


> I was hoping at some point that this would allow us to have auto-loaded
> scripts without having to have the same path structure in the auto-load
> directory as in the executable (by that, I mean that if you are
> debugging /work/build/gcc-feature-a/gcc/cc1, you don't need to have
> cc1-gdb.gdb defined in your auto-load directory as
> auto-load/work/build/gcc-feature-a/gcc/cc1-gdb.gdb. It'd just be
> sufficient to have cc1-gdb.gdb defined in your scripts-directory.
> But looking at the code, I don't think that this is what we are
> talking about.

I do not think these two features are related.  I can think about some ideas
but I do not see a super-elegant one for it now.


Thanks,
Jan


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 2/2] Implement multi-component --with-auto-load-dir
  2012-05-09 20:34   ` Jan Kratochvil
@ 2012-05-09 20:51     ` Joel Brobecker
  2012-05-11 18:47       ` Jan Kratochvil
  0 siblings, 1 reply; 14+ messages in thread
From: Joel Brobecker @ 2012-05-09 20:51 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

> With Fedora scl-utils ("alternative packaging") you have both regular
> 	/usr/share/gdb/auto-load/
> and also the "alternative"
> 	/opt/rh/upgradeset/root/usr/share/gdb/auto-load/

I see.  I wish we could manage both with one setting.  Since we need
a "list" of directories, I'd keep "auto-load script-dir" (should we make
that script-dir plural?)...

I can see how things can be awkward for turning the safety guard off
(the equivalent of what we used to do with "auto-load safe-path").
I think I'd just make that a boolean setting instead.

> > I was hoping at some point that this would allow us to have auto-loaded
> > scripts without having to have the same path structure in the auto-load
> > directory as in the executable (by that, I mean that if you are
> > debugging /work/build/gcc-feature-a/gcc/cc1, you don't need to have
> > cc1-gdb.gdb defined in your auto-load directory as
> > auto-load/work/build/gcc-feature-a/gcc/cc1-gdb.gdb. It'd just be
> > sufficient to have cc1-gdb.gdb defined in your scripts-directory.
> > But looking at the code, I don't think that this is what we are
> > talking about.
> 
> I do not think these two features are related.  I can think about some ideas
> but I do not see a super-elegant one for it now.

No, they are not related, and you shouldn't have to worry about that
(unless you want to!). It's a feature I think some users would enjoy
having, but if I want it, I should be the one taking care of the
implementation.

-- 
Joel


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [commit] [patch 2/2] Implement multi-component --with-auto-load-dir
  2012-05-09 18:55   ` [patch 2/2] Implement multi-component --with-auto-load-dir Jan Kratochvil
  2012-05-09 19:23     ` Eli Zaretskii
@ 2012-05-11 18:21     ` Jan Kratochvil
  1 sibling, 0 replies; 14+ messages in thread
From: Jan Kratochvil @ 2012-05-11 18:21 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On Wed, 09 May 2012 20:54:29 +0200, Jan Kratochvil wrote:
> 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'.

Checked in:
	http://sourceware.org/ml/gdb-cvs/2012-05/msg00081.html


Thanks,
Jan


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 2/2] Implement multi-component --with-auto-load-dir
  2012-05-09 20:51     ` Joel Brobecker
@ 2012-05-11 18:47       ` Jan Kratochvil
  0 siblings, 0 replies; 14+ messages in thread
From: Jan Kratochvil @ 2012-05-11 18:47 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On Wed, 09 May 2012 22:51:19 +0200, Joel Brobecker wrote:
> > With Fedora scl-utils ("alternative packaging") you have both regular
> > 	/usr/share/gdb/auto-load/
> > and also the "alternative"
> > 	/opt/rh/upgradeset/root/usr/share/gdb/auto-load/
> 
> I see.  I wish we could manage both with one setting.  Since we need
> a "list" of directories, I'd keep "auto-load script-dir" (should we make
> that script-dir plural?)...

We already have multi-directory "set debug-file-directory".

(It may be called so as it was a single directory in the past; OTOH if you
insist on dir/directories we should rename it and make the original setting
obsolete-compatible.)

We also have command "directory" which properly parses multiple directories:

(gdb) directory /tmp/a:/tmp/b
Warning: /tmp/a: No such file or directory.
Warning: /tmp/b: No such file or directory.
Source directories searched: /tmp/a:/tmp/b:$cdir:$cwd

We can argue about singular vs. plural form like there are many reasons for
both cases in which form to name SQL tables.


> I can see how things can be awkward for turning the safety guard off
> (the equivalent of what we used to do with "auto-load safe-path").
> I think I'd just make that a boolean setting instead.

Do you mean to make 'auto-load safe-path [on|off]'?  This would be
coincidentally fine for me as I both face untrusted inferiors and I dislike
any auto-loads.  But it would be too dangerous for anyone who likes
auto-loaded scripts and who also faces untrusted inferiors.


> > > debugging /work/build/gcc-feature-a/gcc/cc1, you don't need to have
> > > cc1-gdb.gdb defined in your auto-load directory as
> > > auto-load/work/build/gcc-feature-a/gcc/cc1-gdb.gdb. It'd just be
> > > sufficient to have cc1-gdb.gdb defined in your scripts-directory.
[...]
> No, they are not related, and you shouldn't have to worry about that
> (unless you want to!). It's a feature I think some users would enjoy
> having, but if I want it, I should be the one taking care of the
> implementation.

I understand it would be useful; I just do not like any auto-loads myself to
try figure out the best way to do it.  Also /usr/share/gdb/auto-load/ has
never been an idea of mine.


Thanks,
Jan


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-05-11 18:47 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-09 15:49 [patch 2/2] Implement multi-component --with-auto-load-dir Jan Kratochvil
2012-05-09 17:50 ` Eli Zaretskii
2012-05-09 18:04   ` Jan Kratochvil
2012-05-09 18:45     ` Eli Zaretskii
2012-05-09 18:44   ` [doc patch] path vs. directory separator [Re: [patch 2/2] Implement multi-component --with-auto-load-dir] Jan Kratochvil
2012-05-09 19:21     ` Eli Zaretskii
2012-05-09 19:30       ` [commit] " Jan Kratochvil
2012-05-09 18:55   ` [patch 2/2] Implement multi-component --with-auto-load-dir Jan Kratochvil
2012-05-09 19:23     ` Eli Zaretskii
2012-05-11 18:21     ` [commit] " Jan Kratochvil
2012-05-09 20:18 ` Joel Brobecker
2012-05-09 20:34   ` Jan Kratochvil
2012-05-09 20:51     ` Joel Brobecker
2012-05-11 18:47       ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox