diff options
author | Tom Tromey <tom@tromey.com> | 2017-09-08 14:26:43 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-09-11 14:15:21 -0600 |
commit | 35c61a1dd5462ceab42618c48c9a60238245761b (patch) | |
tree | d74d1822708779e9d19ed23b5b2bc6c5917289e2 /gdb/python | |
parent | 7c96f8c1dae023c7d0b1cabc5e50c4d18fd06960 (diff) | |
download | gdb-35c61a1dd5462ceab42618c48c9a60238245761b.zip gdb-35c61a1dd5462ceab42618c48c9a60238245761b.tar.gz gdb-35c61a1dd5462ceab42618c48c9a60238245761b.tar.bz2 |
Small event ownership clean up in Python layer
It seems cleaner to me for functions like create_thread_event_object,
which pass object ownership to their callers, to directly return a
gdb_ref<>. This way the ownership transfer is part of the API. This
patch makes this change.
ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>
* python/py-threadevent.c (create_thread_event_object): Return
gdbpy_ref.
* python/py-stopevent.h (create_stop_event_object)
(create_breakpoint_event_object, create_signal_event_object):
Update.
* python/py-stopevent.c (create_stop_event_object): Return
gdbpy_ref.
(emit_stop_event): Update.
* python/py-signalevent.c (create_signal_event_object): Return
gdbpy_ref.
* python/py-infevents.c (create_inferior_call_event_object):
Update.
* python/py-event.h (create_event_object)
(create_thread_event_object): Update.
* python/py-event.c (create_event_object): Return gdbpy_ref.
* python/py-continueevent.c: Return gdbpy_ref.
* python/py-bpevent.c (create_breakpoint_event_object): Return
gdbpy_ref.
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/py-bpevent.c | 4 | ||||
-rw-r--r-- | gdb/python/py-continueevent.c | 2 | ||||
-rw-r--r-- | gdb/python/py-event.c | 4 | ||||
-rw-r--r-- | gdb/python/py-event.h | 6 | ||||
-rw-r--r-- | gdb/python/py-infevents.c | 4 | ||||
-rw-r--r-- | gdb/python/py-signalevent.c | 4 | ||||
-rw-r--r-- | gdb/python/py-stopevent.c | 10 | ||||
-rw-r--r-- | gdb/python/py-stopevent.h | 8 | ||||
-rw-r--r-- | gdb/python/py-threadevent.c | 4 |
9 files changed, 23 insertions, 23 deletions
diff --git a/gdb/python/py-bpevent.c b/gdb/python/py-bpevent.c index c5a85b6..021c83a 100644 --- a/gdb/python/py-bpevent.c +++ b/gdb/python/py-bpevent.c @@ -27,7 +27,7 @@ extern PyTypeObject breakpoint_event_object_type /* Create and initialize a BreakpointEvent object. This acquires new references to BREAKPOINT_LIST and FIRST_BP. */ -PyObject * +gdbpy_ref<> create_breakpoint_event_object (PyObject *breakpoint_list, PyObject *first_bp) { gdbpy_ref<> breakpoint_event_obj @@ -45,7 +45,7 @@ create_breakpoint_event_object (PyObject *breakpoint_list, PyObject *first_bp) breakpoint_list) < 0) return NULL; - return breakpoint_event_obj.release (); + return breakpoint_event_obj; } GDBPY_NEW_EVENT_TYPE (breakpoint, diff --git a/gdb/python/py-continueevent.c b/gdb/python/py-continueevent.c index 8be28c2..ca2927f 100644 --- a/gdb/python/py-continueevent.c +++ b/gdb/python/py-continueevent.c @@ -24,7 +24,7 @@ extern PyTypeObject continue_event_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object"); -static PyObject * +static gdbpy_ref<> create_continue_event_object (void) { return create_thread_event_object (&continue_event_object_type); diff --git a/gdb/python/py-event.c b/gdb/python/py-event.c index b349891..9d84e33 100644 --- a/gdb/python/py-event.c +++ b/gdb/python/py-event.c @@ -27,7 +27,7 @@ evpy_dealloc (PyObject *self) Py_TYPE (self)->tp_free (self); } -PyObject * +gdbpy_ref<> create_event_object (PyTypeObject *py_type) { gdbpy_ref<event_object> event_obj (PyObject_New (event_object, py_type)); @@ -38,7 +38,7 @@ create_event_object (PyTypeObject *py_type) if (!event_obj->dict) return NULL; - return (PyObject*) event_obj.release (); + return gdbpy_ref<> ((PyObject *) event_obj.release ()); } /* Add the attribute ATTR to the event object EVENT. In diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h index 2f02c5f..27db828 100644 --- a/gdb/python/py-event.h +++ b/gdb/python/py-event.h @@ -124,9 +124,9 @@ extern int emit_memory_changed_event (CORE_ADDR addr, ssize_t len); extern int evpy_emit_event (PyObject *event, eventregistry_object *registry); -extern PyObject *create_event_object (PyTypeObject *py_type); -extern PyObject *create_thread_event_object (PyTypeObject *py_type, - PyObject *thread = nullptr); +extern gdbpy_ref<> create_event_object (PyTypeObject *py_type); +extern gdbpy_ref<> create_thread_event_object (PyTypeObject *py_type, + PyObject *thread = nullptr); extern int emit_new_objfile_event (struct objfile *objfile); extern int emit_clear_objfiles_event (void); diff --git a/gdb/python/py-infevents.c b/gdb/python/py-infevents.c index 6e3c8c8..8a63b79 100644 --- a/gdb/python/py-infevents.c +++ b/gdb/python/py-infevents.c @@ -43,10 +43,10 @@ create_inferior_call_event_object (inferior_call_kind flag, ptid_t ptid, switch (flag) { case INFERIOR_CALL_PRE: - event.reset (create_event_object (&inferior_call_pre_event_object_type)); + event = create_event_object (&inferior_call_pre_event_object_type); break; case INFERIOR_CALL_POST: - event.reset (create_event_object (&inferior_call_post_event_object_type)); + event = create_event_object (&inferior_call_post_event_object_type); break; default: gdb_assert_not_reached ("invalid inferior_call_kind"); diff --git a/gdb/python/py-signalevent.c b/gdb/python/py-signalevent.c index a8f41c2..c2391de 100644 --- a/gdb/python/py-signalevent.c +++ b/gdb/python/py-signalevent.c @@ -23,7 +23,7 @@ extern PyTypeObject signal_event_object_type CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("event_object"); -PyObject * +gdbpy_ref<> create_signal_event_object (enum gdb_signal stop_signal) { const char *signal_name; @@ -43,7 +43,7 @@ create_signal_event_object (enum gdb_signal stop_signal) signal_name_obj.get ()) < 0) return NULL; - return signal_event_obj.release (); + return signal_event_obj; } GDBPY_NEW_EVENT_TYPE (signal, diff --git a/gdb/python/py-stopevent.c b/gdb/python/py-stopevent.c index cfa4591..a0be5f2 100644 --- a/gdb/python/py-stopevent.c +++ b/gdb/python/py-stopevent.c @@ -20,7 +20,7 @@ #include "defs.h" #include "py-stopevent.h" -PyObject * +gdbpy_ref<> create_stop_event_object (PyTypeObject *py_type) { return create_thread_event_object (py_type); @@ -70,8 +70,8 @@ emit_stop_event (struct bpstats *bs, enum gdb_signal stop_signal) if (list != NULL) { - stop_event_obj.reset (create_breakpoint_event_object (list.get (), - first_bp)); + stop_event_obj = create_breakpoint_event_object (list.get (), + first_bp); if (stop_event_obj == NULL) return -1; } @@ -80,7 +80,7 @@ emit_stop_event (struct bpstats *bs, enum gdb_signal stop_signal) if (stop_signal != GDB_SIGNAL_0 && stop_signal != GDB_SIGNAL_TRAP) { - stop_event_obj.reset (create_signal_event_object (stop_signal)); + stop_event_obj = create_signal_event_object (stop_signal); if (stop_event_obj == NULL) return -1; } @@ -89,7 +89,7 @@ emit_stop_event (struct bpstats *bs, enum gdb_signal stop_signal) be known and this should eventually be unused. */ if (stop_event_obj == NULL) { - stop_event_obj.reset (create_stop_event_object (&stop_event_object_type)); + stop_event_obj = create_stop_event_object (&stop_event_object_type); if (stop_event_obj == NULL) return -1; } diff --git a/gdb/python/py-stopevent.h b/gdb/python/py-stopevent.h index a56ca7e..62c52d7 100644 --- a/gdb/python/py-stopevent.h +++ b/gdb/python/py-stopevent.h @@ -22,15 +22,15 @@ #include "py-event.h" -extern PyObject *create_stop_event_object (PyTypeObject *py_type); +extern gdbpy_ref<> create_stop_event_object (PyTypeObject *py_type); extern void stop_evpy_dealloc (PyObject *self); extern int emit_stop_event (struct bpstats *bs, enum gdb_signal stop_signal); -extern PyObject *create_breakpoint_event_object (PyObject *breakpoint_list, - PyObject *first_bp); +extern gdbpy_ref<> create_breakpoint_event_object (PyObject *breakpoint_list, + PyObject *first_bp); -extern PyObject *create_signal_event_object (enum gdb_signal stop_signal); +extern gdbpy_ref<> create_signal_event_object (enum gdb_signal stop_signal); #endif /* GDB_PY_STOPEVENT_H */ diff --git a/gdb/python/py-threadevent.c b/gdb/python/py-threadevent.c index 7211fa2..8b742ca 100644 --- a/gdb/python/py-threadevent.c +++ b/gdb/python/py-threadevent.c @@ -47,7 +47,7 @@ get_event_thread (void) return thread; } -PyObject * +gdbpy_ref<> create_thread_event_object (PyTypeObject *py_type, PyObject *thread) { gdbpy_ref<> thread_event_obj (create_event_object (py_type)); @@ -66,7 +66,7 @@ create_thread_event_object (PyTypeObject *py_type, PyObject *thread) thread) < 0) return NULL; - return thread_event_obj.release (); + return thread_event_obj; } GDBPY_NEW_EVENT_TYPE (thread, |