Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: RFC: problems with minimal symbols (without a type)
Date: Wed, 15 Nov 2017 01:35:00 -0000	[thread overview]
Message-ID: <20171115013531.cwj5pzjttrihofhl@adacore.com> (raw)
In-Reply-To: <4bca71af-2877-2adf-9f54-e51d7e6b5b8b@redhat.com>

> > And unfortunately, the Ada equivalent of casting does not work either:
> > 
> >     (gdb) print integer(constraint_error)
> >     'constraint_error' has unknown type; cast it to its declared type
> 
> Shouldn't we just make that work, like it works for C?

Of course. It's at the top of my list, and independent in my mind
of the discussion about forcing the cast. It was a convenient
work-around, however, allowing me to reduce the urgency to fix
this issue with casting.

That being said...

> Let me quote a conversation that happened on IRC just last week
> (user name anonymized):
[...]
>  <palves>	you have to cast malloc to the right function pointer type, and then call that.
>  <palves>	something like: p ((void * (*) (size_t )) malloc) (128)
>  <palves>	in master, the simpler 'p (void*)malloc (128)' does the right thing.
>  <palves>	(it infers the prototype from the type of the passed in arguments + the cast-to type)

I understand why GDB now behaves more naturally when using the casting
information to infer the symbol's type and how this is an improvement.
But wouldn't that part be orthogonal to the question whether GDB should
make this case mandatory or not?

This is probably a judgement call. And since I didn't comment on
the patch when it was proposed, I suppose it's fair that I try it
for Ada users as well, and see how they react. It'll keep the languages
consistent too, which is an advantage.

Just to answer some of your questions (therefore not in the spirit
of continuing a debate):

> At least an Ada conversion/cast is Ada syntax.
> The "print {my_type} minsym'address" syntax above looks like
> the GDB syntax/extension that works with C too?

Yes, this part is documented in the Ada section of the GDB manual.

> How do users discover that that gdb syntax extension is available
> and that they need to use it?
> For non-integer types, users must already do some casting to get at
> the real data.  Why treat integers differently?

For me, this is because those minimal symbols are typically integral
types. So, for a non-trivial part of the times I use this feature,
it actually gives me the right answer. Therefore, for me, GDB lost
a small feature that didn't always work, but still did work for a good
chunk of the scenarios I was involved in.

I'll work on fixing the casting whenever I find some time...

That got me to one piece of code in evaluate_subexp_for_cast:

      /* Don't allow e.g. '&(int)var_with_no_debug_info'.  */
      if (VALUE_LVAL (val) == lval_memory)
        {
          if (value_lazy (val))
            value_fetch_lazy (val);
          VALUE_LVAL (val) = not_lval;
        }

I was wondering why do we not want to allow someone get its
address? I checked the commit that introduced this change,
and it doesn't say.

Thanks for the feedback,
-- 
Joel


  reply	other threads:[~2017-11-15  1:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-09  1:25 Joel Brobecker
2017-11-09 10:47 ` Pedro Alves
2017-11-15  1:35   ` Joel Brobecker [this message]
2017-11-15 12:17     ` Pedro Alves
2017-11-15 18:52       ` Joel Brobecker
2017-11-17  0:51         ` Joel Brobecker
2017-11-17 11:32         ` Pedro Alves
2017-11-17 17:19           ` Joel Brobecker

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=20171115013531.cwj5pzjttrihofhl@adacore.com \
    --to=brobecker@adacore.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