From: Doug Evans <dje@google.com>
To: Nick Bull <nicholaspbull@gmail.com>
Cc: Pedro Alves <palves@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v7] Events when inferior is modified
Date: Fri, 17 Oct 2014 20:00:00 -0000 [thread overview]
Message-ID: <21569.30068.738159.240720@ruffy.mtv.corp.google.com> (raw)
In-Reply-To: <21569.29405.219428.940000@ruffy.mtv.corp.google.com>
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;
> > +}
> > +
> [...]
next prev parent reply other threads:[~2014-10-17 20:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-17 17:32 [PATCH v6] " Nick Bull
2014-09-24 14:05 ` Robert O'Callahan
2014-09-25 10:14 ` Phil Muldoon
2014-10-01 9:50 ` Nick Bull
2014-10-01 17:52 ` Pedro Alves
2014-10-17 16:26 ` [PATCH v7] " Nick Bull
2014-10-17 19:49 ` Doug Evans
2014-10-17 20:00 ` Doug Evans [this message]
2014-10-22 12:40 ` [PATCH v8] " Nick Bull
2014-11-17 18:13 ` Nick Bull
2014-11-17 21:25 ` Doug Evans
2014-11-18 16:37 ` Nick Bull
2014-11-20 0:21 ` Doug Evans
2014-11-20 10:36 ` Nick Bull
2014-12-02 19:20 ` Doug Evans
2014-12-04 10:45 ` Nick Bull
2014-12-15 8:33 ` Yao Qi
2014-10-24 15:14 ` [PATCH v7] " Pedro Alves
2014-11-06 18:19 ` Doug Evans
2014-11-07 12:21 ` Pedro Alves
2014-11-07 17:04 ` Doug Evans
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=21569.30068.738159.240720@ruffy.mtv.corp.google.com \
--to=dje@google.com \
--cc=gdb-patches@sourceware.org \
--cc=nicholaspbull@gmail.com \
--cc=palves@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox