Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Doug Evans <dje@google.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] fix ref counting of inferior_to_inferior_object
Date: Mon, 23 Sep 2013 20:41:00 -0000	[thread overview]
Message-ID: <87hadbmfsr.fsf@fleche.redhat.com> (raw)
In-Reply-To: <yjt2zjrhekva.fsf@ruffy.mtv.corp.google.com> (Doug Evans's	message of "Thu, 12 Sep 2013 15:27:37 -0700")

>>>>> "Doug" == Doug Evans <dje@google.com> writes:

Doug> While adding an inferior attribute to the newobjfile event,
Doug> I noticed inferior_to_inferior_object sometimes returns (AFAICT)
Doug> a new reference and sometimes returns a borrowed reference.

The current code is maybe weird but I think it isn't incorrect.  That
said it is fine to change it as well.

The current model is that the Python object mirroring the inferior
clears the inferior->Python mapping when it is finally destroyed.
If the Python code then requests the Python object for that inferior
again, a new object is created.  This is "ok" because the Inferior
object doesn't carry any user state.

Doug>  /* Return a reference to the Python object of type Inferior
Doug>     representing INFERIOR.  If the object has already been created,
Doug> -   return it and increment the reference count,  otherwise, create it.
Doug> +   return it,  otherwise create it.  The result is a borrowed reference.
Doug>     Return NULL on failure.  */

This change requires a CPYCHECKER_RETURNS_BORROWED_REF annotation on the
declaration of inferior_to_inferior_object.

Tom


  reply	other threads:[~2013-09-23 20:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-12 22:27 Doug Evans
2013-09-23 20:41 ` Tom Tromey [this message]
2013-09-25 18:18   ` Doug Evans
2013-09-25 18:32     ` Tom Tromey
2013-09-25 19:29       ` Doug Evans
2013-09-25 20:11         ` Tom Tromey
2013-09-25 21:11           ` 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=87hadbmfsr.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    /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