From: Pedro Alves <palves@redhat.com>
To: lgustavo@codesourcery.com
Cc: Joel Brobecker <brobecker@adacore.com>,
"'gdb-patches@sourceware.org'"
<gdb-patches@sourceware.org>
Subject: Re: [PATCH, cleanup] Standardize access to ptid
Date: Sun, 29 Sep 2013 18:45:00 -0000 [thread overview]
Message-ID: <52487534.3000609@redhat.com> (raw)
In-Reply-To: <5248607C.6030909@codesourcery.com>
On 09/29/2013 06:16 PM, Luis Machado wrote:
>>> @@ -33,6 +33,10 @@
>>> ptid_get_lwp - Fetch the lwp component of a ptid.
>>> ptid_get_tid - Fetch the tid component of a ptid.
>>> ptid_equal - Test to see if two ptids are equal.
>>> + ptid_is_pid - Test if a ptid's pid component is non-zero.
>>
>> No, that's not right:
>>
>> /* Returns true if PTID represents a process. */
>>
>> int
>> ptid_is_pid (ptid_t ptid)
>> {
>> if (ptid_equal (minus_one_ptid, ptid))
>> return 0;
>> if (ptid_equal (null_ptid, ptid))
>> return 0;
>>
>> return (ptid_get_lwp (ptid) == 0 && ptid_get_tid (ptid) == 0);
>> }
>>
>> So this only returns true iff the ptid looks like (pid,0,0).
>> (ptid_is_pid on (pid,lwp,0) returns false, for example.)
>> This is considered a ptid that identifies the whole PID process (the
>> whole thread group in Linux speak). Both the core and the targets
>> use and agree on this.
>
> I've changed the description to the following:
>
> "Test if a ptid looks like (pid, 0, 0)."
>
> Seems to clearly state what is being checked.
Sounds fine, thanks.
>> ...
> All of this makes sense to me, but perhaps we should introduce such a
> change later on? After the cleanup possibly, since this will require
> changes in places of the code that deal with various subsystems of GDB.
Yes, I was just doing a brain dump. I'm not suggesting to actually
do it now. And certainly not ever as part of this patch.
>> With that in mind, I think I'd prefer renaming these
>> new "is" functions as:
>>
>> ptid_is_lwp -> ptid_lwp_p
>> ptid_is_tid -> ptid_tid_p
>>
>> (or at least ptid_has_lwp, though the _p variant has
>> precedent in the frame stuff, and it feels to me that frame_ids
>> and ptids are at about the same conceptual level.)
>
> I'm happy with ptid_lwp_p and ptid_tid_p.
Thanks.
>> And I'm also don't really like the "ptid_is_invalid" function that much.
>> minus_one_ptid or null_ptid aren't really always invalid. They have
>> special meanings as either invalid, terminator, or as wildcard depending
>> on context. See e.g, how frame_id_p returns true to wildcard frame ids,
>> and the special outer_frame_id (although that one should die.
>> But with the above suggestion, I don't think the function
>> would end up with any use left, so it could just be dropped. But I suppose
>> I'll just get used to it if it stays. ;-) But, if it stays, please,
>> please, invert its logic, getting rid of the double
>> negative ("if (!ptid_is_invalid ()").
>
> I thought about ptid_special_p or ptid_is_special to check for both
Yeah, good one. I would have liked that naming more.
> null_ptid and minus_one_ptid, but this check would only be used (for now
> at least) in the ptid.c file. Maybe not worth the effort, so i left it out.
Yeah.
I only skimmed most of the new patch, focused mostly on ptid.c/ptid.h, and
on the places is_lwp / is_thread used to be used, and, I'm fine with this
version. Thanks a lot!
--
Pedro Alves
next prev parent reply other threads:[~2013-09-29 18:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-19 22:28 Luis Machado
2013-09-25 0:51 ` Luis Machado
2013-09-26 12:53 ` Joel Brobecker
2013-09-26 12:58 ` Luis Machado
2013-09-26 15:10 ` Pedro Alves
2013-09-29 17:17 ` Luis Machado
2013-09-29 18:45 ` Pedro Alves [this message]
2013-09-30 11:50 ` Luis Machado
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=52487534.3000609@redhat.com \
--to=palves@redhat.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=lgustavo@codesourcery.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