public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: Luis Machado <luis.machado@linaro.org>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix printing of non pointer types when memory tagging is enabled
Date: Fri, 28 May 2021 15:11:36 -0700	[thread overview]
Message-ID: <e9a8b41d-ad0a-a3c9-0355-597fcf5d8883@FreeBSD.org> (raw)
In-Reply-To: <6f18950b-04be-45ef-4a40-a52512485044@linaro.org>

On 5/28/21 12:18 PM, Luis Machado wrote:
> On 5/28/21 4:08 PM, John Baldwin wrote:
>> On 5/18/21 1:20 PM, Luis Machado via Gdb-patches wrote:
>>> When the architecture supports memory tagging, we handle pointer types
>>> in a special way, so we can validate tags and show mismatches.
>>> @@ -1266,18 +1266,22 @@ print_value (value *val, const
>>> value_print_options &opts)
>>>    static bool
>>>    should_validate_memtags (struct value *value)
>>>    {
>>> -  if (target_supports_memory_tagging ()
>>> -      && gdbarch_tagged_address_p (target_gdbarch (), value))
>>> -    {
>>> -      gdb_assert (value != nullptr && value_type (value) != nullptr);
>>> +  gdb_assert (value != nullptr && value_type (value) != nullptr);
>>> -      enum type_code code = value_type (value)->code ();
>>> +  enum type_code code = value_type (value)->code ();
>>> -      return (code == TYPE_CODE_PTR
>>> -          || code == TYPE_CODE_REF
>>> -          || code == TYPE_CODE_METHODPTR
>>> -          || code == TYPE_CODE_MEMBERPTR);
>>> +  try
>>> +    {
>>> +      if (code == TYPE_CODE_PTR
>>> +      && target_supports_memory_tagging ()
>>> +      && gdbarch_tagged_address_p (target_gdbarch (), value))
>>> +    return true;
>>
>> Hmm, so why only TYPE_CODE_PTR in the new code but TYPE_CODE_REF and
>> method/member pointers in the old?
>>
> 
> My assessment of the situation wasn't entirely correct (too optimistic).
> Trying to handle all of these types in such a high level function is
> very complex and very error-prone. This is, in part, due to how GDB
> bends the handling of some types in order to show the data the user
> wants. Even the type-handling functions run into some conversion issues
> sometimes.
> 
> The member pointers, more specifically, are not even regular pointers,
> but a TYPE_CODE_INT of 16 bytes. Trying to interpret that as a pointer
> so we can do memory tag operations runs into conversion limitations of
> GDB's type-casting system.
> 
> Handling only TYPE_CODE_PTR is guaranteed to have the desired effect,
> since we want to be able to show the pointer's logical tag and also
> potentially want to set the allocation tag for the memory tag granule
> that pointer points to. A value of type TYPE_CODE_PTR will always have a
> valid value_address () return.
> 
> We can handle all the other types in the default way. There is obviously
> room for improvement in terms of what types we should/should not handle,
> but right now handling TYPE_CODE_PTR gives very useful results for the
> most common use cases.

Ok, sounds good to me.  That was the only bit that didn't seem obvious to
me when reading the diff.

-- 
John Baldwin

  reply	other threads:[~2021-05-28 22:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18 20:20 Luis Machado
2021-05-27 11:31 ` [PING] " Luis Machado
2021-05-28 19:08 ` John Baldwin
2021-05-28 19:18   ` Luis Machado
2021-05-28 22:11     ` John Baldwin [this message]
2021-05-29  1:26 ` Simon Marchi
2021-05-29  6:26   ` Luis Machado
2021-06-20 16:19     ` Joel Brobecker
2021-06-21 13:28       ` Luis Machado
2021-06-22  1:37 ` Luis Machado
2021-07-01 13:50   ` [PING][PATCH] " Luis Machado
2021-07-01 19:52   ` [PATCH] " Pedro Alves
2021-07-02 12:47     ` Luis Machado
2021-07-02 13:19       ` Pedro Alves
2021-07-02 13:45         ` Luis Machado
2021-07-02 15:14           ` Pedro Alves
2021-07-05 14:32             ` Luis Machado
2021-07-05 23:06               ` Pedro Alves
2021-07-06 16:32                 ` Luis Machado
2021-07-07 10:49                   ` [PATCH v3] Fix printing of non-address " Pedro Alves
2021-07-17 18:53                     ` Joel Brobecker
2021-07-19  9:37                       ` Luis Machado
2021-07-19 18: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=e9a8b41d-ad0a-a3c9-0355-597fcf5d8883@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=gdb-patches@sourceware.org \
    --cc=luis.machado@linaro.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).