diff options
author | Doug Evans <dje@google.com> | 2010-04-23 18:09:16 +0000 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2010-04-23 18:09:16 +0000 |
commit | 88a1906b0da33e2905cce61e133b67cdde314847 (patch) | |
tree | 8aad3a1bd84d470955e81b5eb1c79efc3ff1f7dd /gdb/python/py-auto-load.c | |
parent | 66d0954266e5613064244015f3963ea617463ecf (diff) | |
download | gdb-88a1906b0da33e2905cce61e133b67cdde314847.zip gdb-88a1906b0da33e2905cce61e133b67cdde314847.tar.gz gdb-88a1906b0da33e2905cce61e133b67cdde314847.tar.bz2 |
* configure.ac (CONFIG_SRCS): Add py-auto-load.o even if not using
python.
* configure: Regenerate.
* main.c: #include "python/python.h".
(captured_main): Defer loading auto-loaded scripts until after
local_gdbinit has been sourced.
* python/py-auto-load.c (gdbpy_global_auto_load): New global.
(load_auto_scripts_for_objfile): New function.
(auto_load_new_objfile): Call it.
* python/python.h (gdbpy_global_auto_load): Declare.
(load_auto_scripts_for_objfile): Declare.
Diffstat (limited to 'gdb/python/py-auto-load.c')
-rw-r--r-- | gdb/python/py-auto-load.c | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/gdb/python/py-auto-load.c b/gdb/python/py-auto-load.c index e3b406c..a06c126 100644 --- a/gdb/python/py-auto-load.c +++ b/gdb/python/py-auto-load.c @@ -28,9 +28,24 @@ #include "progspace.h" #include "objfiles.h" #include "python.h" -#include "python-internal.h" #include "cli/cli-cmds.h" +/* Internal-use flag to enable/disable auto-loading. + 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 + auto-loading. + + This flag exists to facilitate deferring auto-loading during start-up + until after ./.gdbinit has been read; it may augment the search directories + used to find the scripts. */ +int gdbpy_global_auto_load = 1; + +#ifdef HAVE_PYTHON + +#include "python-internal.h" + /* NOTE: It's trivial to also support auto-loading normal gdb scripts. There has yet to be a need so it's not implemented. */ @@ -66,7 +81,9 @@ struct loaded_script_entry const char *full_path; }; -/* This is true if we should auto-load python code when an objfile is opened, +/* 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; @@ -377,7 +394,15 @@ auto_load_new_objfile (struct objfile *objfile) if (!objfile->name) return; - if (gdbpy_auto_load) + load_auto_scripts_for_objfile (objfile); +} + +/* Load any auto-loaded scripts for OBJFILE. */ + +void +load_auto_scripts_for_objfile (struct objfile *objfile) +{ + if (gdbpy_auto_load && gdbpy_global_auto_load) { auto_load_objfile_script (objfile, GDBPY_AUTO_FILE_NAME); auto_load_section_scripts (objfile, GDBPY_AUTO_SECTION_NAME); @@ -457,3 +482,12 @@ Enables or disables auto-loading of Python code when an object is opened."), _("Print dump of auto-loaded section scripts matching REGEXP."), &maintenanceprintlist); } + +#else /* ! HAVE_PYTHON */ + +void +load_auto_scripts_for_objfile (struct objfile *objfile) +{ +} + +#endif /* ! HAVE_PYTHON */ |