[PATCH v7] Events when inferior is modified
Doug Evans
dje@google.com
Fri Oct 17 20:00:00 GMT 2014
Doug Evans writes:
> [...]
> Alas our use of thread ids is a bit, umm, confusing
> (in more ways than one! :-().
> Here, it's not guaranteed that ptid.lwp has something useful,
> and it may be that the target uses ptid.tid instead.
>
> See python/py-infthread.c:thpy_get_ptid.
> I think we should make that non-static and use that here.
Well, more specifically, split it into two and export a routine
that builds a python ptid tuple from a ptid_t.
> IOW, pass the whole ptid_t to the event.
>
> > + if (tid_obj == NULL)
> > + goto fail;
> > + make_cleanup_py_decref (tid_obj);
> > +
> > + failed = evpy_add_attribute (event, "tid", tid_obj) < 0;
> > + if (failed)
> > + goto fail;
> > +
> > + addr_obj = PyLong_FromLongLong (addr);
> > + if (addr_obj == NULL)
> > + goto fail;
> > + make_cleanup_py_decref (addr_obj);
> > +
> > + failed = evpy_add_attribute (event, "address", addr_obj) < 0;
> > + if (failed)
> > + goto fail;
> > +
>
> Run the cleanups here as well as for the fail case.
Well, more specifically (bleah) ...
E.g., the addr_obj attribute will have two references when we return
here. We want it to only have one: when the event goes away
we want addr_obj to go away too.
Obviously we don't want to decref the event object itself.
This applies to my other "Run the cleanups ..." comments below.
>
> > + return event;
> > +
> > + fail:
> > + do_cleanups (cleanups);
> > + return NULL;
> > +}
> > +
> > +/* Construct a gdb.RegisterChangedEvent containing the affected
> > + register number. */
> > +
> > +static PyObject *
> > +create_register_changed_event_object (struct frame_info *frame,
> > + short regnum)
> > +{
> > + PyObject * event;
> > + PyObject *frame_obj = NULL;
> > + PyObject *regnum_obj = NULL;
> > + int failed;
> > + struct cleanup *cleanups;
> > +
> > + event = create_event_object (®ister_changed_event_object_type);
> > + if (event == NULL)
> > + return NULL;
> > +
> > + cleanups = make_cleanup_py_decref (event);
> > +
> > + frame_obj = frame_info_to_frame_object (frame);
> > + if (frame_obj == NULL)
> > + goto fail;
> > + make_cleanup_py_decref (frame_obj);
> > +
> > + failed = evpy_add_attribute (event, "frame", frame_obj) < 0;
> > + if (failed)
> > + goto fail;
> > +
> > + regnum_obj = PyLong_FromLongLong (regnum);
> > + if (regnum_obj == NULL)
> > + goto fail;
> > + make_cleanup_py_decref (regnum_obj);
> > +
> > + failed = evpy_add_attribute (event, "regnum", regnum_obj) < 0;
> > + if (failed)
> > + goto fail;
> > +
>
> Run the cleanups here as well as for the fail case.
>
> > + return event;
> > +
> > + fail:
> > + do_cleanups (cleanups);
> > + return NULL;
> > +}
> > +
> > +/* Construct a gdb.MemoryChangedEvent describing the extent of the
> > + affected memory. */
> > +
> > +static PyObject *
> > +create_memory_changed_event_object (CORE_ADDR addr, ssize_t len)
> > +{
> > + PyObject * event;
> > + PyObject *addr_obj = NULL;
> > + PyObject *len_obj = NULL;
> > + int failed;
> > + struct cleanup *cleanups;
> > +
> > + event = create_event_object (&memory_changed_event_object_type);
> > +
> > + if (event == NULL)
> > + return NULL;
> > + cleanups = make_cleanup_py_decref (event);
> > +
> > + addr_obj = PyLong_FromLongLong (addr);
> > + if (addr_obj == NULL)
> > + goto fail;
> > + make_cleanup_py_decref (addr_obj);
> > +
> > + failed = evpy_add_attribute (event, "address", addr_obj) < 0;
> > + if (failed)
> > + goto fail;
> > +
> > + len_obj = PyLong_FromLong (len);
> > + if (len_obj == NULL)
> > + goto fail;
> > + make_cleanup_py_decref (len_obj);
> > +
> > + failed = evpy_add_attribute (event, "length", len_obj) < 0;
> > + if (failed)
> > + goto fail;
> > +
>
> Run the cleanups here as well as for the fail case.
>
> > + return event;
> > +
> > + fail:
> > + do_cleanups (cleanups);
> > + return NULL;
> > +}
> > +
> [...]
More information about the Gdb-patches
mailing list