Use gdbpy_enter in py-xmethods.c
authorTom Tromey <tom@tromey.com>
Mon, 7 Nov 2016 23:13:40 +0000 (16:13 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 11 Jan 2017 02:13:44 +0000 (19:13 -0700)
Change the simple parts of py-xmethods.c to use gdbpy_enter.

2017-01-10  Tom Tromey  <tom@tromey.com>

* python/py-xmethods.c (gdbpy_free_xmethod_worker_data)
(gdbpy_clone_xmethod_worker_data): Use gdbpy_enter.

gdb/ChangeLog
gdb/python/py-xmethods.c

index 28b599b0dcf4d623c418aa0b0171d0803320405e..344452b2c4f4cf8fd36534c71f0601b60ad57e6f 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-10  Tom Tromey  <tom@tromey.com>
+
+       * python/py-xmethods.c (gdbpy_free_xmethod_worker_data)
+       (gdbpy_clone_xmethod_worker_data): Use gdbpy_enter.
+
 2017-01-10  Tom Tromey  <tom@tromey.com>
 
        * python/py-type.c (save_objfile_types): Use gdbpy_enter.
index f4947abc4a9df990ebf60a9e6a34785200832d65..eab69a03d7a00255787cde2ada8f4a00905a458e 100644 (file)
@@ -52,18 +52,15 @@ gdbpy_free_xmethod_worker_data (const struct extension_language_defn *extlang,
                                void *data)
 {
   struct gdbpy_worker_data *worker_data = (struct gdbpy_worker_data *) data;
-  struct cleanup *cleanups;
 
   gdb_assert (worker_data->worker != NULL && worker_data->this_type != NULL);
 
   /* We don't do much here, but we still need the GIL.  */
-  cleanups = ensure_python_env (get_current_arch (), current_language);
+  gdbpy_enter enter_py (get_current_arch (), current_language);
 
   Py_DECREF (worker_data->worker);
   Py_DECREF (worker_data->this_type);
   xfree (worker_data);
-
-  do_cleanups (cleanups);
 }
 
 /* Implementation of clone_xmethod_worker_data for Python.  */
@@ -74,12 +71,11 @@ gdbpy_clone_xmethod_worker_data (const struct extension_language_defn *extlang,
 {
   struct gdbpy_worker_data *worker_data
     = (struct gdbpy_worker_data *) data, *new_data;
-  struct cleanup *cleanups;
 
   gdb_assert (worker_data->worker != NULL && worker_data->this_type != NULL);
 
   /* We don't do much here, but we still need the GIL.  */
-  cleanups = ensure_python_env (get_current_arch (), current_language);
+  gdbpy_enter enter_py (get_current_arch (), current_language);
 
   new_data = XCNEW (struct gdbpy_worker_data);
   new_data->worker = worker_data->worker;
@@ -87,8 +83,6 @@ gdbpy_clone_xmethod_worker_data (const struct extension_language_defn *extlang,
   Py_INCREF (new_data->worker);
   Py_INCREF (new_data->this_type);
 
-  do_cleanups (cleanups);
-
   return new_data;
 }