gdb: extension languages finish_initialization to initialize
Now that both Python and Guile are fully initialized from their respective finish_initialization methods, the "finish" in the method name doesn't really make sense; initialization starts _and_ finishes with that method. As such, this commit renames finish_initialization to just initialize. There should be no user visible changes after this commit. gdb/ChangeLog: * extension-priv.h (struct extension_language_ops): Rename 'finish_initialization' to 'initialize'. * extension.c (finish_ext_lang_initialization): Renamed to... (ext_lang_initialization): ...this, update comment, and updated the calls to reflect the change in struct extension_language_ops. * extension.h (finish_ext_lang_initialization): Renamed to... (ext_lang_initialization): ...this. * guile/guile.c (gdbscm_finish_initialization): Renamed to... (gdbscm_initialize): ...this, update comment at definition. (guile_extension_ops): Update. * main.c (captured_main_1): Update call to finish_ext_lang_initialization. * python/python.c (gdbpy_finish_initialization): Rename to... (gdbpy_initialize): ...this, update comment at definition, and update call to do_finish_initialization. (python_extension_ops): Update. (do_finish_initialization): Rename to... (do_initialize): ...this, and update comment.
This commit is contained in:
parent
1178f01adf
commit
041ca48e97
7 changed files with 50 additions and 33 deletions
|
@ -1,3 +1,24 @@
|
||||||
|
2021-04-28 Andrew Burgess <andrew.burgess@embecosm.com>
|
||||||
|
|
||||||
|
* extension-priv.h (struct extension_language_ops): Rename
|
||||||
|
'finish_initialization' to 'initialize'.
|
||||||
|
* extension.c (finish_ext_lang_initialization): Renamed to...
|
||||||
|
(ext_lang_initialization): ...this, update comment, and updated
|
||||||
|
the calls to reflect the change in struct extension_language_ops.
|
||||||
|
* extension.h (finish_ext_lang_initialization): Renamed to...
|
||||||
|
(ext_lang_initialization): ...this.
|
||||||
|
* guile/guile.c (gdbscm_finish_initialization): Renamed to...
|
||||||
|
(gdbscm_initialize): ...this, update comment at definition.
|
||||||
|
(guile_extension_ops): Update.
|
||||||
|
* main.c (captured_main_1): Update call to
|
||||||
|
finish_ext_lang_initialization.
|
||||||
|
* python/python.c (gdbpy_finish_initialization): Rename to...
|
||||||
|
(gdbpy_initialize): ...this, update comment at definition, and
|
||||||
|
update call to do_finish_initialization.
|
||||||
|
(python_extension_ops): Update.
|
||||||
|
(do_finish_initialization): Rename to...
|
||||||
|
(do_initialize): ...this, and update comment.
|
||||||
|
|
||||||
2021-04-28 Andrew Burgess <andrew.burgess@embecosm.com>
|
2021-04-28 Andrew Burgess <andrew.burgess@embecosm.com>
|
||||||
|
|
||||||
* main.c (captured_main_1): Add a call to
|
* main.c (captured_main_1): Add a call to
|
||||||
|
|
|
@ -109,10 +109,11 @@ struct extension_language_script_ops
|
||||||
|
|
||||||
struct extension_language_ops
|
struct extension_language_ops
|
||||||
{
|
{
|
||||||
/* Called at the end of gdb initialization to give the extension language
|
/* Called after GDB has processed the early initialization settings
|
||||||
an opportunity to finish up. This is useful for things like adding
|
files. This is when the extension language should be initialized. By
|
||||||
new commands where one has to wait until gdb itself is initialized. */
|
the time this is called all of the earlier initialization functions
|
||||||
void (*finish_initialization) (const struct extension_language_defn *);
|
have already been called. */
|
||||||
|
void (*initialize) (const struct extension_language_defn *);
|
||||||
|
|
||||||
/* Return non-zero if the extension language successfully initialized.
|
/* Return non-zero if the extension language successfully initialized.
|
||||||
This method is required. */
|
This method is required. */
|
||||||
|
|
|
@ -323,19 +323,19 @@ using scoped_default_sigint = scoped_default_signal<SIGINT>;
|
||||||
These only iterate over external extension languages, not including
|
These only iterate over external extension languages, not including
|
||||||
GDB's own extension/scripting language, unless otherwise indicated. */
|
GDB's own extension/scripting language, unless otherwise indicated. */
|
||||||
|
|
||||||
/* Wrapper to call the extension_language_ops.finish_initialization "method"
|
/* Wrapper to call the extension_language_ops.initialize "method" for each
|
||||||
for each compiled-in extension language. */
|
compiled-in extension language. */
|
||||||
|
|
||||||
void
|
void
|
||||||
finish_ext_lang_initialization (void)
|
ext_lang_initialization (void)
|
||||||
{
|
{
|
||||||
for (const struct extension_language_defn *extlang : extension_languages)
|
for (const struct extension_language_defn *extlang : extension_languages)
|
||||||
{
|
{
|
||||||
if (extlang->ops != nullptr
|
if (extlang->ops != nullptr
|
||||||
&& extlang->ops->finish_initialization != NULL)
|
&& extlang->ops->initialize != NULL)
|
||||||
{
|
{
|
||||||
scoped_default_sigint set_sigint_to_default_handler;
|
scoped_default_sigint set_sigint_to_default_handler;
|
||||||
extlang->ops->finish_initialization (extlang);
|
extlang->ops->initialize (extlang);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,7 +276,7 @@ extern bool ext_lang_auto_load_enabled (const struct extension_language_defn *);
|
||||||
/* Wrappers for each extension language API function that iterate over all
|
/* Wrappers for each extension language API function that iterate over all
|
||||||
extension languages. */
|
extension languages. */
|
||||||
|
|
||||||
extern void finish_ext_lang_initialization (void);
|
extern void ext_lang_initialization (void);
|
||||||
|
|
||||||
extern void eval_ext_lang_from_control_command (struct command_line *cmd);
|
extern void eval_ext_lang_from_control_command (struct command_line *cmd);
|
||||||
|
|
||||||
|
|
|
@ -75,8 +75,7 @@ const char *gdbscm_print_excp = gdbscm_print_excp_message;
|
||||||
|
|
||||||
#ifdef HAVE_GUILE
|
#ifdef HAVE_GUILE
|
||||||
|
|
||||||
static void gdbscm_finish_initialization
|
static void gdbscm_initialize (const struct extension_language_defn *);
|
||||||
(const struct extension_language_defn *);
|
|
||||||
static int gdbscm_initialized (const struct extension_language_defn *);
|
static int gdbscm_initialized (const struct extension_language_defn *);
|
||||||
static void gdbscm_eval_from_control_command
|
static void gdbscm_eval_from_control_command
|
||||||
(const struct extension_language_defn *, struct command_line *);
|
(const struct extension_language_defn *, struct command_line *);
|
||||||
|
@ -113,7 +112,7 @@ static const struct extension_language_script_ops guile_extension_script_ops =
|
||||||
|
|
||||||
static const struct extension_language_ops guile_extension_ops =
|
static const struct extension_language_ops guile_extension_ops =
|
||||||
{
|
{
|
||||||
gdbscm_finish_initialization,
|
gdbscm_initialize,
|
||||||
gdbscm_initialized,
|
gdbscm_initialized,
|
||||||
|
|
||||||
gdbscm_eval_from_control_command,
|
gdbscm_eval_from_control_command,
|
||||||
|
@ -638,12 +637,11 @@ call_initialize_gdb_module (void *data)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A callback to finish Guile initialization after gdb has finished all its
|
/* A callback to initialize Guile after gdb has finished all its
|
||||||
initialization.
|
initialization. This is the extension_language_ops.initialize "method". */
|
||||||
This is the extension_language_ops.finish_initialization "method". */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdbscm_finish_initialization (const struct extension_language_defn *extlang)
|
gdbscm_initialize (const struct extension_language_defn *extlang)
|
||||||
{
|
{
|
||||||
#if HAVE_GUILE
|
#if HAVE_GUILE
|
||||||
/* The Python support puts the C side in module "_gdb", leaving the
|
/* The Python support puts the C side in module "_gdb", leaving the
|
||||||
|
|
|
@ -1053,8 +1053,8 @@ captured_main_1 (struct captured_main_args *context)
|
||||||
execute_cmdargs (&cmdarg_vec, CMDARG_EARLYINIT_FILE,
|
execute_cmdargs (&cmdarg_vec, CMDARG_EARLYINIT_FILE,
|
||||||
CMDARG_EARLYINIT_COMMAND, &ret);
|
CMDARG_EARLYINIT_COMMAND, &ret);
|
||||||
|
|
||||||
/* Finish initializing the extension languges. */
|
/* Initialize the extension languages. */
|
||||||
finish_ext_lang_initialization ();
|
ext_lang_initialization ();
|
||||||
|
|
||||||
/* Recheck if we're starting up quietly after processing the startup
|
/* Recheck if we're starting up quietly after processing the startup
|
||||||
scripts and commands. */
|
scripts and commands. */
|
||||||
|
|
|
@ -129,8 +129,7 @@ PyObject *gdbpy_gdb_memory_error;
|
||||||
static script_sourcer_func gdbpy_source_script;
|
static script_sourcer_func gdbpy_source_script;
|
||||||
static objfile_script_sourcer_func gdbpy_source_objfile_script;
|
static objfile_script_sourcer_func gdbpy_source_objfile_script;
|
||||||
static objfile_script_executor_func gdbpy_execute_objfile_script;
|
static objfile_script_executor_func gdbpy_execute_objfile_script;
|
||||||
static void gdbpy_finish_initialization
|
static void gdbpy_initialize (const struct extension_language_defn *);
|
||||||
(const struct extension_language_defn *);
|
|
||||||
static int gdbpy_initialized (const struct extension_language_defn *);
|
static int gdbpy_initialized (const struct extension_language_defn *);
|
||||||
static void gdbpy_eval_from_control_command
|
static void gdbpy_eval_from_control_command
|
||||||
(const struct extension_language_defn *, struct command_line *cmd);
|
(const struct extension_language_defn *, struct command_line *cmd);
|
||||||
|
@ -162,7 +161,7 @@ const struct extension_language_script_ops python_extension_script_ops =
|
||||||
|
|
||||||
const struct extension_language_ops python_extension_ops =
|
const struct extension_language_ops python_extension_ops =
|
||||||
{
|
{
|
||||||
gdbpy_finish_initialization,
|
gdbpy_initialize,
|
||||||
gdbpy_initialized,
|
gdbpy_initialized,
|
||||||
|
|
||||||
gdbpy_eval_from_control_command,
|
gdbpy_eval_from_control_command,
|
||||||
|
@ -1885,12 +1884,12 @@ message == an error message without a stack will be printed."),
|
||||||
|
|
||||||
#ifdef HAVE_PYTHON
|
#ifdef HAVE_PYTHON
|
||||||
|
|
||||||
/* Helper function for gdbpy_finish_initialization. This does the
|
/* Helper function for gdbpy_initialize. This does the work and then
|
||||||
work and then returns false if an error has occurred and must be
|
returns false if an error has occurred and must be displayed, or true on
|
||||||
displayed, or true on success. */
|
success. */
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
do_finish_initialization (const struct extension_language_defn *extlang)
|
do_initialize (const struct extension_language_defn *extlang)
|
||||||
{
|
{
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
PyObject *sys_path;
|
PyObject *sys_path;
|
||||||
|
@ -1948,21 +1947,19 @@ do_finish_initialization (const struct extension_language_defn *extlang)
|
||||||
return gdb_pymodule_addobject (m, "gdb", gdb_python_module) >= 0;
|
return gdb_pymodule_addobject (m, "gdb", gdb_python_module) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform the remaining python initializations.
|
/* Perform Python initialization. This will be called after GDB has
|
||||||
These must be done after GDB is at least mostly initialized.
|
performed all of its own initialization. This is the
|
||||||
E.g., The "info pretty-printer" command needs the "info" prefix
|
extension_language_ops.initialize "method". */
|
||||||
command installed.
|
|
||||||
This is the extension_language_ops.finish_initialization "method". */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdbpy_finish_initialization (const struct extension_language_defn *extlang)
|
gdbpy_initialize (const struct extension_language_defn *extlang)
|
||||||
{
|
{
|
||||||
if (!do_start_initialization () && PyErr_Occurred ())
|
if (!do_start_initialization () && PyErr_Occurred ())
|
||||||
gdbpy_print_stack ();
|
gdbpy_print_stack ();
|
||||||
|
|
||||||
gdbpy_enter enter_py (get_current_arch (), current_language);
|
gdbpy_enter enter_py (get_current_arch (), current_language);
|
||||||
|
|
||||||
if (!do_finish_initialization (extlang))
|
if (!do_initialize (extlang))
|
||||||
{
|
{
|
||||||
gdbpy_print_stack ();
|
gdbpy_print_stack ();
|
||||||
warning (_("internal error: Unhandled Python exception"));
|
warning (_("internal error: Unhandled Python exception"));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue