|
28 | 28 | #include "progspace.h" |
29 | 29 | #include "objfiles.h" |
30 | 30 | #include "python.h" |
31 | | -#include "python-internal.h" |
32 | 31 | #include "cli/cli-cmds.h" |
33 | 32 |
|
| 33 | +/* Internal-use flag to enable/disable auto-loading. |
| 34 | + This is true if we should auto-load python code when an objfile is opened, |
| 35 | + false otherwise. |
| 36 | +
|
| 37 | + Both gdbpy_auto_load && gdbpy_global_auto_load must be true to enable |
| 38 | + auto-loading. |
| 39 | +
|
| 40 | + This flag exists to facilitate deferring auto-loading during start-up |
| 41 | + until after ./.gdbinit has been read; it may augment the search directories |
| 42 | + used to find the scripts. */ |
| 43 | +int gdbpy_global_auto_load = 1; |
| 44 | + |
| 45 | +#ifdef HAVE_PYTHON |
| 46 | + |
| 47 | +#include "python-internal.h" |
| 48 | + |
34 | 49 | /* NOTE: It's trivial to also support auto-loading normal gdb scripts. |
35 | 50 | There has yet to be a need so it's not implemented. */ |
36 | 51 |
|
@@ -66,7 +81,9 @@ struct loaded_script_entry |
66 | 81 | const char *full_path; |
67 | 82 | }; |
68 | 83 |
|
69 | | -/* This is true if we should auto-load python code when an objfile is opened, |
| 84 | +/* User-settable option to enable/disable auto-loading: |
| 85 | + maint set python auto-load on|off |
| 86 | + This is true if we should auto-load python code when an objfile is opened, |
70 | 87 | false otherwise. */ |
71 | 88 | static int gdbpy_auto_load = 1; |
72 | 89 |
|
@@ -377,7 +394,15 @@ auto_load_new_objfile (struct objfile *objfile) |
377 | 394 | if (!objfile->name) |
378 | 395 | return; |
379 | 396 |
|
380 | | - if (gdbpy_auto_load) |
| 397 | + load_auto_scripts_for_objfile (objfile); |
| 398 | +} |
| 399 | + |
| 400 | +/* Load any auto-loaded scripts for OBJFILE. */ |
| 401 | + |
| 402 | +void |
| 403 | +load_auto_scripts_for_objfile (struct objfile *objfile) |
| 404 | +{ |
| 405 | + if (gdbpy_auto_load && gdbpy_global_auto_load) |
381 | 406 | { |
382 | 407 | auto_load_objfile_script (objfile, GDBPY_AUTO_FILE_NAME); |
383 | 408 | 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."), |
457 | 482 | _("Print dump of auto-loaded section scripts matching REGEXP."), |
458 | 483 | &maintenanceprintlist); |
459 | 484 | } |
| 485 | + |
| 486 | +#else /* ! HAVE_PYTHON */ |
| 487 | + |
| 488 | +void |
| 489 | +load_auto_scripts_for_objfile (struct objfile *objfile) |
| 490 | +{ |
| 491 | +} |
| 492 | + |
| 493 | +#endif /* ! HAVE_PYTHON */ |
0 commit comments