aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-function.c11
-rw-r--r--gdb/python/py-xmethods.c5
2 files changed, 8 insertions, 8 deletions
diff --git a/gdb/python/py-function.c b/gdb/python/py-function.c
index 13c7a11..6762a6d 100644
--- a/gdb/python/py-function.c
+++ b/gdb/python/py-function.c
@@ -59,14 +59,13 @@ static struct value *
fnpy_call (struct gdbarch *gdbarch, const struct language_defn *language,
void *cookie, int argc, struct value **argv)
{
- struct value *value = NULL;
- /* 'result' must be set to NULL, this initially indicates whether
- the function was called, or not. */
- gdbpy_ref result;
-
+ /* The gdbpy_enter object needs to be placed first, so that it's the last to
+ be destroyed. */
gdbpy_enter enter_py (gdbarch, language);
-
+ struct value *value;
+ gdbpy_ref result;
gdbpy_ref args (convert_values_to_python (argc, argv));
+
/* convert_values_to_python can return NULL on error. If we
encounter this, do not call the function, but allow the Python ->
error code conversion below to deal with the Python exception.
diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c
index c3ca75a..6505d06 100644
--- a/gdb/python/py-xmethods.c
+++ b/gdb/python/py-xmethods.c
@@ -308,6 +308,9 @@ gdbpy_get_xmethod_arg_types (const struct extension_language_defn *extlang,
struct xmethod_worker *worker,
int *nargs, struct type ***arg_types)
{
+ /* The gdbpy_enter object needs to be placed first, so that it's the last to
+ be destroyed. */
+ gdbpy_enter enter_py (get_current_arch (), current_language);
struct gdbpy_worker_data *worker_data
= (struct gdbpy_worker_data *) worker->data;
PyObject *py_worker = worker_data->worker;
@@ -319,8 +322,6 @@ gdbpy_get_xmethod_arg_types (const struct extension_language_defn *extlang,
an invalid/unusable number of arg types. */
*nargs = -1;
- gdbpy_enter enter_py (get_current_arch (), current_language);
-
gdbpy_ref get_arg_types_method
(PyObject_GetAttrString (py_worker, get_arg_types_method_name));
if (get_arg_types_method == NULL)