From: Tom Tromey <tom@tromey.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Use thread_info and inferior pointers more throughout
Date: Thu, 07 Jun 2018 18:28:00 -0000 [thread overview]
Message-ID: <87tvqeladc.fsf@tromey.com> (raw)
In-Reply-To: <20180607180704.3991-1-palves@redhat.com> (Pedro Alves's message of "Thu, 7 Jun 2018 19:07:04 +0100")
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
Pedro> In many cases though, we already have the thread_info or inferior
Pedro> pointer handy, but we "lose" it somewhere along the call stack, only
Pedro> to look it up again by ptid_t/pid. Since thread_info or inferior
Pedro> objects know their parent target, if we pass around thread_info or
Pedro> inferior pointers when possible, we avoid having to add extra
Pedro> target_ops parameters to many functions, and also, we eliminate a
Pedro> number of by ptid_t/int lookups.
This seems like a good idea. I've sometimes wondered why ptid was used
rather than object pointers; but now it seems that there was no deep
reason :)
Pedro> - Related, there's a spot where using a RAII object to handle the
Pedro> refcount would be handy, so a new scoped_inc_dec_ref class is added
Pedro> to common/refcounted-object.h.
It seems to me that this could be done via gdb::ref_ptr plus a simple
policy class that interfaces it to refcounted_object.
Pedro> +/* A RAII type that increments/decrements the refcount of an object on
Pedro> + enter/exit of a scope. */
Pedro> +
Pedro> +class scoped_inc_dec_ref
Pedro> +{
Pedro> +public:
Pedro> + explicit scoped_inc_dec_ref (refcounted_object *obj)
Pedro> + : m_obj (obj)
Pedro> + {
Pedro> + m_obj->incref ();
Pedro> + }
Pedro> +
Pedro> + ~scoped_inc_dec_ref ()
Pedro> + {
Pedro> + m_obj->decref ();
Pedro> + }
... if you do keep this it probably needs DISABLE_COPY_AND_ASSIGN.
Tom
next prev parent reply other threads:[~2018-06-07 18:28 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-07 18:07 Pedro Alves
2018-06-07 18:28 ` Tom Tromey [this message]
2018-06-21 15:57 ` Pedro Alves
2018-06-21 16:21 ` Pedro Alves
2018-06-25 10:18 ` Ulrich Weigand
2018-06-25 10:23 ` Pedro Alves
2018-06-27 11:34 ` Ulrich Weigand
2018-06-27 12:43 ` [PATCH] Fix Cell debugging regression (Re: [PATCH] Use thread_info and inferior pointers more throughout) Pedro Alves
2018-06-27 13:12 ` Ulrich Weigand
2018-06-27 13:17 ` Pedro Alves
2018-06-27 15:30 ` [PATCH v2] " Pedro Alves
2018-06-27 16:05 ` Ulrich Weigand
2018-06-27 16:25 ` Pedro Alves
2019-02-14 15:45 ` [PATCH] Use thread_info and inferior pointers more throughout Thomas Schwinge
2018-06-27 18:16 ` Possible regression on gdb.multi/multi-arch-exec.exp (was: Re: [PATCH] Use thread_info and inferior pointers more throughout) Sergio Durigan Junior
2018-06-27 18:39 ` Keith Seitz
2018-06-28 12:09 ` Possible regression on gdb.multi/multi-arch-exec.exp Pedro Alves
2018-06-28 16:02 ` [pushed] Fix follow-exec regression / crash (Re: Possible regression on gdb.multi/multi-arch-exec.exp) Pedro Alves
2018-06-28 16:37 ` Sergio Durigan Junior
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=87tvqeladc.fsf@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).