* [patch+7.5] auto-load: User conveniences suggested by Doug Evans
@ 2012-08-21 14:44 Jan Kratochvil
2012-08-21 17:50 ` Eli Zaretskii
2012-08-22 15:46 ` Pedro Alves
0 siblings, 2 replies; 26+ messages in thread
From: Jan Kratochvil @ 2012-08-21 14:44 UTC (permalink / raw)
To: gdb-patches; +Cc: Doug Evans
Hi,
according to user feedback after gdb-7.5 with the auto-load feature considered
by users as pain I have implemented various backward compatible extensions
suggested by Doug.
* Make new full explanatory message for forbidden auto-load file attempt.
Display it only once per session.
Particularly suggest how to set it up in ~/.gdbinit.
* "set auto-load scripts-directory" should specifically mention *-gdb.gdb and
*-gdb.py to prevent confusion with the unrelated section .debug_gdb_scripts.
* "set auto-load safe-path" may contain also files, not just directories.
Doug said the files should not be allowed there, I did not understand why,
but as it is now released in gdb-7.5 it is too late for any change anyway.
So at least document it in "help set auto-load safe-path"; GDB Manual
already documents it.
No regressions on {x86_64,x86_64-m32,i686}-fedora18-linux-gnu.
Thanks,
Jan
gdb/
2012-08-21 Jan Kratochvil <jan.kratochvil@redhat.com>
Implement auto-load user conveniences suggested by Doug Evans.
* auto-load.c: Include top.h.
(file_is_auto_load_safe): New variable advice_printed. Print advice.
(_initialize_auto_load): New variable scripts_directory_help. Mention
GDBPY_AUTO_FILE_NAME and GDB_AUTO_FILE_NAME for set auto-load
scripts-directory. Document in online help one can use also files for
set auto-load safe-path.
* python/py-auto-load.c: (GDBPY_AUTO_FILE_NAME): Move it from here ...
* python/python.h (GDBPY_AUTO_FILE_NAME): ... to here.
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 03a7539..cf33d1d 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -37,6 +37,7 @@
#include "completer.h"
#include "observer.h"
#include "fnmatch.h"
+#include "top.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. */
@@ -441,6 +442,7 @@ file_is_auto_load_safe (const char *filename, const char *debug_fmt, ...)
{
char *filename_real = NULL;
struct cleanup *back_to;
+ static int advice_printed = 0;
if (debug_auto_load)
{
@@ -470,6 +472,27 @@ file_is_auto_load_safe (const char *filename, const char *debug_fmt, ...)
"`auto-load safe-path' set to \"%s\"."),
filename_real, auto_load_safe_path);
+ if (!advice_printed)
+ {
+ const char *homedir = getenv ("HOME");
+ char *homeinit;
+
+ if (homedir == NULL)
+ homedir = "$HOME";
+ homeinit = xstrprintf ("%s/%s", homedir, gdbinit);
+ make_cleanup (xfree, homeinit);
+
+ printf_filtered (_("\
+To enable execution of this file add \"add-auto-load-safe-path %s\" \
+line to \"%s\".\n\
+To completely disable this security protection \
+add \"set auto-load safe-path /\" line to \"%s\".\n\
+For more information about this security protection run from the shell: \
+info \"(gdb)Auto-loading safe path\"\n"),
+ filename_real, homeinit, homeinit);
+ advice_printed = 1;
+ }
+
do_cleanups (back_to);
return 0;
}
@@ -1128,6 +1151,7 @@ void
_initialize_auto_load (void)
{
struct cmd_list_element *cmd;
+ char *scripts_directory_help;
auto_load_pspace_data
= register_program_space_data_with_cleanup (auto_load_pspace_data_cleanup);
@@ -1170,30 +1194,45 @@ Usage: info auto-load local-gdbinit"),
auto_load_info_cmdlist_get ());
auto_load_dir = xstrdup (AUTO_LOAD_DIR);
+ scripts_directory_help = xstrprintf (_("\
+Automatically loaded %s%s%sGDB scripts\n\
+(named OBJFILE%s) are located in one of the directories listed by this\n\
+option.\n\
+This option is ignored for the kinds of scripts \
+having 'set auto-load ... off'.\n\
+Directories listed here need to be present also \
+in the 'set auto-load safe-path'\n\
+option."),
+#ifdef HAVE_PYTHON
+ _("Python scripts (named OBJFILE"),
+ GDBPY_AUTO_FILE_NAME, _(") and "),
+#else
+ "", "", "",
+#endif
+ GDB_AUTO_FILE_NAME);
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."),
+Show the list of directories from which to load auto-loaded scripts."),
+ scripts_directory_help,
set_auto_load_dir, show_auto_load_dir,
auto_load_set_cmdlist_get (),
auto_load_show_cmdlist_get ());
+ xfree (scripts_directory_help);
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, _("\
-Set the list of directories from which it is safe to auto-load files."), _("\
-Show the list of directories from which it is safe to auto-load files."), _("\
+Set the list of paths from which it is safe to auto-load files."), _("\
+Show the list of paths 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\
printed and file will not be used otherwise.\n\
+You can mix both directory and filename entries.\n\
Setting this parameter to an empty list resets it to its default value.\n\
Setting this parameter to '/' (without the quotes) allows any file\n\
-for the 'set auto-load ...' options. Each directory can be also shell\n\
+for the 'set auto-load ...' options. Each path entry can be also shell\n\
wildcard pattern; '*' does not match directory separator.\n\
This option is ignored for the kinds of files having 'set auto-load ... off'.\n\
This options has security implications for untrusted inferiors."),
diff --git a/gdb/python/py-auto-load.c b/gdb/python/py-auto-load.c
index 8512129..a018f5f 100644
--- a/gdb/python/py-auto-load.c
+++ b/gdb/python/py-auto-load.c
@@ -31,10 +31,6 @@
#include "python-internal.h"
-/* The suffix of per-objfile scripts to auto-load.
- E.g. When the program loads libfoo.so, look for libfoo-gdb.py. */
-#define GDBPY_AUTO_FILE_NAME "-gdb.py"
-
/* The section to look for Python auto-loaded scripts (in file formats that
support sections).
Each entry in this section is a byte of value 1, and then the nul-terminated
diff --git a/gdb/python/python.h b/gdb/python/python.h
index dd7066f..0d07271 100644
--- a/gdb/python/python.h
+++ b/gdb/python/python.h
@@ -24,6 +24,10 @@
struct breakpoint_object;
+/* The suffix of per-objfile scripts to auto-load.
+ E.g. When the program loads libfoo.so, look for libfoo-gdb.py. */
+#define GDBPY_AUTO_FILE_NAME "-gdb.py"
+
extern void finish_python_initialization (void);
void eval_python_from_control_command (struct command_line *);
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-08-21 14:44 [patch+7.5] auto-load: User conveniences suggested by Doug Evans Jan Kratochvil
@ 2012-08-21 17:50 ` Eli Zaretskii
2012-08-24 16:11 ` Jan Kratochvil
2012-08-22 15:46 ` Pedro Alves
1 sibling, 1 reply; 26+ messages in thread
From: Eli Zaretskii @ 2012-08-21 17:50 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches, dje
> Date: Tue, 21 Aug 2012 16:43:55 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: Doug Evans <dje@google.com>
>
> according to user feedback after gdb-7.5 with the auto-load feature considered
> by users as pain I have implemented various backward compatible extensions
> suggested by Doug.
Thanks!
> + if (!advice_printed)
> + {
> + const char *homedir = getenv ("HOME");
> + char *homeinit;
> +
> + if (homedir == NULL)
> + homedir = "$HOME";
This should fall back on $USERPROFILE or on $APPDATA on MS-Windows if
$HOME is not defined. $USERPROFILE/$APPDATA are Windows equivalents
of $HOME, but some Windows users (including yours truly) set $HOME to
another directory (e.g., I don't like having my precious files on a
system disk, because disasters strike there more frequently).
> + printf_filtered (_("\
> +To enable execution of this file add \"add-auto-load-safe-path %s\" \
> +line to \"%s\".\n\
Suggest to move the "add-auto-load-safe-path" part to a new line,
because the file name displayed after that will probably overflow the
terminal line.
> + scripts_directory_help = xstrprintf (_("\
> +Automatically loaded %s%s%sGDB scripts\n\
> +(named OBJFILE%s) are located in one of the directories listed by this\n\
> +option.\n\
> +This option is ignored for the kinds of scripts \
> +having 'set auto-load ... off'.\n\
> +Directories listed here need to be present also \
> +in the 'set auto-load safe-path'\n\
> +option."),
Here, the lines are unnecessarily too short, IMO.
> -Set the list of directories from which it is safe to auto-load files."), _("\
> -Show the list of directories from which it is safe to auto-load files."), _("\
> +Set the list of paths from which it is safe to auto-load files."), _("\
> +Show the list of paths from which it is safe to auto-load files."), _("\
Why "paths" instead of directories? GNU Coding Standards frown on
using "paths" with this semantics.
If the problem is that these can be both files and directories, let's
say "list of files and directories that are safe for auto-loading".
Thanks.
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-08-21 17:50 ` Eli Zaretskii
@ 2012-08-24 16:11 ` Jan Kratochvil
2012-08-24 18:15 ` Eli Zaretskii
0 siblings, 1 reply; 26+ messages in thread
From: Jan Kratochvil @ 2012-08-24 16:11 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches, dje
On Tue, 21 Aug 2012 19:50:25 +0200, Eli Zaretskii wrote:
> > + if (!advice_printed)
> > + {
> > + const char *homedir = getenv ("HOME");
> > + char *homeinit;
> > +
> > + if (homedir == NULL)
> > + homedir = "$HOME";
>
> This should fall back on $USERPROFILE or on $APPDATA on MS-Windows if
> $HOME is not defined. $USERPROFILE/$APPDATA are Windows equivalents
> of $HOME, but some Windows users (including yours truly) set $HOME to
> another directory (e.g., I don't like having my precious files on a
> system disk, because disasters strike there more frequently).
GDB main.c get_init_files does just:
homedir = getenv ("HOME");
So if getenv ("HOME") does not work GDB will not find such .gdbinit file
anyway. GDB maybe should do on MS-Windows also getenv ("USERPROFILE") etc.
but that is an unrelated issue needing a fix in main.c get_init_files first.
That part
if (homedir == NULL)
homedir = "$HOME";
may apply for MinGW but it tries to suggest you should 'set HOME c:\' for
example first. It is very MinGW specific problem. Any change here without
change in main.c get_init_files does not make sense.
> > + printf_filtered (_("\
> > +To enable execution of this file add \"add-auto-load-safe-path %s\" \
> > +line to \"%s\".\n\
>
> Suggest to move the "add-auto-load-safe-path" part to a new line,
> because the file name displayed after that will probably overflow the
> terminal line.
Even the line "add-auto-load-safe-path %s" itself may and will overflow the
terminal line. I do not find it such a problem, any terminal wraps lines and
most terminals nowadays are several times wider than 80 columns so I do not
think it makes sense to artifically wrap lines for them. If the user wants
the output more narrow let she narrow her terminal.
> > + scripts_directory_help = xstrprintf (_("\
> > +Automatically loaded %s%s%sGDB scripts\n\
> > +(named OBJFILE%s) are located in one of the directories listed by this\n\
> > +option.\n\
> > +This option is ignored for the kinds of scripts \
> > +having 'set auto-load ... off'.\n\
> > +Directories listed here need to be present also \
> > +in the 'set auto-load safe-path'\n\
> > +option."),
>
> Here, the lines are unnecessarily too short, IMO.
I think there should be some clear decision what should the GDB output conform
to. In this and the paragraph above we have exactly opposite opinions whether
to wrap the text or not.
My opinion:
So far I believe constant text should be formatted to 80 columns, which is
terrible to read but it should conform to GNU Coding Style like the source
does. But when there is some variable text (%s) contained therein one cannot
expect how the variable text is wide so one can leave it wide enough.
> > -Set the list of directories from which it is safe to auto-load files."), _("\
> > -Show the list of directories from which it is safe to auto-load files."), _("\
> > +Set the list of paths from which it is safe to auto-load files."), _("\
> > +Show the list of paths from which it is safe to auto-load files."), _("\
>
> Why "paths" instead of directories? GNU Coding Standards frown on
> using "paths" with this semantics.
>
> If the problem is that these can be both files and directories,
Yes.
> let's say "list of files and directories that are safe for auto-loading".
OK. I hope you are fine with "path" in the second part:
-for the 'set auto-load ...' options. Each directory can be also shell\n\
+for the 'set auto-load ...' options. Each path entry can be also shell\n\
wildcard pattern; '*' does not match directory separator.\n\
Thanks,
Jan
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-08-24 16:11 ` Jan Kratochvil
@ 2012-08-24 18:15 ` Eli Zaretskii
2012-09-09 8:53 ` Jan Kratochvil
0 siblings, 1 reply; 26+ messages in thread
From: Eli Zaretskii @ 2012-08-24 18:15 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches, dje
> Date: Fri, 24 Aug 2012 18:10:59 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: gdb-patches@sourceware.org, dje@google.com
>
> On Tue, 21 Aug 2012 19:50:25 +0200, Eli Zaretskii wrote:
> > > + if (!advice_printed)
> > > + {
> > > + const char *homedir = getenv ("HOME");
> > > + char *homeinit;
> > > +
> > > + if (homedir == NULL)
> > > + homedir = "$HOME";
> >
> > This should fall back on $USERPROFILE or on $APPDATA on MS-Windows if
> > $HOME is not defined. $USERPROFILE/$APPDATA are Windows equivalents
> > of $HOME, but some Windows users (including yours truly) set $HOME to
> > another directory (e.g., I don't like having my precious files on a
> > system disk, because disasters strike there more frequently).
>
> GDB main.c get_init_files does just:
> homedir = getenv ("HOME");
>
> So if getenv ("HOME") does not work GDB will not find such .gdbinit file
> anyway. GDB maybe should do on MS-Windows also getenv ("USERPROFILE") etc.
> but that is an unrelated issue needing a fix in main.c get_init_files first.
>
> That part
> if (homedir == NULL)
> homedir = "$HOME";
>
> may apply for MinGW but it tries to suggest you should 'set HOME c:\' for
> example first. It is very MinGW specific problem. Any change here without
> change in main.c get_init_files does not make sense.
We should change them all, but at the very least we should not make
the problem worse than it already is, IMO.
> > > + printf_filtered (_("\
> > > +To enable execution of this file add \"add-auto-load-safe-path %s\" \
> > > +line to \"%s\".\n\
> >
> > Suggest to move the "add-auto-load-safe-path" part to a new line,
> > because the file name displayed after that will probably overflow the
> > terminal line.
>
> Even the line "add-auto-load-safe-path %s" itself may and will overflow the
> terminal line.
But more file names will fit then.
> > > + scripts_directory_help = xstrprintf (_("\
> > > +Automatically loaded %s%s%sGDB scripts\n\
> > > +(named OBJFILE%s) are located in one of the directories listed by this\n\
> > > +option.\n\
> > > +This option is ignored for the kinds of scripts \
> > > +having 'set auto-load ... off'.\n\
> > > +Directories listed here need to be present also \
> > > +in the 'set auto-load safe-path'\n\
> > > +option."),
> >
> > Here, the lines are unnecessarily too short, IMO.
>
> I think there should be some clear decision what should the GDB output conform
> to. In this and the paragraph above we have exactly opposite opinions whether
> to wrap the text or not.
The above simply looks aesthetically wrong to me. Whatever standards
we set, they should first and foremost be presentable.
> My opinion:
> So far I believe constant text should be formatted to 80 columns, which is
> terrible to read but it should conform to GNU Coding Style like the source
> does.
Division into lines is not only an aesthetical issue. It can also
separate parts that are not as coupled as others. So it's not just a
technical issue of how many characters to leave on each line, IMO.
> > If the problem is that these can be both files and directories,
>
> Yes.
>
> > let's say "list of files and directories that are safe for auto-loading".
>
> OK. I hope you are fine with "path" in the second part:
>
> -for the 'set auto-load ...' options. Each directory can be also shell\n\
> +for the 'set auto-load ...' options. Each path entry can be also shell\n\
> wildcard pattern; '*' does not match directory separator.\n\
Yes, "path entry" is OK.
Thanks.
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-08-24 18:15 ` Eli Zaretskii
@ 2012-09-09 8:53 ` Jan Kratochvil
2012-09-09 17:26 ` Eli Zaretskii
0 siblings, 1 reply; 26+ messages in thread
From: Jan Kratochvil @ 2012-09-09 8:53 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches, dje
On Fri, 24 Aug 2012 20:14:52 +0200, Eli Zaretskii wrote:
> > > > + scripts_directory_help = xstrprintf (_("\
> > > > +Automatically loaded %s%s%sGDB scripts\n\
> > > > +(named OBJFILE%s) are located in one of the directories listed by this\n\
> > > > +option.\n\
> > > > +This option is ignored for the kinds of scripts \
> > > > +having 'set auto-load ... off'.\n\
> > > > +Directories listed here need to be present also \
> > > > +in the 'set auto-load safe-path'\n\
> > > > +option."),
> > >
> > > Here, the lines are unnecessarily too short, IMO.
> >
> > I think there should be some clear decision what should the GDB output conform
> > to. In this and the paragraph above we have exactly opposite opinions whether
> > to wrap the text or not.
>
> The above simply looks aesthetically wrong to me. Whatever standards
> we set, they should first and foremost be presentable.
I find the source form of the help text confusing the discussion here, let's
talk about the output only. Formatting of the output into the source file
does not matter much I think.
--with python form:
(gdb) help set auto-load scripts-directory
Set the list of directories from which to load auto-loaded scripts.
Automatically loaded Python scripts (named OBJFILE-gdb.py) and GDB scripts
(named OBJFILE-gdb.gdb) are located in one of the directories listed by this
option.
This option is ignored for the kinds of scripts having 'set auto-load ... off'.
Directories listed here need to be present also in the 'set auto-load safe-path'
option.
--without-python form:
(gdb) help set auto-load scripts-directory
Set the list of directories from which to load auto-loaded scripts.
Automatically loaded GDB scripts
(named OBJFILE-gdb.gdb) are located in one of the directories listed by this
option.
This option is ignored for the kinds of scripts having 'set auto-load ... off'.
Directories listed here need to be present also in the 'set auto-load safe-path'
option.
Do you find anything aesthetically wrong with this output form and could you
suggest specific changes?
--without-python form is not perfect but I find it good enough for the less
common case of builds.
Thanks,
Jan
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-09-09 8:53 ` Jan Kratochvil
@ 2012-09-09 17:26 ` Eli Zaretskii
2012-09-09 17:55 ` Jan Kratochvil
0 siblings, 1 reply; 26+ messages in thread
From: Eli Zaretskii @ 2012-09-09 17:26 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches, dje
> Date: Sun, 9 Sep 2012 10:53:12 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: gdb-patches@sourceware.org, dje@google.com
>
> --without-python form:
> (gdb) help set auto-load scripts-directory
> Set the list of directories from which to load auto-loaded scripts.
> Automatically loaded GDB scripts
> (named OBJFILE-gdb.gdb) are located in one of the directories listed by this
> option.
Can we make these two lines more evenly sized?
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-09-09 17:26 ` Eli Zaretskii
@ 2012-09-09 17:55 ` Jan Kratochvil
2012-09-09 18:09 ` Eli Zaretskii
0 siblings, 1 reply; 26+ messages in thread
From: Jan Kratochvil @ 2012-09-09 17:55 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches, dje
On Sun, 09 Sep 2012 19:26:43 +0200, Eli Zaretskii wrote:
> > --without-python form:
> > (gdb) help set auto-load scripts-directory
> > Set the list of directories from which to load auto-loaded scripts.
> > Automatically loaded GDB scripts
> > (named OBJFILE-gdb.gdb) are located in one of the directories listed by this
> > option.
>
> Can we make these two lines more evenly sized?
--with-python form:
(gdb) help set auto-load scripts-directory
Set the list of directories from which to load auto-loaded scripts.
Automatically loaded Python scripts (named OBJFILE-gdb.py) and GDB scripts
(named OBJFILE-gdb.gdb) are located in one of the directories listed by this
option.
This option is ignored for the kinds of scripts having 'set auto-load ... off'.
Directories listed here need to be present also in the 'set auto-load safe-path'
option.
--without-python form:
(gdb) help set auto-load scripts-directory
Set the list of directories from which to load auto-loaded scripts.
Automatically loaded GDB scripts (named OBJFILE-gdb.gdb) are located in one
of the directories listed by this option.
This option is ignored for the kinds of scripts having 'set auto-load ... off'.
Directories listed here need to be present also in the 'set auto-load safe-path'
option.
Thanks,
Jan
gdb/
2012-09-09 Jan Kratochvil <jan.kratochvil@redhat.com>
Implement auto-load user conveniences suggested by Doug Evans.
* auto-load.c: Include top.h.
(file_is_auto_load_safe): New variable advice_printed. Print advice.
(_initialize_auto_load): New variable scripts_directory_help. Mention
GDBPY_AUTO_FILE_NAME and GDB_AUTO_FILE_NAME for set auto-load
scripts-directory. Document in online help one can use also files for
set auto-load safe-path.
* python/py-auto-load.c: (GDBPY_AUTO_FILE_NAME): Move it from here ...
* python/python.h (GDBPY_AUTO_FILE_NAME): ... to here.
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index b314ad6..a0f8266 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -37,6 +37,7 @@
#include "completer.h"
#include "observer.h"
#include "fnmatch.h"
+#include "top.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. */
@@ -441,6 +442,7 @@ file_is_auto_load_safe (const char *filename, const char *debug_fmt, ...)
{
char *filename_real = NULL;
struct cleanup *back_to;
+ static int advice_printed = 0;
if (debug_auto_load)
{
@@ -470,6 +472,30 @@ file_is_auto_load_safe (const char *filename, const char *debug_fmt, ...)
"`auto-load safe-path' set to \"%s\"."),
filename_real, auto_load_safe_path);
+ if (!advice_printed)
+ {
+ const char *homedir = getenv ("HOME");
+ char *homeinit;
+
+ if (homedir == NULL)
+ homedir = "$HOME";
+ homeinit = xstrprintf ("%s/%s", homedir, gdbinit);
+ make_cleanup (xfree, homeinit);
+
+ printf_filtered (_("\
+To enable execution of this file add\n\
+\tadd-auto-load-safe-path %s\n\
+line to your configuration file \"%s\".\n\
+To completely disable this security protection add\n\
+\tset auto-load safe-path /\n\
+line to your configuration file \"%s\".\n\
+For more information about this security protection see\n\
+the \"Auto-loading safe path\" section in the GDB manual or run from the shell:\n\
+\tinfo \"(gdb)Auto-loading safe path\"\n"),
+ filename_real, homeinit, homeinit);
+ advice_printed = 1;
+ }
+
do_cleanups (back_to);
return 0;
}
@@ -1164,6 +1190,7 @@ void
_initialize_auto_load (void)
{
struct cmd_list_element *cmd;
+ char *scripts_directory_help;
auto_load_pspace_data
= register_program_space_data_with_cleanup (NULL,
@@ -1207,30 +1234,50 @@ Usage: info auto-load local-gdbinit"),
auto_load_info_cmdlist_get ());
auto_load_dir = xstrdup (AUTO_LOAD_DIR);
+ scripts_directory_help = xstrprintf (
+#ifdef HAVE_PYTHON
+ _("\
+Automatically loaded Python scripts (named OBJFILE%s) and GDB scripts\n\
+(named OBJFILE%s) are located in one of the directories listed by this\n\
+option.\n\
+%s"),
+ GDBPY_AUTO_FILE_NAME,
+#else
+ _("\
+Automatically loaded GDB scripts (named OBJFILE%s) are located in one\n\
+of the directories listed by this option.\n\
+%s"),
+#endif
+ GDB_AUTO_FILE_NAME,
+ _("\
+This option is ignored for the kinds of scripts \
+having 'set auto-load ... off'.\n\
+Directories listed here need to be present also \
+in the 'set auto-load safe-path'\n\
+option."));
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."),
+Show the list of directories from which to load auto-loaded scripts."),
+ scripts_directory_help,
set_auto_load_dir, show_auto_load_dir,
auto_load_set_cmdlist_get (),
auto_load_show_cmdlist_get ());
+ xfree (scripts_directory_help);
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, _("\
-Set the list of directories from which it is safe to auto-load files."), _("\
-Show the list of directories from which it is safe to auto-load files."), _("\
+Set the list of files and directories that are safe for auto-loading."), _("\
+Show the list of files and directories that are safe for auto-loading."), _("\
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\
printed and file will not be used otherwise.\n\
+You can mix both directory and filename entries.\n\
Setting this parameter to an empty list resets it to its default value.\n\
Setting this parameter to '/' (without the quotes) allows any file\n\
-for the 'set auto-load ...' options. Each directory can be also shell\n\
+for the 'set auto-load ...' options. Each path entry can be also shell\n\
wildcard pattern; '*' does not match directory separator.\n\
This option is ignored for the kinds of files having 'set auto-load ... off'.\n\
This options has security implications for untrusted inferiors."),
diff --git a/gdb/python/py-auto-load.c b/gdb/python/py-auto-load.c
index 8512129..a018f5f 100644
--- a/gdb/python/py-auto-load.c
+++ b/gdb/python/py-auto-load.c
@@ -31,10 +31,6 @@
#include "python-internal.h"
-/* The suffix of per-objfile scripts to auto-load.
- E.g. When the program loads libfoo.so, look for libfoo-gdb.py. */
-#define GDBPY_AUTO_FILE_NAME "-gdb.py"
-
/* The section to look for Python auto-loaded scripts (in file formats that
support sections).
Each entry in this section is a byte of value 1, and then the nul-terminated
diff --git a/gdb/python/python.h b/gdb/python/python.h
index dd7066f..0d07271 100644
--- a/gdb/python/python.h
+++ b/gdb/python/python.h
@@ -24,6 +24,10 @@
struct breakpoint_object;
+/* The suffix of per-objfile scripts to auto-load.
+ E.g. When the program loads libfoo.so, look for libfoo-gdb.py. */
+#define GDBPY_AUTO_FILE_NAME "-gdb.py"
+
extern void finish_python_initialization (void);
void eval_python_from_control_command (struct command_line *);
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-09-09 17:55 ` Jan Kratochvil
@ 2012-09-09 18:09 ` Eli Zaretskii
0 siblings, 0 replies; 26+ messages in thread
From: Eli Zaretskii @ 2012-09-09 18:09 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches, dje
> Date: Sun, 9 Sep 2012 19:54:31 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: gdb-patches@sourceware.org, dje@google.com
>
> > Can we make these two lines more evenly sized?
>
> --with-python form:
> (gdb) help set auto-load scripts-directory
> Set the list of directories from which to load auto-loaded scripts.
> Automatically loaded Python scripts (named OBJFILE-gdb.py) and GDB scripts
> (named OBJFILE-gdb.gdb) are located in one of the directories listed by this
> option.
> This option is ignored for the kinds of scripts having 'set auto-load ... off'.
> Directories listed here need to be present also in the 'set auto-load safe-path'
> option.
>
> --without-python form:
> (gdb) help set auto-load scripts-directory
> Set the list of directories from which to load auto-loaded scripts.
> Automatically loaded GDB scripts (named OBJFILE-gdb.gdb) are located in one
> of the directories listed by this option.
> This option is ignored for the kinds of scripts having 'set auto-load ... off'.
> Directories listed here need to be present also in the 'set auto-load safe-path'
> option.
Thanks, I'm happy now.
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-08-21 14:44 [patch+7.5] auto-load: User conveniences suggested by Doug Evans Jan Kratochvil
2012-08-21 17:50 ` Eli Zaretskii
@ 2012-08-22 15:46 ` Pedro Alves
2012-08-24 15:13 ` Jan Kratochvil
2012-08-24 15:19 ` Eli Zaretskii
1 sibling, 2 replies; 26+ messages in thread
From: Pedro Alves @ 2012-08-22 15:46 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches, Doug Evans
On 08/21/2012 03:43 PM, Jan Kratochvil wrote:
> +add \"set auto-load safe-path /\" line to \"%s\".\n\
> +For more information about this security protection run from the shell: \
> +info \"(gdb)Auto-loading safe path\"\n"),
> + filename_real, homeinit, homeinit);
This may be cryptic, for instance, for Windows users who won't
have 'info' available in the shell. How about something like:
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.
?
--
Pedro Alves
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-08-22 15:46 ` Pedro Alves
@ 2012-08-24 15:13 ` Jan Kratochvil
2012-08-24 15:17 ` Pedro Alves
2012-08-24 15:19 ` Eli Zaretskii
1 sibling, 1 reply; 26+ messages in thread
From: Jan Kratochvil @ 2012-08-24 15:13 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, Doug Evans
On Wed, 22 Aug 2012 17:46:27 +0200, Pedro Alves wrote:
> On 08/21/2012 03:43 PM, Jan Kratochvil wrote:
> > +add \"set auto-load safe-path /\" line to \"%s\".\n\
> > +For more information about this security protection run from the shell: \
> > +info \"(gdb)Auto-loading safe path\"\n"),
> > + filename_real, homeinit, homeinit);
>
> This may be cryptic, for instance, for Windows users who won't
> have 'info' available in the shell. How about something like:
>
> For more information about this security protection see the
> "Auto-loading safe path" section in the GDB manual.
>
> ?
In such case I prefer to rather drop the line. It is obvious one can find the
information in GDB Manual.
The goal was to make access to the information easy enough.
What about printing instead:
For more information about this security protection see: http://sourceware.org/gdb/onlinedocs/gdb/Auto_002dloading-safe-path.html
Thanks,
Jan
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-08-24 15:13 ` Jan Kratochvil
@ 2012-08-24 15:17 ` Pedro Alves
0 siblings, 0 replies; 26+ messages in thread
From: Pedro Alves @ 2012-08-24 15:17 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches, Doug Evans
On 08/24/2012 04:12 PM, Jan Kratochvil wrote:
> On Wed, 22 Aug 2012 17:46:27 +0200, Pedro Alves wrote:
>> On 08/21/2012 03:43 PM, Jan Kratochvil wrote:
>>> +add \"set auto-load safe-path /\" line to \"%s\".\n\
>>> +For more information about this security protection run from the shell: \
>>> +info \"(gdb)Auto-loading safe path\"\n"),
>>> + filename_real, homeinit, homeinit);
>>
>> This may be cryptic, for instance, for Windows users who won't
>> have 'info' available in the shell. How about something like:
>>
>> For more information about this security protection see the
>> "Auto-loading safe path" section in the GDB manual.
>>
>> ?
>
> In such case I prefer to rather drop the line. It is obvious one can find the
> information in GDB Manual.
I disagree. The sentence says which section to look for. There are many methods
to get at the manual. E.g, a frontend may even have the manual embedded/indexed in
its help system.
> The goal was to make access to the information easy enough.
>
> What about printing instead:
>
> For more information about this security protection see: http://sourceware.org/gdb/onlinedocs/gdb/Auto_002dloading-safe-path.html
This points at the current/trunk version of GDB's docs, not the version that the user is running.
We shouldn't ever assume these urls are stable.
>
>
> Thanks,
> Jan
--
Pedro Alves
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-08-22 15:46 ` Pedro Alves
2012-08-24 15:13 ` Jan Kratochvil
@ 2012-08-24 15:19 ` Eli Zaretskii
2012-08-24 15:28 ` Pedro Alves
1 sibling, 1 reply; 26+ messages in thread
From: Eli Zaretskii @ 2012-08-24 15:19 UTC (permalink / raw)
To: Pedro Alves; +Cc: jan.kratochvil, gdb-patches, dje
> Date: Wed, 22 Aug 2012 16:46:27 +0100
> From: Pedro Alves <palves@redhat.com>
> CC: gdb-patches@sourceware.org, Doug Evans <dje@google.com>
>
> On 08/21/2012 03:43 PM, Jan Kratochvil wrote:
> > +add \"set auto-load safe-path /\" line to \"%s\".\n\
> > +For more information about this security protection run from the shell: \
> > +info \"(gdb)Auto-loading safe path\"\n"),
> > + filename_real, homeinit, homeinit);
>
> This may be cryptic, for instance, for Windows users who won't
> have 'info' available in the shell.
Why wouldn't they? A Windows port is available.
> How about something like:
>
> For more information about this security protection see the
> "Auto-loading safe path" section in the GDB manual.
>
> ?
If they don't have 'info', how will they read the manual?
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-08-24 15:19 ` Eli Zaretskii
@ 2012-08-24 15:28 ` Pedro Alves
2012-08-24 15:31 ` Pedro Alves
0 siblings, 1 reply; 26+ messages in thread
From: Pedro Alves @ 2012-08-24 15:28 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: jan.kratochvil, gdb-patches, dje
On 08/24/2012 04:19 PM, Eli Zaretskii wrote:
>> Date: Wed, 22 Aug 2012 16:46:27 +0100
>> From: Pedro Alves <palves@redhat.com>
>> CC: gdb-patches@sourceware.org, Doug Evans <dje@google.com>
>>
>> On 08/21/2012 03:43 PM, Jan Kratochvil wrote:
>>> +add \"set auto-load safe-path /\" line to \"%s\".\n\
>>> +For more information about this security protection run from the shell: \
>>> +info \"(gdb)Auto-loading safe path\"\n"),
>>> + filename_real, homeinit, homeinit);
>>
>> This may be cryptic, for instance, for Windows users who won't
>> have 'info' available in the shell.
>
> Why wouldn't they? A Windows port is available.
I mean "won't usually have" -- because they haven't installed it.
For instance, I believe people that use Windows hosted toolchains from
CodeSourcery or AdaCore won't usually have info installed, and won't ever
bother to install it.
My point is that the meat of the information here is the pointing
at a section in the manual, not some specific way to get at it.
>
>> How about something like:
>>
>> For more information about this security protection see the
>> "Auto-loading safe path" section in the GDB manual.
>>
>> ?
>
> If they don't have 'info', how will they read the manual?
Either online; a local html version that is installed along the
toolchain (common, and some vendors integrate this with the frontend
like, e.g., Eclipse); or a local pdf version (also common).
--
Pedro Alves
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-08-24 15:28 ` Pedro Alves
@ 2012-08-24 15:31 ` Pedro Alves
2012-08-24 15:43 ` Jan Kratochvil
2012-08-24 17:56 ` Eli Zaretskii
0 siblings, 2 replies; 26+ messages in thread
From: Pedro Alves @ 2012-08-24 15:31 UTC (permalink / raw)
To: gdb-patches; +Cc: Eli Zaretskii, jan.kratochvil, dje
On 08/24/2012 04:28 PM, Pedro Alves wrote:
> My point is that the meat of the information here is the pointing
> at a section in the manual, not some specific way to get at it.
... and I'd be happy if we combined Jan's and my suggestions. Something like:
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.
For example, run from the shell:
info \"(gdb)Auto-loading safe path\
Would that work?
--
Pedro Alves
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-08-24 15:31 ` Pedro Alves
@ 2012-08-24 15:43 ` Jan Kratochvil
2012-08-24 17:56 ` Eli Zaretskii
1 sibling, 0 replies; 26+ messages in thread
From: Jan Kratochvil @ 2012-08-24 15:43 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, Eli Zaretskii, dje
On Fri, 24 Aug 2012 17:31:28 +0200, Pedro Alves wrote:
> ... and I'd be happy if we combined Jan's and my suggestions. Something like:
>
> For more information about this security protection see the
> "Auto-loading safe path" section in the GDB manual.
> For example, run from the shell:
> info \"(gdb)Auto-loading safe path\
>
> Would that work?
In fact I find this a distribution specific part, which current FSF GDB does
not address and it may never should be.
What about printing in FSF GDB:
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.
And in Fedora GDB to patch it for:
For example, run from the shell: info "(gdb)Auto-loading safe path"
As Fedora could also address the common problem of uninstalled gdb-doc and
therefore depending on 'rpm -q gdb-doc' exit code Fedora could print:
For example, run from the shell: yum -y install gdb-doc; info "(gdb)Auto-loading safe path"
Sure Fedora is unrelated to this gdb-patches list, just giving the picture how
distro specific parts can be useful and at the same time very unrelated to FSF
GDB.
Thanks,
Jan
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-08-24 15:31 ` Pedro Alves
2012-08-24 15:43 ` Jan Kratochvil
@ 2012-08-24 17:56 ` Eli Zaretskii
2012-08-24 18:01 ` Jan Kratochvil
1 sibling, 1 reply; 26+ messages in thread
From: Eli Zaretskii @ 2012-08-24 17:56 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, jan.kratochvil, dje
> Date: Fri, 24 Aug 2012 16:31:28 +0100
> From: Pedro Alves <palves@redhat.com>
> CC: Eli Zaretskii <eliz@gnu.org>, jan.kratochvil@redhat.com, dje@google.com
>
> On 08/24/2012 04:28 PM, Pedro Alves wrote:
>
> > My point is that the meat of the information here is the pointing
> > at a section in the manual, not some specific way to get at it.
>
> ... and I'd be happy if we combined Jan's and my suggestions. Something like:
>
> For more information about this security protection see the
> "Auto-loading safe path" section in the GDB manual.
> For example, run from the shell:
> info \"(gdb)Auto-loading safe path\
>
> Would that work?
I would rephrase
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual
('info \"(gdb)Auto-loading safe path\"').
I removed the reference to the shell because the above works in Emacs
as well, and is also shorter.
I hope we all can agree to this compromise.
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-08-24 17:56 ` Eli Zaretskii
@ 2012-08-24 18:01 ` Jan Kratochvil
2012-08-24 18:26 ` Eli Zaretskii
0 siblings, 1 reply; 26+ messages in thread
From: Jan Kratochvil @ 2012-08-24 18:01 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Pedro Alves, gdb-patches, dje
On Fri, 24 Aug 2012 19:55:45 +0200, Eli Zaretskii wrote:
> For more information about this security protection see the
> "Auto-loading safe path" section in the GDB manual
> ('info \"(gdb)Auto-loading safe path\"').
>
> I removed the reference to the shell because the above works in Emacs
> as well, and is also shorter.
People type such commands into GDB, from what I know from IRC.
Maybe to put there 'shell info ...' but that also has disadvantages.
Jan
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-08-24 18:01 ` Jan Kratochvil
@ 2012-08-24 18:26 ` Eli Zaretskii
2012-08-27 18:02 ` Pedro Alves
0 siblings, 1 reply; 26+ messages in thread
From: Eli Zaretskii @ 2012-08-24 18:26 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: palves, gdb-patches, dje
> Date: Fri, 24 Aug 2012 20:00:33 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: Pedro Alves <palves@redhat.com>, gdb-patches@sourceware.org,
> dje@google.com
>
> On Fri, 24 Aug 2012 19:55:45 +0200, Eli Zaretskii wrote:
> > For more information about this security protection see the
> > "Auto-loading safe path" section in the GDB manual
> > ('info \"(gdb)Auto-loading safe path\"').
> >
> > I removed the reference to the shell because the above works in Emacs
> > as well, and is also shorter.
>
> People type such commands into GDB, from what I know from IRC.
We must draw a line somewhere. Otherwise, we will end up explaining
how to start a shell etc.
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-08-24 18:26 ` Eli Zaretskii
@ 2012-08-27 18:02 ` Pedro Alves
2012-08-27 18:12 ` Jan Kratochvil
0 siblings, 1 reply; 26+ messages in thread
From: Pedro Alves @ 2012-08-27 18:02 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Jan Kratochvil, gdb-patches, dje
On 08/24/2012 07:26 PM, Eli Zaretskii wrote:
>> Date: Fri, 24 Aug 2012 20:00:33 +0200
>> From: Jan Kratochvil <jan.kratochvil@redhat.com>
>> Cc: Pedro Alves <palves@redhat.com>, gdb-patches@sourceware.org,
>> dje@google.com
>>
>> On Fri, 24 Aug 2012 19:55:45 +0200, Eli Zaretskii wrote:
>>> For more information about this security protection see the
>>> "Auto-loading safe path" section in the GDB manual
>>> ('info \"(gdb)Auto-loading safe path\"').
>>>
>>> I removed the reference to the shell because the above works in Emacs
>>> as well, and is also shorter.
>>
>> People type such commands into GDB, from what I know from IRC.
>
> We must draw a line somewhere. Otherwise, we will end up explaining
> how to start a shell etc.
I have to agree with Jan here. "info" is also a GDB command -- that
would surely leave users confused. :-(
If four lines is too much, then my previous suggestion, but merged
to three lines, still leaves us with 71 columns:
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual
(For example, run from the shell: info \"(gdb)Auto-loading safe path\).
IMO, that's not too long, and is maximally informative.
WRT emacs, I honestly think that an emacs user is able to do the
"I don't need to run 'info' on shell -- I can do it right here
in the minibuffer" mental jump.
--
Pedro Alves
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-08-27 18:02 ` Pedro Alves
@ 2012-08-27 18:12 ` Jan Kratochvil
2012-09-09 9:02 ` Jan Kratochvil
0 siblings, 1 reply; 26+ messages in thread
From: Jan Kratochvil @ 2012-08-27 18:12 UTC (permalink / raw)
To: Pedro Alves; +Cc: Eli Zaretskii, gdb-patches, dje
On Mon, 27 Aug 2012 20:02:27 +0200, Pedro Alves wrote:
> For more information about this security protection see the
> "Auto-loading safe path" section in the GDB manual
> (For example, run from the shell: info \"(gdb)Auto-loading safe path\).
When we are at it then:
For example, run from the shell: info "(gdb)Auto-loading safe path"
As otherwise it is pain to copy-paste it. Or in fact it does not work when
naively copy-pasted.
> WRT emacs, I honestly think that an emacs user
I honestly think the ratio of Emacs users among the GDB CLI users is not
significant enough (for special features targeted at them).
Thanks,
Jan
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-08-27 18:12 ` Jan Kratochvil
@ 2012-09-09 9:02 ` Jan Kratochvil
2012-09-10 11:29 ` Pedro Alves
0 siblings, 1 reply; 26+ messages in thread
From: Jan Kratochvil @ 2012-09-09 9:02 UTC (permalink / raw)
To: Pedro Alves; +Cc: Eli Zaretskii, gdb-patches, dje
On Mon, 27 Aug 2012 20:11:47 +0200, Jan Kratochvil wrote:
> On Mon, 27 Aug 2012 20:02:27 +0200, Pedro Alves wrote:
> > For more information about this security protection see the
> > "Auto-loading safe path" section in the GDB manual
> > (For example, run from the shell: info \"(gdb)Auto-loading safe path\).
>
> When we are at it then:
>
> For example, run from the shell: info "(gdb)Auto-loading safe path"
>
> As otherwise it is pain to copy-paste it. Or in fact it does not work when
> naively copy-pasted.
Without the parentheses we have looped back to the original form in the patch.
Suggesting therefore the following output form which I tried to compile from
all the suggestions:
Reading symbols from /home/jkratoch/redhat/gdb-clean/gdb/gdb...done.
warning: File "/home/jkratoch/redhat/gdb-clean/gdb/gdb-gdb.gdb" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
add-auto-load-safe-path /home/jkratoch/redhat/gdb-clean/gdb/gdb-gdb.gdb
line to your configuration file "/home/jkratoch/.gdbinit".
To completely disable this security protection add
set auto-load safe-path /
line to your configuration file "/home/jkratoch/.gdbinit".
For more information about this security protection see
the "Auto-loading safe path" section in the GDB manual or run from the shell:
info "(gdb)Auto-loading safe path"
warning: File "/home/jkratoch/redhat/gdb-clean/gdb/gdb-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
(gdb) q
I will check it the case of no further comments.
Thanks,
Jan
gdb/
2012-09-09 Jan Kratochvil <jan.kratochvil@redhat.com>
Implement auto-load user conveniences suggested by Doug Evans.
* auto-load.c: Include top.h.
(file_is_auto_load_safe): New variable advice_printed. Print advice.
(_initialize_auto_load): New variable scripts_directory_help. Mention
GDBPY_AUTO_FILE_NAME and GDB_AUTO_FILE_NAME for set auto-load
scripts-directory. Document in online help one can use also files for
set auto-load safe-path.
* python/py-auto-load.c: (GDBPY_AUTO_FILE_NAME): Move it from here ...
* python/python.h (GDBPY_AUTO_FILE_NAME): ... to here.
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index b314ad6..603183c 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -37,6 +37,7 @@
#include "completer.h"
#include "observer.h"
#include "fnmatch.h"
+#include "top.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. */
@@ -441,6 +442,7 @@ file_is_auto_load_safe (const char *filename, const char *debug_fmt, ...)
{
char *filename_real = NULL;
struct cleanup *back_to;
+ static int advice_printed = 0;
if (debug_auto_load)
{
@@ -470,6 +472,30 @@ file_is_auto_load_safe (const char *filename, const char *debug_fmt, ...)
"`auto-load safe-path' set to \"%s\"."),
filename_real, auto_load_safe_path);
+ if (!advice_printed)
+ {
+ const char *homedir = getenv ("HOME");
+ char *homeinit;
+
+ if (homedir == NULL)
+ homedir = "$HOME";
+ homeinit = xstrprintf ("%s/%s", homedir, gdbinit);
+ make_cleanup (xfree, homeinit);
+
+ printf_filtered (_("\
+To enable execution of this file add\n\
+\tadd-auto-load-safe-path %s\n\
+line to your configuration file \"%s\".\n\
+To completely disable this security protection add\n\
+\tset auto-load safe-path /\n\
+line to your configuration file \"%s\".\n\
+For more information about this security protection see\n\
+the \"Auto-loading safe path\" section in the GDB manual or run from the shell:\n\
+\tinfo \"(gdb)Auto-loading safe path\"\n"),
+ filename_real, homeinit, homeinit);
+ advice_printed = 1;
+ }
+
do_cleanups (back_to);
return 0;
}
@@ -1164,6 +1190,7 @@ void
_initialize_auto_load (void)
{
struct cmd_list_element *cmd;
+ char *scripts_directory_help;
auto_load_pspace_data
= register_program_space_data_with_cleanup (NULL,
@@ -1207,30 +1234,45 @@ Usage: info auto-load local-gdbinit"),
auto_load_info_cmdlist_get ());
auto_load_dir = xstrdup (AUTO_LOAD_DIR);
+ scripts_directory_help = xstrprintf (_("\
+Automatically loaded %s%s%sGDB scripts\n\
+(named OBJFILE%s) are located in one of the directories listed by this\n\
+option.\n\
+This option is ignored for the kinds of scripts \
+having 'set auto-load ... off'.\n\
+Directories listed here need to be present also \
+in the 'set auto-load safe-path'\n\
+option."),
+#ifdef HAVE_PYTHON
+ _("Python scripts (named OBJFILE"),
+ GDBPY_AUTO_FILE_NAME, _(") and "),
+#else
+ "", "", "",
+#endif
+ GDB_AUTO_FILE_NAME);
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."),
+Show the list of directories from which to load auto-loaded scripts."),
+ scripts_directory_help,
set_auto_load_dir, show_auto_load_dir,
auto_load_set_cmdlist_get (),
auto_load_show_cmdlist_get ());
+ xfree (scripts_directory_help);
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, _("\
-Set the list of directories from which it is safe to auto-load files."), _("\
-Show the list of directories from which it is safe to auto-load files."), _("\
+Set the list of files and directories that are safe for auto-loading."), _("\
+Show the list of files and directories that are safe for auto-loading."), _("\
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\
printed and file will not be used otherwise.\n\
+You can mix both directory and filename entries.\n\
Setting this parameter to an empty list resets it to its default value.\n\
Setting this parameter to '/' (without the quotes) allows any file\n\
-for the 'set auto-load ...' options. Each directory can be also shell\n\
+for the 'set auto-load ...' options. Each path entry can be also shell\n\
wildcard pattern; '*' does not match directory separator.\n\
This option is ignored for the kinds of files having 'set auto-load ... off'.\n\
This options has security implications for untrusted inferiors."),
diff --git a/gdb/python/py-auto-load.c b/gdb/python/py-auto-load.c
index 8512129..a018f5f 100644
--- a/gdb/python/py-auto-load.c
+++ b/gdb/python/py-auto-load.c
@@ -31,10 +31,6 @@
#include "python-internal.h"
-/* The suffix of per-objfile scripts to auto-load.
- E.g. When the program loads libfoo.so, look for libfoo-gdb.py. */
-#define GDBPY_AUTO_FILE_NAME "-gdb.py"
-
/* The section to look for Python auto-loaded scripts (in file formats that
support sections).
Each entry in this section is a byte of value 1, and then the nul-terminated
diff --git a/gdb/python/python.h b/gdb/python/python.h
index dd7066f..0d07271 100644
--- a/gdb/python/python.h
+++ b/gdb/python/python.h
@@ -24,6 +24,10 @@
struct breakpoint_object;
+/* The suffix of per-objfile scripts to auto-load.
+ E.g. When the program loads libfoo.so, look for libfoo-gdb.py. */
+#define GDBPY_AUTO_FILE_NAME "-gdb.py"
+
extern void finish_python_initialization (void);
void eval_python_from_control_command (struct command_line *);
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-09-09 9:02 ` Jan Kratochvil
@ 2012-09-10 11:29 ` Pedro Alves
2012-09-10 11:47 ` Jan Kratochvil
0 siblings, 1 reply; 26+ messages in thread
From: Pedro Alves @ 2012-09-10 11:29 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Eli Zaretskii, gdb-patches, dje
On 09/09/2012 10:01 AM, Jan Kratochvil wrote:
> On Mon, 27 Aug 2012 20:11:47 +0200, Jan Kratochvil wrote:
>> On Mon, 27 Aug 2012 20:02:27 +0200, Pedro Alves wrote:
>>> For more information about this security protection see the
>>> "Auto-loading safe path" section in the GDB manual
>>> (For example, run from the shell: info \"(gdb)Auto-loading safe path\).
>>
>> When we are at it then:
>>
>> For example, run from the shell: info "(gdb)Auto-loading safe path"
>
>> As otherwise it is pain to copy-paste it. Or in fact it does not work when
>> naively copy-pasted.
Sure. It was just a typo - (mis)copied from the original patch.
> Without the parentheses we have looped back to the original form in the patch.
Well, we have not. The original form of the patch didn't point at the
manual in English; it only showed an info command.
I really don't care for the parentheses. Fine with me with or without.
>
> Suggesting therefore the following output form which I tried to compile from
> all the suggestions:
>
> Reading symbols from /home/jkratoch/redhat/gdb-clean/gdb/gdb...done.
> warning: File "/home/jkratoch/redhat/gdb-clean/gdb/gdb-gdb.gdb" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
> To enable execution of this file add
> add-auto-load-safe-path /home/jkratoch/redhat/gdb-clean/gdb/gdb-gdb.gdb
> line to your configuration file "/home/jkratoch/.gdbinit".
> To completely disable this security protection add
> set auto-load safe-path /
> line to your configuration file "/home/jkratoch/.gdbinit".
> For more information about this security protection see
> the "Auto-loading safe path" section in the GDB manual or run from the shell:
> info "(gdb)Auto-loading safe path"
> warning: File "/home/jkratoch/redhat/gdb-clean/gdb/gdb-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
I honestly don't understand why "for example, run..." would be worse
than "or run...", while "or" to my ears implies that the information that
you get in the pointed section of the manual might be different (alternative)
from what you get from that info command. But that's maybe just language
barrier, or just me. I'm happy enough with this version. Thanks.
> I will check it the case of no further comments.
>
>
> Thanks,
> Jan
>
>
> gdb/
> 2012-09-09 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> Implement auto-load user conveniences suggested by Doug Evans.
> * auto-load.c: Include top.h.
> (file_is_auto_load_safe): New variable advice_printed. Print advice.
> (_initialize_auto_load): New variable scripts_directory_help. Mention
> GDBPY_AUTO_FILE_NAME and GDB_AUTO_FILE_NAME for set auto-load
> scripts-directory. Document in online help one can use also files for
> set auto-load safe-path.
> * python/py-auto-load.c: (GDBPY_AUTO_FILE_NAME): Move it from here ...
> * python/python.h (GDBPY_AUTO_FILE_NAME): ... to here.
>
> diff --git a/gdb/auto-load.c b/gdb/auto-load.c
> index b314ad6..603183c 100644
> --- a/gdb/auto-load.c
> +++ b/gdb/auto-load.c
> @@ -37,6 +37,7 @@
> #include "completer.h"
> #include "observer.h"
> #include "fnmatch.h"
> +#include "top.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. */
> @@ -441,6 +442,7 @@ file_is_auto_load_safe (const char *filename, const char *debug_fmt, ...)
> {
> char *filename_real = NULL;
> struct cleanup *back_to;
> + static int advice_printed = 0;
>
> if (debug_auto_load)
> {
> @@ -470,6 +472,30 @@ file_is_auto_load_safe (const char *filename, const char *debug_fmt, ...)
> "`auto-load safe-path' set to \"%s\"."),
> filename_real, auto_load_safe_path);
>
> + if (!advice_printed)
> + {
> + const char *homedir = getenv ("HOME");
> + char *homeinit;
> +
> + if (homedir == NULL)
> + homedir = "$HOME";
> + homeinit = xstrprintf ("%s/%s", homedir, gdbinit);
> + make_cleanup (xfree, homeinit);
> +
> + printf_filtered (_("\
> +To enable execution of this file add\n\
> +\tadd-auto-load-safe-path %s\n\
> +line to your configuration file \"%s\".\n\
> +To completely disable this security protection add\n\
> +\tset auto-load safe-path /\n\
> +line to your configuration file \"%s\".\n\
> +For more information about this security protection see\n\
> +the \"Auto-loading safe path\" section in the GDB manual or run from the shell:\n\
> +\tinfo \"(gdb)Auto-loading safe path\"\n"),
> + filename_real, homeinit, homeinit);
> + advice_printed = 1;
> + }
> +
> do_cleanups (back_to);
> return 0;
> }
> @@ -1164,6 +1190,7 @@ void
> _initialize_auto_load (void)
> {
> struct cmd_list_element *cmd;
> + char *scripts_directory_help;
>
> auto_load_pspace_data
> = register_program_space_data_with_cleanup (NULL,
> @@ -1207,30 +1234,45 @@ Usage: info auto-load local-gdbinit"),
> auto_load_info_cmdlist_get ());
>
> auto_load_dir = xstrdup (AUTO_LOAD_DIR);
> + scripts_directory_help = xstrprintf (_("\
> +Automatically loaded %s%s%sGDB scripts\n\
> +(named OBJFILE%s) are located in one of the directories listed by this\n\
> +option.\n\
> +This option is ignored for the kinds of scripts \
> +having 'set auto-load ... off'.\n\
> +Directories listed here need to be present also \
> +in the 'set auto-load safe-path'\n\
> +option."),
> +#ifdef HAVE_PYTHON
> + _("Python scripts (named OBJFILE"),
> + GDBPY_AUTO_FILE_NAME, _(") and "),
> +#else
> + "", "", "",
> +#endif
> + GDB_AUTO_FILE_NAME);
> 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."),
> +Show the list of directories from which to load auto-loaded scripts."),
> + scripts_directory_help,
> set_auto_load_dir, show_auto_load_dir,
> auto_load_set_cmdlist_get (),
> auto_load_show_cmdlist_get ());
> + xfree (scripts_directory_help);
>
> 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, _("\
> -Set the list of directories from which it is safe to auto-load files."), _("\
> -Show the list of directories from which it is safe to auto-load files."), _("\
> +Set the list of files and directories that are safe for auto-loading."), _("\
> +Show the list of files and directories that are safe for auto-loading."), _("\
> 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\
> printed and file will not be used otherwise.\n\
> +You can mix both directory and filename entries.\n\
> Setting this parameter to an empty list resets it to its default value.\n\
> Setting this parameter to '/' (without the quotes) allows any file\n\
> -for the 'set auto-load ...' options. Each directory can be also shell\n\
> +for the 'set auto-load ...' options. Each path entry can be also shell\n\
> wildcard pattern; '*' does not match directory separator.\n\
> This option is ignored for the kinds of files having 'set auto-load ... off'.\n\
> This options has security implications for untrusted inferiors."),
> diff --git a/gdb/python/py-auto-load.c b/gdb/python/py-auto-load.c
> index 8512129..a018f5f 100644
> --- a/gdb/python/py-auto-load.c
> +++ b/gdb/python/py-auto-load.c
> @@ -31,10 +31,6 @@
>
> #include "python-internal.h"
>
> -/* The suffix of per-objfile scripts to auto-load.
> - E.g. When the program loads libfoo.so, look for libfoo-gdb.py. */
> -#define GDBPY_AUTO_FILE_NAME "-gdb.py"
> -
> /* The section to look for Python auto-loaded scripts (in file formats that
> support sections).
> Each entry in this section is a byte of value 1, and then the nul-terminated
> diff --git a/gdb/python/python.h b/gdb/python/python.h
> index dd7066f..0d07271 100644
> --- a/gdb/python/python.h
> +++ b/gdb/python/python.h
> @@ -24,6 +24,10 @@
>
> struct breakpoint_object;
>
> +/* The suffix of per-objfile scripts to auto-load.
> + E.g. When the program loads libfoo.so, look for libfoo-gdb.py. */
> +#define GDBPY_AUTO_FILE_NAME "-gdb.py"
> +
> extern void finish_python_initialization (void);
>
> void eval_python_from_control_command (struct command_line *);
>
--
Pedro Alves
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-09-10 11:29 ` Pedro Alves
@ 2012-09-10 11:47 ` Jan Kratochvil
2012-09-10 13:06 ` Pedro Alves
0 siblings, 1 reply; 26+ messages in thread
From: Jan Kratochvil @ 2012-09-10 11:47 UTC (permalink / raw)
To: Pedro Alves; +Cc: Eli Zaretskii, gdb-patches, dje
On Mon, 10 Sep 2012 13:29:19 +0200, Pedro Alves wrote:
> On 09/09/2012 10:01 AM, Jan Kratochvil wrote:
> > For more information about this security protection see
> > the "Auto-loading safe path" section in the GDB manual or run from the shell:
> > info "(gdb)Auto-loading safe path"
> > warning: File "/home/jkratoch/redhat/gdb-clean/gdb/gdb-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
>
> I honestly don't understand why "for example, run..." would be worse
> than "or run...", while "or" to my ears implies that the information that
> you get in the pointed section of the manual might be different (alternative)
> from what you get from that info command. But that's maybe just language
> barrier, or just me. I'm happy enough with this version. Thanks.
I understand "for example" would be slightly better there but it IMO is not
worth an extra line.
I believe the output should not be too long to be read by anyone.
I understand the warning in 7.5 has proven to be too short, though.
For example the initial GDB licensing information (without -q) is too long,
I do not see it required by GNU Coding Standards; but the initial text is
offtopic here.
Thanks,
Jan
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-09-10 11:47 ` Jan Kratochvil
@ 2012-09-10 13:06 ` Pedro Alves
2012-09-10 15:28 ` Jan Kratochvil
0 siblings, 1 reply; 26+ messages in thread
From: Pedro Alves @ 2012-09-10 13:06 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Eli Zaretskii, gdb-patches, dje
On 09/10/2012 12:47 PM, Jan Kratochvil wrote:
> On Mon, 10 Sep 2012 13:29:19 +0200, Pedro Alves wrote:
>> On 09/09/2012 10:01 AM, Jan Kratochvil wrote:
>>> For more information about this security protection see
>>> the "Auto-loading safe path" section in the GDB manual or run from the shell:
>>> info "(gdb)Auto-loading safe path"
>>> warning: File "/home/jkratoch/redhat/gdb-clean/gdb/gdb-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
>>
>> I honestly don't understand why "for example, run..." would be worse
>> than "or run...", while "or" to my ears implies that the information that
>> you get in the pointed section of the manual might be different (alternative)
>> from what you get from that info command. But that's maybe just language
>> barrier, or just me. I'm happy enough with this version. Thanks.
>
> I understand "for example" would be slightly better there but it IMO is not
> worth an extra line.
If that's the issue, "e.g.," is shorter, and moving the "the" to the
previous line still leaves us at 78 columns:
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual. E.g., run from the shell:
info "(gdb)Auto-loading safe path"
vs the 77 columns:
For more information about this security protection see
the "Auto-loading safe path" section in the GDB manual or run from the shell:
info "(gdb)Auto-loading safe path"
Not suggesting this one, but a little re-flowing can bring it down to 73 columns,
at the expense of breaking the section name in two lines:
For more information about this security protection see the "Auto-loading
safe path" section in the GDB manual. For example, run from the shell:
info "(gdb)Auto-loading safe path"
Anyway, just for completeness. Thanks.
>
> I believe the output should not be too long to be read by anyone.
> I understand the warning in 7.5 has proven to be too short, though.
>
> For example the initial GDB licensing information (without -q) is too long,
> I do not see it required by GNU Coding Standards; but the initial text is
> offtopic here.
--
Pedro Alves
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-09-10 13:06 ` Pedro Alves
@ 2012-09-10 15:28 ` Jan Kratochvil
2012-09-17 18:29 ` [commit+7.5] " Jan Kratochvil
0 siblings, 1 reply; 26+ messages in thread
From: Jan Kratochvil @ 2012-09-10 15:28 UTC (permalink / raw)
To: Pedro Alves; +Cc: Eli Zaretskii, gdb-patches, dje
On Mon, 10 Sep 2012 15:06:21 +0200, Pedro Alves wrote:
> If that's the issue, "e.g.," is shorter, and moving the "the" to the
> previous line still leaves us at 78 columns:
>
> For more information about this security protection see the
> "Auto-loading safe path" section in the GDB manual. E.g., run from the shell:
> info "(gdb)Auto-loading safe path"
Chose this one.
> Not suggesting this one, but a little re-flowing can bring it down to 73 columns,
> at the expense of breaking the section name in two lines:
>
> For more information about this security protection see the "Auto-loading
> safe path" section in the GDB manual. For example, run from the shell:
> info "(gdb)Auto-loading safe path"
Yes, I did not want to break the section name for easier copy-pasting.
Thanks,
Jan
gdb/
2012-09-10 Jan Kratochvil <jan.kratochvil@redhat.com>
Implement auto-load user conveniences suggested by Doug Evans.
* auto-load.c: Include top.h.
(file_is_auto_load_safe): New variable advice_printed. Print advice.
(_initialize_auto_load): New variable scripts_directory_help. Mention
GDBPY_AUTO_FILE_NAME and GDB_AUTO_FILE_NAME for set auto-load
scripts-directory. Document in online help one can use also files for
set auto-load safe-path.
* python/py-auto-load.c: (GDBPY_AUTO_FILE_NAME): Move it from here ...
* python/python.h (GDBPY_AUTO_FILE_NAME): ... to here.
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index b314ad6..c5eb8d1 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -37,6 +37,7 @@
#include "completer.h"
#include "observer.h"
#include "fnmatch.h"
+#include "top.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. */
@@ -441,6 +442,7 @@ file_is_auto_load_safe (const char *filename, const char *debug_fmt, ...)
{
char *filename_real = NULL;
struct cleanup *back_to;
+ static int advice_printed = 0;
if (debug_auto_load)
{
@@ -470,6 +472,30 @@ file_is_auto_load_safe (const char *filename, const char *debug_fmt, ...)
"`auto-load safe-path' set to \"%s\"."),
filename_real, auto_load_safe_path);
+ if (!advice_printed)
+ {
+ const char *homedir = getenv ("HOME");
+ char *homeinit;
+
+ if (homedir == NULL)
+ homedir = "$HOME";
+ homeinit = xstrprintf ("%s/%s", homedir, gdbinit);
+ make_cleanup (xfree, homeinit);
+
+ printf_filtered (_("\
+To enable execution of this file add\n\
+\tadd-auto-load-safe-path %s\n\
+line to your configuration file \"%s\".\n\
+To completely disable this security protection add\n\
+\tset auto-load safe-path /\n\
+line to your configuration file \"%s\".\n\
+For more information about this security protection see the\n\
+\"Auto-loading safe path\" section in the GDB manual. E.g., run from the shell:\n\
+\tinfo \"(gdb)Auto-loading safe path\"\n"),
+ filename_real, homeinit, homeinit);
+ advice_printed = 1;
+ }
+
do_cleanups (back_to);
return 0;
}
@@ -1164,6 +1190,7 @@ void
_initialize_auto_load (void)
{
struct cmd_list_element *cmd;
+ char *scripts_directory_help;
auto_load_pspace_data
= register_program_space_data_with_cleanup (NULL,
@@ -1207,30 +1234,50 @@ Usage: info auto-load local-gdbinit"),
auto_load_info_cmdlist_get ());
auto_load_dir = xstrdup (AUTO_LOAD_DIR);
+ scripts_directory_help = xstrprintf (
+#ifdef HAVE_PYTHON
+ _("\
+Automatically loaded Python scripts (named OBJFILE%s) and GDB scripts\n\
+(named OBJFILE%s) are located in one of the directories listed by this\n\
+option.\n\
+%s"),
+ GDBPY_AUTO_FILE_NAME,
+#else
+ _("\
+Automatically loaded GDB scripts (named OBJFILE%s) are located in one\n\
+of the directories listed by this option.\n\
+%s"),
+#endif
+ GDB_AUTO_FILE_NAME,
+ _("\
+This option is ignored for the kinds of scripts \
+having 'set auto-load ... off'.\n\
+Directories listed here need to be present also \
+in the 'set auto-load safe-path'\n\
+option."));
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."),
+Show the list of directories from which to load auto-loaded scripts."),
+ scripts_directory_help,
set_auto_load_dir, show_auto_load_dir,
auto_load_set_cmdlist_get (),
auto_load_show_cmdlist_get ());
+ xfree (scripts_directory_help);
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, _("\
-Set the list of directories from which it is safe to auto-load files."), _("\
-Show the list of directories from which it is safe to auto-load files."), _("\
+Set the list of files and directories that are safe for auto-loading."), _("\
+Show the list of files and directories that are safe for auto-loading."), _("\
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\
printed and file will not be used otherwise.\n\
+You can mix both directory and filename entries.\n\
Setting this parameter to an empty list resets it to its default value.\n\
Setting this parameter to '/' (without the quotes) allows any file\n\
-for the 'set auto-load ...' options. Each directory can be also shell\n\
+for the 'set auto-load ...' options. Each path entry can be also shell\n\
wildcard pattern; '*' does not match directory separator.\n\
This option is ignored for the kinds of files having 'set auto-load ... off'.\n\
This options has security implications for untrusted inferiors."),
diff --git a/gdb/python/py-auto-load.c b/gdb/python/py-auto-load.c
index 8512129..a018f5f 100644
--- a/gdb/python/py-auto-load.c
+++ b/gdb/python/py-auto-load.c
@@ -31,10 +31,6 @@
#include "python-internal.h"
-/* The suffix of per-objfile scripts to auto-load.
- E.g. When the program loads libfoo.so, look for libfoo-gdb.py. */
-#define GDBPY_AUTO_FILE_NAME "-gdb.py"
-
/* The section to look for Python auto-loaded scripts (in file formats that
support sections).
Each entry in this section is a byte of value 1, and then the nul-terminated
diff --git a/gdb/python/python.h b/gdb/python/python.h
index dd7066f..0d07271 100644
--- a/gdb/python/python.h
+++ b/gdb/python/python.h
@@ -24,6 +24,10 @@
struct breakpoint_object;
+/* The suffix of per-objfile scripts to auto-load.
+ E.g. When the program loads libfoo.so, look for libfoo-gdb.py. */
+#define GDBPY_AUTO_FILE_NAME "-gdb.py"
+
extern void finish_python_initialization (void);
void eval_python_from_control_command (struct command_line *);
^ permalink raw reply [flat|nested] 26+ messages in thread* [commit+7.5] [patch+7.5] auto-load: User conveniences suggested by Doug Evans
2012-09-10 15:28 ` Jan Kratochvil
@ 2012-09-17 18:29 ` Jan Kratochvil
0 siblings, 0 replies; 26+ messages in thread
From: Jan Kratochvil @ 2012-09-17 18:29 UTC (permalink / raw)
To: Pedro Alves; +Cc: Eli Zaretskii, gdb-patches, dje
On Mon, 10 Sep 2012 17:27:57 +0200, Jan Kratochvil wrote:
> gdb/
> 2012-09-10 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> Implement auto-load user conveniences suggested by Doug Evans.
> * auto-load.c: Include top.h.
> (file_is_auto_load_safe): New variable advice_printed. Print advice.
> (_initialize_auto_load): New variable scripts_directory_help. Mention
> GDBPY_AUTO_FILE_NAME and GDB_AUTO_FILE_NAME for set auto-load
> scripts-directory. Document in online help one can use also files for
> set auto-load safe-path.
> * python/py-auto-load.c: (GDBPY_AUTO_FILE_NAME): Move it from here ...
> * python/python.h (GDBPY_AUTO_FILE_NAME): ... to here.
Checked in:
http://sourceware.org/ml/gdb-cvs/2012-09/msg00087.html
And for 7.5:
http://sourceware.org/ml/gdb-cvs/2012-09/msg00088.html
Thanks,
Jan
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2012-09-17 18:29 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-21 14:44 [patch+7.5] auto-load: User conveniences suggested by Doug Evans Jan Kratochvil
2012-08-21 17:50 ` Eli Zaretskii
2012-08-24 16:11 ` Jan Kratochvil
2012-08-24 18:15 ` Eli Zaretskii
2012-09-09 8:53 ` Jan Kratochvil
2012-09-09 17:26 ` Eli Zaretskii
2012-09-09 17:55 ` Jan Kratochvil
2012-09-09 18:09 ` Eli Zaretskii
2012-08-22 15:46 ` Pedro Alves
2012-08-24 15:13 ` Jan Kratochvil
2012-08-24 15:17 ` Pedro Alves
2012-08-24 15:19 ` Eli Zaretskii
2012-08-24 15:28 ` Pedro Alves
2012-08-24 15:31 ` Pedro Alves
2012-08-24 15:43 ` Jan Kratochvil
2012-08-24 17:56 ` Eli Zaretskii
2012-08-24 18:01 ` Jan Kratochvil
2012-08-24 18:26 ` Eli Zaretskii
2012-08-27 18:02 ` Pedro Alves
2012-08-27 18:12 ` Jan Kratochvil
2012-09-09 9:02 ` Jan Kratochvil
2012-09-10 11:29 ` Pedro Alves
2012-09-10 11:47 ` Jan Kratochvil
2012-09-10 13:06 ` Pedro Alves
2012-09-10 15:28 ` Jan Kratochvil
2012-09-17 18:29 ` [commit+7.5] " Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox