* mi/mi-main.c: Include python-internal.h.

(mi_cmd_list_features): Check gdb_python_initialized.
	* python/py-inferior.c (python_on_normal_stop, python_on_resume)
	(python_inferior_exit, python_new_objfile, add_thread_object)
	(delete_thread_object, py_free_inferior): Check
	gdb_python_initialized.
	* python/py-prettyprint.c (apply_val_pretty_printer): Check
	gdb_python_initialized.
	* python/py-type.c (save_objfile_types): Check
	gdb_python_initialized.
	* python/python-internal.h (gdb_python_initialized): Declare.
	* python/python.c (ensure_python_env): Throw exception if
	Python not initialized.
	(before_prompt_hook, source_python_script_for_objfile)
	(start_type_printers, apply_type_printers,
	free_type_printers): Check gdb_python_initialized.
	* varobj.c (varobj_get_display_hint)
	(dynamic_varobj_has_child_method, update_dynamic_varobj_children)
	(install_new_value_visualizer, varobj_set_visualizer)
	(value_get_print_value): Check gdb_python_initialized.
This commit is contained in:
Tom Tromey
2013-05-20 20:29:44 +00:00
parent 999633ede7
commit 0646da15da
8 changed files with 169 additions and 76 deletions

View File

@ -150,6 +150,10 @@ ensure_python_env (struct gdbarch *gdbarch,
{
struct python_env *env = xmalloc (sizeof *env);
/* We should not ever enter Python unless initialized. */
if (!gdb_python_initialized)
error (_("Python not initialized"));
env->state = PyGILState_Ensure ();
env->gdbarch = python_gdbarch;
env->language = python_language;
@ -896,6 +900,9 @@ before_prompt_hook (const char *current_gdb_prompt)
struct cleanup *cleanup;
char *prompt = NULL;
if (!gdb_python_initialized)
return;
cleanup = ensure_python_env (get_current_arch (), current_language);
if (gdb_python_module
@ -1159,6 +1166,9 @@ source_python_script_for_objfile (struct objfile *objfile, FILE *file,
{
struct cleanup *cleanups;
if (!gdb_python_initialized)
return;
cleanups = ensure_python_env (get_objfile_arch (objfile), current_language);
gdbpy_current_objfile = objfile;
@ -1220,6 +1230,9 @@ start_type_printers (void)
struct cleanup *cleanups;
PyObject *type_module, *func, *result_obj = NULL;
if (!gdb_python_initialized)
return NULL;
cleanups = ensure_python_env (get_current_arch (), current_language);
type_module = PyImport_ImportModule ("gdb.types");
@ -1266,6 +1279,9 @@ apply_type_printers (void *printers, struct type *type)
if (printers_obj == NULL)
return NULL;
if (!gdb_python_initialized)
return NULL;
cleanups = ensure_python_env (get_current_arch (), current_language);
type_obj = type_to_type_object (type);
@ -1324,6 +1340,9 @@ free_type_printers (void *arg)
if (printers == NULL)
return;
if (!gdb_python_initialized)
return;
cleanups = ensure_python_env (get_current_arch (), current_language);
Py_DECREF (printers);
do_cleanups (cleanups);