From: Simon Marchi <simark@simark.ca>
To: Andrew Burgess <andrew.burgess@embecosm.com>, gdb-patches@sourceware.org
Subject: Re: [PATCHv3 1/2] gdb: Convert enum range_type to a bit field enum
Date: Sat, 19 Sep 2020 09:50:41 -0400 [thread overview]
Message-ID: <3c557be0-e07c-2894-322c-65559f695b61@simark.ca> (raw)
In-Reply-To: <e92d2bfab5afe0c3e83a6cae55a083e62d23b5b5.1600505722.git.andrew.burgess@embecosm.com>
On 2020-09-19 5:48 a.m., Andrew Burgess wrote:
> The expression range_type enum represents the following ideas:
>
> - Lower bound is set to default,
> - Upper bound is set to default,
> - Upper bound is exclusive.
>
> There are currently 6 entries in the enum to represent the combination
> of all those ideas.
>
> In a future commit I'd like to add stride information to the range,
> this could in theory appear with any of the existing enum entries, so
> this would take us to 12 enum entries.
>
> This feels like its getting a little out of hand, so in this commit I
> switch the range_type enum over to being a flags style enum. There's
> one entry to represent no flags being set, then 3 flags to represent
> the 3 ideas above. Adding stride information will require adding only
> one more enum flag.
>
> I've then gone through and updated the code to handle this change.
>
> There should be no user visible changes after this commit.
I think it's a good idea. I noted a few comments below.
> diff --git a/gdb/expression.h b/gdb/expression.h
> index 5af10f05db1..9dc598984e0 100644
> --- a/gdb/expression.h
> +++ b/gdb/expression.h
> @@ -187,20 +187,20 @@ extern void dump_prefix_expression (struct expression *, struct ui_file *);
>
> enum range_type
> {
> - /* Neither the low nor the high bound was given -- so this refers to
> - the entire available range. */
> - BOTH_BOUND_DEFAULT,
> + /* This is a standard range. Both the lower and upper bounds are
> + defined, and the bounds are inclusive. */
> + RANGE_STANDARD = 0,
> +
> /* The low bound was not given and the high bound is inclusive. */
> - LOW_BOUND_DEFAULT,
> + RANGE_LOW_BOUND_DEFAULT = 1 << 0,
> +
> /* The high bound was not given and the low bound in inclusive. */
> - HIGH_BOUND_DEFAULT,
> - /* Both bounds were given and both are inclusive. */
> - NONE_BOUND_DEFAULT,
> - /* The low bound was not given and the high bound is exclusive. */
> - NONE_BOUND_DEFAULT_EXCLUSIVE,
> - /* Both bounds were given. The low bound is inclusive and the high
> - bound is exclusive. */
> - LOW_BOUND_DEFAULT_EXCLUSIVE,
> + RANGE_HIGH_BOUND_DEFAULT = 1 << 1,
I don't think the comments on RANGE_LOW_BOUND_DEFAULT and
RANGE_HIGH_BOUND_DEFAULT should mention that the other bound is
inclusive anymore, since that's controlled by another flag.
> +DEF_ENUM_FLAGS_TYPE (enum range_type, range_types);
I think the type name is confusing. I thought at first it was related
to a TYPE_CODE_RANGE `struct type`. What about renaming to "enum
range_flag" and the enum flags type to "range_flags"?
> diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
> index db888098c4a..5111de9cf9c 100644
> --- a/gdb/rust-exp.y
> +++ b/gdb/rust-exp.y
> @@ -2492,24 +2492,29 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation,
>
> case OP_RANGE:
> {
> - enum range_type kind = BOTH_BOUND_DEFAULT;
> + enum range_type kind = (RANGE_HIGH_BOUND_DEFAULT
> + | RANGE_LOW_BOUND_DEFAULT);
>
> if (operation->left.op != NULL)
> {
> convert_ast_to_expression (operation->left.op, top);
> - kind = HIGH_BOUND_DEFAULT;
> + kind = RANGE_HIGH_BOUND_DEFAULT;
What I understand from this code is: if the low bound (left) is provided
to the range operator, we want to clear the RANGE_LOW_BOUND_DEFAULT bit.
So I think it would be more natural to write in the typical form to
clear bits:
kind &= ~RANGE_LOW_BOUND_DEFAULT;
I think it expresses the intent better.
You'll need to make the enum type explicitly unsigned to be able to use
the ~ operator.
Simon
next prev parent reply other threads:[~2020-09-19 13:50 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-13 12:58 [PATCH 0/8] Fortran Array Slicing and Striding Support Andrew Burgess
2020-08-13 12:58 ` [PATCH 1/8] gdbsupport: Provide global operators |=, &=, and ^= for enum bit flags Andrew Burgess
2020-08-15 17:16 ` Tom Tromey
2020-08-16 9:13 ` Andrew Burgess
2020-08-17 10:40 ` Andrew Burgess
2020-08-20 16:00 ` Pedro Alves
2020-08-21 14:49 ` Pedro Alves
2020-08-21 15:57 ` Andrew Burgess
2020-08-21 18:10 ` Pedro Alves
2020-08-13 12:58 ` [PATCH 2/8] gdbsupport: Make function arguments constant in enum-flags.h Andrew Burgess
2020-08-15 19:45 ` Tom Tromey
2020-08-16 9:08 ` Andrew Burgess
2020-08-13 12:58 ` [PATCH 3/8] gdb/fortran: Clean up array/string expression evaluation Andrew Burgess
2020-08-13 12:58 ` [PATCH 4/8] gdb/fortran: Move Fortran expression handling into f-lang.c Andrew Burgess
2020-08-13 12:58 ` [PATCH 5/8] gdb/fortran: Change whitespace when printing arrays Andrew Burgess
2020-08-13 12:58 ` [PATCH 6/8] gdb: Convert enum range_type to a bit field enum Andrew Burgess
2020-08-13 12:58 ` [PATCH 7/8] gdb/testsuite: Add missing expected results Andrew Burgess
2020-08-13 12:58 ` [PATCH 8/8] gdb/fortran: Add support for Fortran array slices at the GDB prompt Andrew Burgess
2020-08-13 13:31 ` Eli Zaretskii
2020-08-26 14:49 ` [PATCHv2 00/10] Fortran Array Slicing and Striding Support Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 01/10] Rewrite valid-expr.h's internals in terms of the detection idiom (C++17/N4502) Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 02/10] Use type_instance_flags more throughout Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 03/10] Rewrite enum_flags, add unit tests, fix problems Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 04/10] gdb: additional changes to make use of type_instance_flags more Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 05/10] gdb/fortran: Clean up array/string expression evaluation Andrew Burgess
2020-09-19 8:53 ` Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 06/10] gdb/fortran: Move Fortran expression handling into f-lang.c Andrew Burgess
2020-09-19 8:53 ` Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 07/10] gdb/fortran: Change whitespace when printing arrays Andrew Burgess
2020-09-19 8:54 ` Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 08/10] gdb: Convert enum range_type to a bit field enum Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 09/10] gdb/testsuite: Add missing expected results Andrew Burgess
2020-09-18 9:53 ` Andrew Burgess
2020-08-26 14:49 ` [PATCHv2 10/10] gdb/fortran: Add support for Fortran array slices at the GDB prompt Andrew Burgess
2020-08-26 17:02 ` Eli Zaretskii
2020-09-19 9:47 ` [PATCHv3 0/2] Fortran Array Slicing and Striding Support Andrew Burgess
2020-09-19 9:48 ` [PATCHv3 1/2] gdb: Convert enum range_type to a bit field enum Andrew Burgess
2020-09-19 13:50 ` Simon Marchi [this message]
2020-09-19 9:48 ` [PATCHv3 2/2] gdb/fortran: Add support for Fortran array slices at the GDB prompt Andrew Burgess
2020-09-19 10:03 ` Eli Zaretskii
2020-09-28 9:40 ` [PATCHv4 0/3] Fortran Array Slicing and Striding Support Andrew Burgess
2020-09-28 9:40 ` [PATCHv4 1/3] gdb: Convert enum range_type to a bit field enum Andrew Burgess
2020-09-28 9:40 ` [PATCHv4 2/3] gdb: rename 'enum range_type' to 'enum range_flag' Andrew Burgess
2020-09-28 9:40 ` [PATCHv4 3/3] gdb/fortran: Add support for Fortran array slices at the GDB prompt Andrew Burgess
2020-09-28 9:52 ` Eli Zaretskii via Gdb-patches
2020-10-11 18:12 ` [PATCHv5 0/4] Fortran Array Slicing and Striding Support Andrew Burgess
2020-10-11 18:12 ` [PATCHv5 1/4] gdb: Convert enum range_type to a bit field enum Andrew Burgess
2020-10-20 20:16 ` Tom Tromey
2020-10-11 18:12 ` [PATCHv5 2/4] gdb: rename 'enum range_type' to 'enum range_flag' Andrew Burgess
2020-10-20 20:16 ` Tom Tromey
2020-10-11 18:12 ` [PATCHv5 3/4] gdb/fortran: add support for parsing array strides in expressions Andrew Burgess
2020-10-12 13:21 ` Simon Marchi
2020-10-20 20:17 ` Tom Tromey
2020-10-22 10:42 ` Andrew Burgess
2020-10-11 18:12 ` [PATCHv5 4/4] gdb/fortran: Add support for Fortran array slices at the GDB prompt Andrew Burgess
2020-10-12 14:10 ` Simon Marchi
2020-10-20 20:45 ` Tom Tromey
2020-10-29 11:08 ` Andrew Burgess
2020-10-31 22:16 ` [PATCHv6] " Andrew Burgess
2020-11-12 12:09 ` Andrew Burgess
2020-11-12 18:58 ` Tom Tromey
2020-11-19 11:56 ` 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=3c557be0-e07c-2894-322c-65559f695b61@simark.ca \
--to=simark@simark.ca \
--cc=andrew.burgess@embecosm.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