Use gdbpy_ref to simplify some logic
This uses the new gdbpy_ref template to simplify logic in various parts of the Python layer; for example removing repeated error code or removing gotos. gdb/ChangeLog 2017-02-10 Tom Tromey <tom@tromey.com> * python/py-cmd.c (cmdpy_destroyer): Use gdbpy_ref. * python/py-breakpoint.c (gdbpy_breakpoint_deleted): Use gdbpy_ref. * python/py-type.c (field_new): Use gdbpy_ref. * python/py-symtab.c (symtab_and_line_to_sal_object): Use gdbpy_ref. * python/py-progspace.c (pspy_new): Use gdbpy_ref. (py_free_pspace): Likewise. (pspace_to_pspace_object): Likewise. * python/py-objfile.c (objfpy_new): Use gdbpy_ref. (py_free_objfile): Likewise. (objfile_to_objfile_object): Likewise. * python/py-inferior.c (delete_thread_object): Use gdbpy_ref. (infpy_read_memory): Likewise. (py_free_inferior): Likewise. * python/py-evtregistry.c (create_eventregistry_object): Use gdbpy_ref. * python/py-event.c (create_event_object): Use gdbpy_ref.
This commit is contained in:
parent
7780f18678
commit
88b6faea99
11 changed files with 94 additions and 116 deletions
|
@ -911,25 +911,23 @@ gdbpy_breakpoint_deleted (struct breakpoint *b)
|
|||
int num = b->number;
|
||||
PyGILState_STATE state;
|
||||
struct breakpoint *bp = NULL;
|
||||
gdbpy_breakpoint_object *bp_obj;
|
||||
|
||||
state = PyGILState_Ensure ();
|
||||
bp = get_breakpoint (num);
|
||||
if (bp)
|
||||
{
|
||||
bp_obj = bp->py_bp_object;
|
||||
if (bp_obj)
|
||||
gdbpy_ref<gdbpy_breakpoint_object> bp_obj (bp->py_bp_object);
|
||||
if (bp_obj != NULL)
|
||||
{
|
||||
if (!evregpy_no_listeners_p (gdb_py_events.breakpoint_deleted))
|
||||
{
|
||||
if (evpy_emit_event ((PyObject *) bp_obj,
|
||||
if (evpy_emit_event ((PyObject *) bp_obj.get (),
|
||||
gdb_py_events.breakpoint_deleted) < 0)
|
||||
gdbpy_print_stack ();
|
||||
}
|
||||
|
||||
bp_obj->bp = NULL;
|
||||
--bppy_live;
|
||||
Py_DECREF (bp_obj);
|
||||
}
|
||||
}
|
||||
PyGILState_Release (state);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue