* python/python-internal.h (struct language_defn): Declare.

(python_gdbarch, python_language): Likewise.
	(ensure_python_env): Add prototype.
	(make_cleanup_py_restore_gil): Remove prototype.

	* python/python.c: Include "arch-utils.h", "value.h" and "language.h".
	(python_gdbarch, python_language): New global variables.
	(struct python_env): New data type.
	(ensure_python_env, restore_python_env): New functions.
	(eval_python_from_control_command): Call ensure_python_env to
	install current architecture and language.
	(python_command, gdbpy_new_objfile): Likewise.
	* python/python-cmd.c: Include "arch-utils.h" and "language.h".
	(cmdpy_destroyer, cmdpy_function, cmdpy_completer): Call
	ensure_python_env.
	* python/python-type.c (clean_up_objfile_types): Likewise.
	* python/python-objfile.c: Include "language.h".
	(clean_up_objfile): Call ensure_python_env.
	* python/python-prettyprint.c (apply_val_pretty_printer): Likewise.
	(apply_varobj_pretty_printer): Do not call PyGILState_Ensure.
	* varobj.c (varobj_ensure_python_env): New helper function.
	(varobj_get_display_hint, update_dynamic_varobj_children,
	install_default_visualizer, varobj_set_visualizer, free_variable,
	value_get_print_value): Call it.
	(value_get_print_value): Add varobj argument instead of pretty
	printer argument.  Update all callers.

	* python/python-utils.c (py_gil_restore, make_cleanup_py_restore_gil):
	Remove.

	* value.h (internal_function_fn): Add GDBARCH and LANGUAGE argument.
	(call_internal_function): Likewise.
	* value.c (call_internal_function): Likewise.  Pass to handler.
	* eval.c (evaluate_subexp_standard): Update call.
	* python/python-function.c: Include "language.h".
	(fnpy_call): Add GDBARCH and LANGAUAGE arguments and call
	make_cleanup_python_env.

	* python/python-value.c (builtin_type_pyint, builtin_type_pyfloat,
	builtin_type_pylong, builtin_type_pybool, builtin_type_pychar,
	valpy_str): Use python_gdbarch and python_language instead of
	current_gdbarch and current_language.
	* python/python-type.c (typy_lookup_typename): Likewise.
This commit is contained in:
Ulrich Weigand
2009-07-02 17:04:23 +00:00
parent e17c207e88
commit d452c4bcef
14 changed files with 179 additions and 97 deletions

View File

@ -19,6 +19,7 @@
#include "defs.h"
#include "arch-utils.h"
#include "value.h"
#include "exceptions.h"
#include "python-internal.h"
@ -26,6 +27,7 @@
#include "gdbcmd.h"
#include "cli/cli-decode.h"
#include "completer.h"
#include "language.h"
/* Struct representing built-in completion types. */
struct cmdpy_completer
@ -90,9 +92,9 @@ static void
cmdpy_destroyer (struct cmd_list_element *self, void *context)
{
cmdpy_object *cmd;
PyGILState_STATE state;
struct cleanup *cleanup;
state = PyGILState_Ensure ();
cleanup = ensure_python_env (get_current_arch (), current_language);
/* Release our hold on the command object. */
cmd = (cmdpy_object *) context;
@ -105,7 +107,7 @@ cmdpy_destroyer (struct cmd_list_element *self, void *context)
xfree (self->doc);
xfree (self->prefixname);
PyGILState_Release (state);
do_cleanups (cleanup);
}
/* Called by gdb to invoke the command. */
@ -115,10 +117,8 @@ cmdpy_function (struct cmd_list_element *command, char *args, int from_tty)
cmdpy_object *obj = (cmdpy_object *) get_cmd_context (command);
PyObject *argobj, *ttyobj, *result;
struct cleanup *cleanup;
PyGILState_STATE state;
state = PyGILState_Ensure ();
cleanup = make_cleanup_py_restore_gil (&state);
cleanup = ensure_python_env (get_current_arch (), current_language);
if (! obj)
error (_("Invalid invocation of Python command object."));
@ -182,10 +182,8 @@ cmdpy_completer (struct cmd_list_element *command, char *text, char *word)
PyObject *textobj, *wordobj, *resultobj = NULL;
char **result = NULL;
struct cleanup *cleanup;
PyGILState_STATE state;
state = PyGILState_Ensure ();
cleanup = make_cleanup_py_restore_gil (&state);
cleanup = ensure_python_env (get_current_arch (), current_language);
if (! obj)
error (_("Invalid invocation of Python command object."));