Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Siva Chandra <sivachandra@google.com>
To: gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Remove unwanted spaces when looking up builtin types
Date: Tue, 18 Nov 2014 23:59:00 -0000	[thread overview]
Message-ID: <CAGyQ6gx_92vb1jSCyt+3-PMLZ8BSr3hnTp9REON06O0mEyvM+g@mail.gmail.com> (raw)
In-Reply-To: <CAGyQ6gyM5OXG35e+q+3TpTxB-NTjC7DqAhQKxk_ZZYZfKwnSMQ@mail.gmail.com>

On Fri, Nov 7, 2014 at 5:49 AM, Siva Chandra <sivachandra@google.com> wrote:
> On Wed, Oct 29, 2014 at 11:50 AM, Siva Chandra <sivachandra@google.com> wrote:
>> Currently, if we do something like gdb.lookup_type(" unsigned long "),
>> GDB errors out because of the leading and trailing spaces.  The
>> attached patch fixes this problem.
>>
>> A practical situation where this problem is hit is when invoking
>> template methods. Its not uncommon to do things like this:
>>
>> (gdb) p foo.bar< unsigned long >()
>>
>> If "bar" happens to be an xmethod, then its implementation will
>> typically need to parse the name of the method ("bar< unsigned long >"
>> in the above example) to get the template argument and lookup the
>> type. GDB currently fails for such cases. One could of course
>> sanitize/fix such inputs in Python before calling lookup_type, but I
>> think it is better done on the GDB side as having white spaces is
>> valid syntax.
>>
>> For non-builtin types, lookup_type goes through the symbol lookup
>> path. AFAIU, that path already ignores whitespaces.
>

Ping.
This is not super critical, but I see that an xmethod test fails after
I have upgraded to gcc-4.8.2 from gcc-4.6. The essential difference I
have found is that looking up a symbol for "  unsigned int  " works
when the test is compiled with gcc-4.6 and it does not when compiled
with 4.8.2. And, when it does not, the type is looked up via
"language_lookup_primitive_type_by_name" which errors out as it does
an exact string match.

[I have not yet looked into why there is a difference between gcc-4.6
and gcc-4.8.2 as I think that the proposed fix is not inappropriate
and does fix the problem.]

>
> gdb/ChangeLog:
>
> 2014-11-07  Siva Chandra Reddy  <sivachandra@google.com>
>
>         * language.c (language_lookup_primitive_type_by_name): Remove
>         unwanted space in the type name before looking it up.
>         (whitespace_p): New function.
>
> gdb/testsuite/ChangeLog:
>
> 2014-11-07  Siva Chandra Reddy  <sivachandra@google.com>
>
>         * gdb.python/py-type.exp: Add new tests.


  reply	other threads:[~2014-11-18 23:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-29 18:50 Siva Chandra
2014-11-07 13:49 ` Siva Chandra
2014-11-18 23:59   ` Siva Chandra [this message]
2015-01-07  6:47 ` Siva Chandra
2015-01-07  7:03   ` 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=CAGyQ6gx_92vb1jSCyt+3-PMLZ8BSr3hnTp9REON06O0mEyvM+g@mail.gmail.com \
    --to=sivachandra@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