* 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.
This commit is contained in:
parent
66d0954266
commit
88a1906b0d
6 changed files with 76 additions and 9 deletions
|
@ -1,5 +1,17 @@
|
||||||
2010-04-23 Doug Evans <dje@google.com>
|
2010-04-23 Doug Evans <dje@google.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
Add support for auto-loading scripts from .debug_gdb_scripts section.
|
Add support for auto-loading scripts from .debug_gdb_scripts section.
|
||||||
* NEWS: Add entry for .debug_gdb_scripts.
|
* NEWS: Add entry for .debug_gdb_scripts.
|
||||||
* Makefile.in SUBDIR_PYTHON_OBS): Add py-auto-load.o.
|
* Makefile.in SUBDIR_PYTHON_OBS): Add py-auto-load.o.
|
||||||
|
|
7
gdb/configure
vendored
7
gdb/configure
vendored
|
@ -9648,9 +9648,10 @@ $as_echo "${PYTHON_CFLAGS}" >&6; }
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Even if Python support is not compiled in, we need to have these files
|
# Even if Python support is not compiled in, we need to have these files
|
||||||
# included in order to recognize the GDB command "python".
|
# included.
|
||||||
CONFIG_OBS="$CONFIG_OBS python.o py-value.o py-prettyprint.o"
|
CONFIG_OBS="$CONFIG_OBS python.o py-value.o py-prettyprint.o py-auto-load.o"
|
||||||
CONFIG_SRCS="$CONFIG_SRCS python/python.c python/py-value.c python/py-prettyprint.c"
|
CONFIG_SRCS="$CONFIG_SRCS python/python.c python/py-value.c \
|
||||||
|
python/py-prettyprint.c python/py-auto-load.c"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -701,9 +701,10 @@ if test "${have_libpython}" = yes; then
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Even if Python support is not compiled in, we need to have these files
|
# Even if Python support is not compiled in, we need to have these files
|
||||||
# included in order to recognize the GDB command "python".
|
# included.
|
||||||
CONFIG_OBS="$CONFIG_OBS python.o py-value.o py-prettyprint.o"
|
CONFIG_OBS="$CONFIG_OBS python.o py-value.o py-prettyprint.o py-auto-load.o"
|
||||||
CONFIG_SRCS="$CONFIG_SRCS python/python.c python/py-value.c python/py-prettyprint.c"
|
CONFIG_SRCS="$CONFIG_SRCS python/python.c python/py-value.c \
|
||||||
|
python/py-prettyprint.c python/py-auto-load.c"
|
||||||
fi
|
fi
|
||||||
AC_SUBST(PYTHON_CFLAGS)
|
AC_SUBST(PYTHON_CFLAGS)
|
||||||
|
|
||||||
|
|
15
gdb/main.c
15
gdb/main.c
|
@ -41,6 +41,7 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "source.h"
|
#include "source.h"
|
||||||
#include "cli/cli-cmds.h"
|
#include "cli/cli-cmds.h"
|
||||||
|
#include "python/python.h"
|
||||||
|
|
||||||
/* If nonzero, display time usage both at startup and for each command. */
|
/* If nonzero, display time usage both at startup and for each command. */
|
||||||
|
|
||||||
|
@ -291,6 +292,7 @@ captured_main (void *data)
|
||||||
char *local_gdbinit;
|
char *local_gdbinit;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
int save_auto_load;
|
||||||
|
|
||||||
long time_at_startup = get_run_time ();
|
long time_at_startup = get_run_time ();
|
||||||
|
|
||||||
|
@ -798,6 +800,11 @@ Excess command line arguments ignored. (%s%s)\n"),
|
||||||
catch_command_errors (directory_switch, dirarg[i], 0, RETURN_MASK_ALL);
|
catch_command_errors (directory_switch, dirarg[i], 0, RETURN_MASK_ALL);
|
||||||
xfree (dirarg);
|
xfree (dirarg);
|
||||||
|
|
||||||
|
/* Skip auto-loading section-specified scripts until we've sourced
|
||||||
|
local_gdbinit (which is often used to augment the source search path). */
|
||||||
|
save_auto_load = gdbpy_global_auto_load;
|
||||||
|
gdbpy_global_auto_load = 0;
|
||||||
|
|
||||||
if (execarg != NULL
|
if (execarg != NULL
|
||||||
&& symarg != NULL
|
&& symarg != NULL
|
||||||
&& strcmp (execarg, symarg) == 0)
|
&& strcmp (execarg, symarg) == 0)
|
||||||
|
@ -857,6 +864,14 @@ Can't attach to process and specify a core file at the same time."));
|
||||||
if (local_gdbinit && !inhibit_gdbinit)
|
if (local_gdbinit && !inhibit_gdbinit)
|
||||||
catch_command_errors (source_script, local_gdbinit, 0, RETURN_MASK_ALL);
|
catch_command_errors (source_script, local_gdbinit, 0, RETURN_MASK_ALL);
|
||||||
|
|
||||||
|
/* Now that all .gdbinit's have been read and all -d options have been
|
||||||
|
processed, we can read any scripts mentioned in SYMARG.
|
||||||
|
We wait until now because it is common to add to the source search
|
||||||
|
path in local_gdbinit. */
|
||||||
|
gdbpy_global_auto_load = save_auto_load;
|
||||||
|
if (symfile_objfile != NULL)
|
||||||
|
load_auto_scripts_for_objfile (symfile_objfile);
|
||||||
|
|
||||||
for (i = 0; i < ncmd; i++)
|
for (i = 0; i < ncmd; i++)
|
||||||
{
|
{
|
||||||
if (cmdarg[i].type == CMDARG_FILE)
|
if (cmdarg[i].type == CMDARG_FILE)
|
||||||
|
|
|
@ -28,9 +28,24 @@
|
||||||
#include "progspace.h"
|
#include "progspace.h"
|
||||||
#include "objfiles.h"
|
#include "objfiles.h"
|
||||||
#include "python.h"
|
#include "python.h"
|
||||||
#include "python-internal.h"
|
|
||||||
#include "cli/cli-cmds.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.
|
/* NOTE: It's trivial to also support auto-loading normal gdb scripts.
|
||||||
There has yet to be a need so it's not implemented. */
|
There has yet to be a need so it's not implemented. */
|
||||||
|
|
||||||
|
@ -66,7 +81,9 @@ struct loaded_script_entry
|
||||||
const char *full_path;
|
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. */
|
false otherwise. */
|
||||||
static int gdbpy_auto_load = 1;
|
static int gdbpy_auto_load = 1;
|
||||||
|
|
||||||
|
@ -377,7 +394,15 @@ auto_load_new_objfile (struct objfile *objfile)
|
||||||
if (!objfile->name)
|
if (!objfile->name)
|
||||||
return;
|
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_objfile_script (objfile, GDBPY_AUTO_FILE_NAME);
|
||||||
auto_load_section_scripts (objfile, GDBPY_AUTO_SECTION_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."),
|
_("Print dump of auto-loaded section scripts matching REGEXP."),
|
||||||
&maintenanceprintlist);
|
&maintenanceprintlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else /* ! HAVE_PYTHON */
|
||||||
|
|
||||||
|
void
|
||||||
|
load_auto_scripts_for_objfile (struct objfile *objfile)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ! HAVE_PYTHON */
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
#include "value.h"
|
#include "value.h"
|
||||||
|
|
||||||
|
extern int gdbpy_global_auto_load;
|
||||||
|
|
||||||
void eval_python_from_control_command (struct command_line *);
|
void eval_python_from_control_command (struct command_line *);
|
||||||
|
|
||||||
void source_python_script (FILE *stream, const char *file);
|
void source_python_script (FILE *stream, const char *file);
|
||||||
|
@ -34,4 +36,6 @@ int apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
|
||||||
|
|
||||||
void preserve_python_values (struct objfile *objfile, htab_t copied_types);
|
void preserve_python_values (struct objfile *objfile, htab_t copied_types);
|
||||||
|
|
||||||
|
void load_auto_scripts_for_objfile (struct objfile *objfile);
|
||||||
|
|
||||||
#endif /* GDB_PYTHON_H */
|
#endif /* GDB_PYTHON_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue