+2018-08-24 Pedro Alves <palves@redhat.com>
+
+ * python/py-bpevent.c (create_breakpoint_event_object): Use
+ copy-initialization.
+ * python/py-continueevent.c (emit_continue_event): Use
+ copy-initialization.
+ * python/py-exitedevent.c (create_exited_event_object): Return a
+ gdbpy_ref<>.
+ (emit_exited_event): Use copy-initialization.
+ * python/py-inferior.c (python_new_inferior)
+ (python_inferior_deleted, add_thread_object): Use
+ copy-initialization.
+ * python/py-infevents.c (create_inferior_call_event_object)
+ (create_register_changed_event_object)
+ (create_memory_changed_event_object): Return a gdbpy_ref<>.
+ (emit_inferior_call_event, emit_memory_changed_event)
+ (emit_register_changed_event): Use copy-initialization.
+ * python/py-newobjfileevent.c (create_new_objfile_event_object):
+ Return a gdbpy_ref<>.
+ (emit_new_objfile_event): Use copy-initialization.
+ (create_clear_objfiles_event_object): Return a gdbpy_ref<>.
+ (emit_clear_objfiles_event): Use copy-initialization.
+ * python/py-signalevent.c (create_signal_event_object): Use
+ copy-initialization.
+ * python/py-threadevent.c (create_thread_event_object): Use
+ copy-initialization.
+
2018-08-24 Pedro Alves <palves@redhat.com>
Simon Marchi <simon.marchi@ericsson.com>
create_breakpoint_event_object (PyObject *breakpoint_list, PyObject *first_bp)
{
gdbpy_ref<> breakpoint_event_obj
- (create_stop_event_object (&breakpoint_event_object_type));
+ = create_stop_event_object (&breakpoint_event_object_type);
if (breakpoint_event_obj == NULL)
return NULL;
if (evregpy_no_listeners_p (gdb_py_events.cont))
return 0;
- gdbpy_ref<> event (create_continue_event_object (ptid));
+ gdbpy_ref<> event = create_continue_event_object (ptid);
if (event != NULL)
return evpy_emit_event (event.get (), gdb_py_events.cont);
return -1;
#include "defs.h"
#include "py-event.h"
-static PyObject *
+static gdbpy_ref<>
create_exited_event_object (const LONGEST *exit_code, struct inferior *inf)
{
- gdbpy_ref<> exited_event (create_event_object (&exited_event_object_type));
+ gdbpy_ref<> exited_event = create_event_object (&exited_event_object_type);
if (exited_event == NULL)
return NULL;
(PyObject *) inf_obj.get ()) < 0)
return NULL;
- return exited_event.release ();
+ return exited_event;
}
/* Callback that is used when an exit event occurs. This function
if (evregpy_no_listeners_p (gdb_py_events.exited))
return 0;
- gdbpy_ref<> event (create_exited_event_object (exit_code, inf));
+ gdbpy_ref<> event = create_exited_event_object (exit_code, inf);
if (event != NULL)
return evpy_emit_event (event.get (), gdb_py_events.exited);
return;
}
- gdbpy_ref<> event (create_event_object (&new_inferior_event_object_type));
+ gdbpy_ref<> event = create_event_object (&new_inferior_event_object_type);
if (event == NULL
|| evpy_add_attribute (event.get (), "inferior",
(PyObject *) inf_obj.get ()) < 0
return;
}
- gdbpy_ref<> event (create_event_object (&inferior_deleted_event_object_type));
+ gdbpy_ref<> event = create_event_object (&inferior_deleted_event_object_type);
if (event == NULL
|| evpy_add_attribute (event.get (), "inferior",
(PyObject *) inf_obj.get ()) < 0
if (evregpy_no_listeners_p (gdb_py_events.new_thread))
return;
- gdbpy_ref<> event (create_thread_event_object (&new_thread_event_object_type,
- (PyObject *) thread_obj));
+ gdbpy_ref<> event = create_thread_event_object (&new_thread_event_object_type,
+ (PyObject *) thread_obj);
if (event == NULL
|| evpy_emit_event (event.get (), gdb_py_events.new_thread) < 0)
gdbpy_print_stack ();
/* Construct either a gdb.InferiorCallPreEvent or a
gdb.InferiorCallPostEvent. */
-static PyObject *
+static gdbpy_ref<>
create_inferior_call_event_object (inferior_call_kind flag, ptid_t ptid,
CORE_ADDR addr)
{
if (evpy_add_attribute (event.get (), "address", addr_obj.get ()) < 0)
return NULL;
- return event.release ();
+ return event;
}
/* Construct a gdb.RegisterChangedEvent containing the affected
register number. */
-static PyObject *
+static gdbpy_ref<>
create_register_changed_event_object (struct frame_info *frame,
int regnum)
{
- gdbpy_ref<> event (create_event_object (®ister_changed_event_object_type));
+ gdbpy_ref<> event = create_event_object (®ister_changed_event_object_type);
if (event == NULL)
return NULL;
if (evpy_add_attribute (event.get (), "regnum", regnum_obj.get ()) < 0)
return NULL;
- return event.release ();
+ return event;
}
/* Construct a gdb.MemoryChangedEvent describing the extent of the
affected memory. */
-static PyObject *
+static gdbpy_ref<>
create_memory_changed_event_object (CORE_ADDR addr, ssize_t len)
{
- gdbpy_ref<> event (create_event_object (&memory_changed_event_object_type));
+ gdbpy_ref<> event = create_event_object (&memory_changed_event_object_type);
if (event == NULL)
return NULL;
if (evpy_add_attribute (event.get (), "length", len_obj.get ()) < 0)
return NULL;
- return event.release ();
+ return event;
}
/* Callback function which notifies observers when an event occurs which
if (evregpy_no_listeners_p (gdb_py_events.inferior_call))
return 0;
- gdbpy_ref<> event (create_inferior_call_event_object (flag, thread, addr));
+ gdbpy_ref<> event = create_inferior_call_event_object (flag, thread, addr);
if (event != NULL)
return evpy_emit_event (event.get (), gdb_py_events.inferior_call);
return -1;
if (evregpy_no_listeners_p (gdb_py_events.memory_changed))
return 0;
- gdbpy_ref<> event (create_memory_changed_event_object (addr, len));
+ gdbpy_ref<> event = create_memory_changed_event_object (addr, len);
if (event != NULL)
return evpy_emit_event (event.get (), gdb_py_events.memory_changed);
return -1;
if (evregpy_no_listeners_p (gdb_py_events.register_changed))
return 0;
- gdbpy_ref<> event (create_register_changed_event_object (frame, regnum));
+ gdbpy_ref<> event = create_register_changed_event_object (frame, regnum);
if (event != NULL)
return evpy_emit_event (event.get (), gdb_py_events.register_changed);
return -1;
#include "defs.h"
#include "py-event.h"
-static PyObject *
+static gdbpy_ref<>
create_new_objfile_event_object (struct objfile *objfile)
{
- PyObject *py_objfile;
-
gdbpy_ref<> objfile_event
- (create_event_object (&new_objfile_event_object_type));
+ = create_event_object (&new_objfile_event_object_type);
if (objfile_event == NULL)
return NULL;
/* Note that objfile_to_objfile_object returns a borrowed reference,
so we don't need a decref here. */
- py_objfile = objfile_to_objfile_object (objfile);
+ PyObject *py_objfile = objfile_to_objfile_object (objfile);
if (!py_objfile || evpy_add_attribute (objfile_event.get (),
"new_objfile",
py_objfile) < 0)
return NULL;
- return objfile_event.release ();
+ return objfile_event;
}
/* Callback function which notifies observers when a new objfile event occurs.
if (evregpy_no_listeners_p (gdb_py_events.new_objfile))
return 0;
- gdbpy_ref<> event (create_new_objfile_event_object (objfile));
+ gdbpy_ref<> event = create_new_objfile_event_object (objfile);
if (event != NULL)
return evpy_emit_event (event.get (), gdb_py_events.new_objfile);
return -1;
\f
/* Subroutine of emit_clear_objfiles_event to simplify it. */
-static PyObject *
+static gdbpy_ref<>
create_clear_objfiles_event_object (void)
{
- PyObject *py_progspace;
-
gdbpy_ref<> objfile_event
- (create_event_object (&clear_objfiles_event_object_type));
+ = create_event_object (&clear_objfiles_event_object_type);
if (objfile_event == NULL)
return NULL;
/* Note that pspace_to_pspace_object returns a borrowed reference,
so we don't need a decref here. */
- py_progspace = pspace_to_pspace_object (current_program_space);
+ PyObject *py_progspace = pspace_to_pspace_object (current_program_space);
if (!py_progspace || evpy_add_attribute (objfile_event.get (),
"progspace",
py_progspace) < 0)
return NULL;
- return objfile_event.release ();
+ return objfile_event;
}
/* Callback function which notifies observers when the "clear objfiles"
if (evregpy_no_listeners_p (gdb_py_events.clear_objfiles))
return 0;
- gdbpy_ref<> event (create_clear_objfiles_event_object ());
+ gdbpy_ref<> event = create_clear_objfiles_event_object ();
if (event != NULL)
return evpy_emit_event (event.get (), gdb_py_events.clear_objfiles);
return -1;
gdbpy_ref<>
create_signal_event_object (enum gdb_signal stop_signal)
{
- const char *signal_name;
gdbpy_ref<> signal_event_obj
- (create_stop_event_object (&signal_event_object_type));
+ = create_stop_event_object (&signal_event_object_type);
if (signal_event_obj == NULL)
return NULL;
- signal_name = gdb_signal_to_name (stop_signal);
+ const char *signal_name = gdb_signal_to_name (stop_signal);
gdbpy_ref<> signal_name_obj (PyString_FromString (signal_name));
if (signal_name_obj == NULL)
{
gdb_assert (thread != NULL);
- gdbpy_ref<> thread_event_obj (create_event_object (py_type));
+ gdbpy_ref<> thread_event_obj = create_event_object (py_type);
if (thread_event_obj == NULL)
return NULL;