aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog27
-rw-r--r--gdb/python/py-bpevent.c2
-rw-r--r--gdb/python/py-continueevent.c2
-rw-r--r--gdb/python/py-exitedevent.c8
-rw-r--r--gdb/python/py-inferior.c8
-rw-r--r--gdb/python/py-infevents.c22
-rw-r--r--gdb/python/py-newobjfileevent.c24
-rw-r--r--gdb/python/py-signalevent.c5
-rw-r--r--gdb/python/py-threadevent.c2
9 files changed, 61 insertions, 39 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e1bdd39..12dda6c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,4 +1,31 @@
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>
PR gdb/23379
diff --git a/gdb/python/py-bpevent.c b/gdb/python/py-bpevent.c
index 03863e4..f6f3c4c 100644
--- a/gdb/python/py-bpevent.c
+++ b/gdb/python/py-bpevent.c
@@ -28,7 +28,7 @@ gdbpy_ref<>
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;
diff --git a/gdb/python/py-continueevent.c b/gdb/python/py-continueevent.c
index b047a83..759b483 100644
--- a/gdb/python/py-continueevent.c
+++ b/gdb/python/py-continueevent.c
@@ -50,7 +50,7 @@ emit_continue_event (ptid_t ptid)
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;
diff --git a/gdb/python/py-exitedevent.c b/gdb/python/py-exitedevent.c
index 6a7c9f5..22c095c 100644
--- a/gdb/python/py-exitedevent.c
+++ b/gdb/python/py-exitedevent.c
@@ -20,10 +20,10 @@
#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;
@@ -45,7 +45,7 @@ create_exited_event_object (const LONGEST *exit_code, struct inferior *inf)
(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
@@ -57,7 +57,7 @@ emit_exited_event (const LONGEST *exit_code, struct inferior *inf)
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);
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 9f09ae9..1cf3729 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -256,7 +256,7 @@ python_new_inferior (struct inferior *inf)
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
@@ -284,7 +284,7 @@ python_inferior_deleted (struct inferior *inf)
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
@@ -353,8 +353,8 @@ add_thread_object (struct thread_info *tp)
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 ();
diff --git a/gdb/python/py-infevents.c b/gdb/python/py-infevents.c
index 2bd0bc7..0df7d96 100644
--- a/gdb/python/py-infevents.c
+++ b/gdb/python/py-infevents.c
@@ -24,7 +24,7 @@
/* 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)
{
@@ -56,17 +56,17 @@ create_inferior_call_event_object (inferior_call_kind flag, ptid_t ptid,
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 (&register_changed_event_object_type));
+ gdbpy_ref<> event = create_event_object (&register_changed_event_object_type);
if (event == NULL)
return NULL;
@@ -84,16 +84,16 @@ create_register_changed_event_object (struct frame_info *frame,
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;
@@ -112,7 +112,7 @@ create_memory_changed_event_object (CORE_ADDR addr, ssize_t len)
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
@@ -127,7 +127,7 @@ emit_inferior_call_event (inferior_call_kind flag, ptid_t thread,
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;
@@ -142,7 +142,7 @@ emit_memory_changed_event (CORE_ADDR addr, ssize_t len)
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;
@@ -157,7 +157,7 @@ emit_register_changed_event (struct frame_info* frame, int regnum)
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;
diff --git a/gdb/python/py-newobjfileevent.c b/gdb/python/py-newobjfileevent.c
index 86de9ac..a9341a3 100644
--- a/gdb/python/py-newobjfileevent.c
+++ b/gdb/python/py-newobjfileevent.c
@@ -20,25 +20,23 @@
#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.
@@ -51,7 +49,7 @@ emit_new_objfile_event (struct objfile *objfile)
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;
@@ -60,25 +58,23 @@ emit_new_objfile_event (struct objfile *objfile)
/* 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"
@@ -92,7 +88,7 @@ emit_clear_objfiles_event (void)
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;
diff --git a/gdb/python/py-signalevent.c b/gdb/python/py-signalevent.c
index d88aaea..a2e7519 100644
--- a/gdb/python/py-signalevent.c
+++ b/gdb/python/py-signalevent.c
@@ -23,14 +23,13 @@
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)
diff --git a/gdb/python/py-threadevent.c b/gdb/python/py-threadevent.c
index 1bc2fb0..a78f0a3 100644
--- a/gdb/python/py-threadevent.c
+++ b/gdb/python/py-threadevent.c
@@ -50,7 +50,7 @@ create_thread_event_object (PyTypeObject *py_type, PyObject *thread)
{
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;