From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCHv2 4/5] gdb: Introduce new language field la_is_string_type_p
Date: Fri, 19 Apr 2019 21:00:00 -0000 [thread overview]
Message-ID: <20190419210033.GV2737@embecosm.com> (raw)
In-Reply-To: <7134c1a3-8cd3-bcb2-c1b3-444f1c879049@redhat.com>
* Pedro Alves <palves@redhat.com> [2019-04-18 18:07:55 +0100]:
> On 4/17/19 12:06 AM, Andrew Burgess wrote:
> > This commit is preparation work for the next commit, and by itself
> > makes no user visible change to GDB. I've split this work into a
> > separate commit in order to make code review easier.
> >
> > This commit adds a new field 'la_is_string_type_p' to the language
> > struct, this predicate will return true if a type is a string type for
> > the given language.
> >
> > Some languages already have a "is this a string" predicate that I was
> > able to reuse, while for other languages I've had to add a new
> > predicate. In this case I took inspiration from the value printing
> > code for that language - what different conditions would result in
> > printing something as a string.
> >
> > A default "is this a string" method has also been added that looks for
> > TYPE_CODE_STRING, this is the fallback I've used for a couple of
> > languages.
> >
> > In this commit I add the new field and initialise it for each
> > language, however at this stage the new field is never used.
> >
>
> Thanks. This nicely addresses one of my previous review comments.
>
> I can't speak to whether the implementation for the different languages
> are correct. E.g., I'm curious from where you extracted the M2 and
> the Rust bits. Didn't seem like it was a refactoring job?
It was mostly me looking for calls to LA_PRINT_STRING in each
languages value printing code then combining all of the conditions
required to reach these calls.
Could we refactor to make use of these new is_string functions within
the value printing code? Sure, but I don't think it would be pretty.
Most languages base their value printing around a switch statement,
and also have additional format related conditions mixed in with the
logic.
Ideally, at least for this commit I'd prefer to no mess with the value
printing code more than I need too...
Thanks,
Andrew
>
> Formatting comments below.
>
> > +/* Return true if TYPE is a string. */
> > +static bool
>
> Empty line after comment.
>
> > +static bool
> > +m2_is_string_type_p (struct type *type)
> > +{
> > + type = check_typedef (type);
> > + if (TYPE_CODE (type) == TYPE_CODE_ARRAY
> > + && TYPE_LENGTH (type) > 0
> > + && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
> > + {
> > + struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
> > +
> > + if (TYPE_LENGTH (elttype) == 1 &&
>
> && goes on the next line.
>
> > + (TYPE_CODE (elttype) == TYPE_CODE_INT
> > + || TYPE_CODE (elttype) == TYPE_CODE_CHAR))
> > + return true;
> > + }
> > +
> > + return false;
> > +}
> > +
>
> Thanks,
> Pedro Alves
next prev parent reply other threads:[~2019-04-19 21:00 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-16 23:06 [PATCHv2 0/5] Add new 'print max-depth' feature Andrew Burgess
2019-03-27 21:53 ` [PATCH 0/2] " Andrew Burgess
2019-03-27 21:53 ` [PATCH 1/2] gdb: Introduce new language field la_struct_too_deep_ellipsis Andrew Burgess
2019-03-28 12:43 ` Pedro Alves
2019-03-27 21:53 ` [PATCH 2/2] gdb: Introduce 'print max-depth' feature Andrew Burgess
2019-03-28 16:08 ` Eli Zaretskii
2019-03-28 12:47 ` [PATCH 0/2] Add new " Pedro Alves
2019-03-28 22:48 ` Andrew Burgess
2019-03-28 23:47 ` Marco Barisione
2019-04-16 23:06 ` [PATCHv2 1/5] gdb/ada: Update some predicate functions to return bool Andrew Burgess
2019-04-18 0:03 ` Joel Brobecker
2019-04-16 23:06 ` [PATCHv2 5/5] gdb: Introduce 'print max-depth' feature Andrew Burgess
2019-04-17 7:42 ` Philippe Waroquiers
2019-04-17 14:35 ` Eli Zaretskii
2019-04-18 1:07 ` Andrew Burgess
2019-04-18 2:38 ` Eli Zaretskii
2019-04-18 21:52 ` Andrew Burgess
2019-04-19 6:50 ` Eli Zaretskii
2019-04-18 17:08 ` Pedro Alves
2019-04-16 23:06 ` [PATCHv2 2/5] gdb/testsuite: Don't add gcc flags when compiling rust tests Andrew Burgess
2019-04-19 14:31 ` Tom Tromey
2019-04-16 23:06 ` [PATCHv2 3/5] gdb: Introduce new language field la_struct_too_deep_ellipsis Andrew Burgess
2019-04-19 14:37 ` Tom Tromey
2019-04-16 23:06 ` [PATCHv2 4/5] gdb: Introduce new language field la_is_string_type_p Andrew Burgess
2019-04-18 17:08 ` Pedro Alves
2019-04-19 21:00 ` Andrew Burgess [this message]
2019-04-19 14:45 ` Tom Tromey
2019-04-19 22:22 ` Andrew Burgess
2019-04-24 19:32 ` Tom Tromey
2019-04-19 22:45 ` Andrew Burgess
2019-04-24 19:33 ` Tom Tromey
2019-04-29 21:14 ` [PATCHv2 0/5] Add new 'print max-depth' feature Andrew Burgess
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=20190419210033.GV2737@embecosm.com \
--to=andrew.burgess@embecosm.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