Re: [patch, doc RFA] New command-line option -na.

Doug Evans
2010-12-15T01:40:25Z

[-- Attachment #1: Type: text/plain, Size: 2456 bytes --]

Note: I have removed -na.

On Sat, Dec 11, 2010 at 12:15 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> +Loads any auto-loaded scripts provided by the program being debugged.
>> +@xref{Auto-loading}.
>
> In addition to the same rewording as above, this sounds inaccurate:
> aren't these scripts loaded only as part of loading the debuggee's
> executable file?  If so, we should mention that here, because (AFAIU),
> invoking GDB without any program as the argument won't trigger any
> auto-loading.

Reword per suggestion, but I kinda like the original wording.
The context here is startup, e.g. shared libraries aren't read at this point.
If you wish a different wording, can you provide one? Thanks.

>>  @table @code
>> -@kindex maint set python auto-load
>> -@item maint set python auto-load [yes|no]
>> -Enable or disable the Python auto-loading feature.
>> -
>> -@kindex maint show python auto-load
>> -@item maint show python auto-load
>> -Show whether Python auto-loading is enabled or disabled.
>> +@kindex set auto-load
>> +@item set auto-load [yes|no]
>> +Enable or disable the auto-loading of scripts.
>> +
>> +@kindex show auto-load
>> +@item show auto-load
>> +Show whether auto-loading is enabled or disabled.
>>  @end table
>
> If we are going to leave this section inside the Python chapter, then
> we should say "auto-load Python scripts" etc. elsewhere, because this
> feature is limited to loading Python scripts, right?

I like what it's in the patch.
There's no reason why one couldn't have non-python auto-loaded
scripts, and there's no reason at the moment for having a different
option to control them.
So I don't want "python" in the option name.
Having it the Python section of the manual is fine for now since
that's all we currently support.

Ok to check in?

2010-12-10 Doug Evans <dje@google.com>

Rename "maint set python auto-load" to "set auto-load-scripts".
* NEWS: Mention it.
* python/py-auto-load.c (auto_load_scripts): Renamed from
gdbpy_auto_load.
(load_auto_scripts_for_objfile): Update.
(gdbpy_initialize_auto_load): Rename "maint set python auto-load" to
"set auto-load-scripts".

doc/
* gdb.texinfo (Startup): Document auto-loading of scripts during
startup.
(Auto-loading): Delete "maint set python auto-load on|off".
Add "set auto-load-scripts on|off".

[-- Attachment #2: gdb-101214-auto-load-2.patch.txt --]
[-- Type: text/plain, Size: 5858 bytes --]

2010-12-10 Doug Evans <dje@google.com>

Rename "maint set python auto-load" to "set auto-load-scripts".
* NEWS: Mention it.
* python/py-auto-load.c (auto_load_scripts): Renamed from
gdbpy_auto_load.
(load_auto_scripts_for_objfile): Update.
(gdbpy_initialize_auto_load): Rename "maint set python auto-load" to
"set auto-load-scripts".

doc/
* gdb.texinfo (Startup): Document auto-loading of scripts during
startup.
(Auto-loading): Delete "maint set python auto-load on|off".
Add "set auto-load-scripts on|off".

Index: NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.414
diff -u -p -r1.414 NEWS
--- NEWS 10 Dec 2010 20:33:44 -0000 1.414
+++ NEWS 15 Dec 2010 01:29:46 -0000
@@ -8,6 +8,9 @@
-data-directory DIR Specify DIR as the "data-directory".
This is mostly for testing purposes.

+* The "maint set python auto-load on|off" command has been renamed to
+ "set auto-load-scripts on|off".
+
* GDB has a new command: "set directories".
It is like the "dir" command except that it replaces the
source path list instead of augmenting it.
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.779
diff -u -p -r1.779 gdb.texinfo
--- doc/gdb.texinfo 7 Dec 2010 17:26:03 -0000 1.779
+++ doc/gdb.texinfo 15 Dec 2010 01:29:47 -0000
@@ -1263,6 +1263,23 @@ to the program you are debugging, in the
@value{GDBN}.

@item
+Loads any auto-loaded scripts when programs or shared-libraries are loaded.
+@xref{Auto-loading}.
+
+If you wish to disable the auto-loading of scripts from a program
+specified on the command line, you must do something like the following:
+
+@smallexample
+$ gdb -ex "set auto-load-scripts off" -ex "file myprogram"
+@end smallexample
+
+The following does not work because the auto-loading is turned off too late:
+
+@smallexample
+$ gdb -ex "set auto-load-scripts off" myprogram
+@end smallexample
+
+@item
Reads command files specified by the @samp{-x} option. @xref{Command
Files}, for more details about @value{GDBN} command files.

@@ -23114,13 +23131,13 @@ debugging commands and scripts.
Auto-loading can be enabled or disabled.

@table @code
-@kindex maint set python auto-load
-@item maint set python auto-load [yes|no]
-Enable or disable the Python auto-loading feature.
-
-@kindex maint show python auto-load
-@item maint show python auto-load
-Show whether Python auto-loading is enabled or disabled.
+@kindex set auto-load-scripts
+@item set auto-load-scripts [yes|no]
+Enable or disable the auto-loading of scripts.
+
+@kindex show auto-load-scripts
+@item show auto-load-scripts
+Show whether auto-loading is enabled or disabled.
@end table

When reading an auto-loaded file, @value{GDBN} sets the
Index: python/py-auto-load.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-auto-load.c,v
retrieving revision 1.5
diff -u -p -r1.5 py-auto-load.c
--- python/py-auto-load.c 22 Sep 2010 20:00:53 -0000 1.5
+++ python/py-auto-load.c 15 Dec 2010 01:29:47 -0000
@@ -34,7 +34,7 @@
This is true if we should auto-load python code when an objfile is opened,
false otherwise.

- Both gdbpy_auto_load && gdbpy_global_auto_load must be true to enable
+ Both auto_load_scripts && gdbpy_global_auto_load must be true to enable
auto-loading.

This flag exists to facilitate deferring auto-loading during start-up
@@ -82,10 +82,15 @@ struct loaded_script_entry
};

/* User-settable option to enable/disable auto-loading:
- maint set python auto-load on|off
- This is true if we should auto-load python code when an objfile is opened,
- false otherwise. */
-static int gdbpy_auto_load = 1;
+ set auto-load-scripts on|off
+ This is true if we should auto-load associated scripts when an objfile
+ is opened, false otherwise.
+ At the moment, this only affects python scripts, but there's no reason
+ one couldn't also have other kinds of auto-loaded scripts, and there's
+ no reason to have them each controlled by a separate flag.
+ So we elide "python" from the name here and in the option.
+ The fact that it lives here is just an implementation detail. */
+static int auto_load_scripts = 1;

/* Per-program-space data key. */
static const struct program_space_data *auto_load_pspace_data;
@@ -404,7 +409,7 @@ auto_load_new_objfile (struct objfile *o
void
load_auto_scripts_for_objfile (struct objfile *objfile)
{
- if (gdbpy_auto_load && gdbpy_global_auto_load)
+ if (auto_load_scripts && gdbpy_global_auto_load)
{
auto_load_objfile_script (objfile, GDBPY_AUTO_FILE_NAME);
auto_load_section_scripts (objfile, GDBPY_AUTO_SECTION_NAME);
@@ -471,14 +476,15 @@ gdbpy_initialize_auto_load (void)

observer_attach_new_objfile (auto_load_new_objfile);

- add_setshow_boolean_cmd ("auto-load", class_maintenance,
- &gdbpy_auto_load, _("\
-Enable or disable auto-loading of Python code when an object is opened."), _("\
-Show whether Python code will be auto-loaded when an object is opened."), _("\
-Enables or disables auto-loading of Python code when an object is opened."),
+ add_setshow_boolean_cmd ("auto-load-scripts", class_support,
+ &auto_load_scripts, _("\
+Set the debugger's behaviour regarding auto-loaded scripts."), _("\
+Show the debugger's behaviour regarding auto-loaded scripts."), _("\
+If enabled, auto-loaded scripts are loaded when the debugger reads\n\
+an executable or shared library."),
NULL, NULL,
- &set_python_list,
- &show_python_list);
+ &setlist,
+ &showlist);

add_cmd ("section-scripts", class_maintenance, maintenance_print_section_scripts,
_("Print dump of auto-loaded section scripts matching REGEXP."),