Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org, Tobias Burnus <burnus@net-b.de>,
		Ulrich Weigand <uweigand@de.ibm.com>,
		Jim Blandy <jimb@red-bean.com>,
	jimb@codesourcery.com
Subject: Re: [patch] static_kind -> bit0, bit1  [Re: [gdb] Fortran dynamic arrays]
Date: Wed, 24 Sep 2008 19:15:00 -0000	[thread overview]
Message-ID: <20080924191504.GA3613@adacore.com> (raw)
In-Reply-To: <20080922151909.GA12274@host0.dyn.jankratochvil.net>

> Here is the patch.

Argh, it took me a long time to break through the patch because
I had missed the fact that the upper-bound was indeed set to
BOUND_CANNOT_BE_DETERMINED once. I think you were pretty clear
about this in your previous message, but my (hopefully then)
fried brain didn't register. I'm sorry I missed that somehow,
because it changes slightly my point of view. To make it up to you,
I will try to help as much as I can.

Anyway, so the patch is using the TYPE_FIELD_ARTIFICIAL bit to
detect range types where a given bound value cannot be determined.
The patch as it is would work, and I wouldn't object to having it
checked in as a small step forward (with the agreement from at least
one other maintainer). However, I think we can implement this slightly
differently to make it more general.

struct field has the following two components:

    /* For a function or member type, this is 1 if the argument is marked
       artificial.  Artificial arguments should not be shown to the
       user.  */
    unsigned int artificial : 1;

    /* This flag is zero for non-static fields, 1 for fields whose location
       is specified by the label loc.physname, and 2 for fields whose location
       is specified by loc.physaddr.  */

    unsigned int static_kind : 2;

In practice, these are really what we call "discriminants" in Ada, which
means a value that we read in order to know what field to use in the
"loc" union. I propose that, instead of re-using the "artificial" flag
for undefined bounds, we merge the two components "artificial" and
"static_kind" together into a 3-bit field whose value would be an enum
that tells us what field to use for our field loc.

Because this field would be 3-bit long, it would allow us to have 7
different possible fields, in addition to the case where the bound
is undefined or the argument is artificial.  That would leave more
than enough room to then add a DWARF block as a possible field loc.

What does everyone think?

Some comments on your patch, that I did review pretty carefully:

> 2008-09-22  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	Replace TYPE_ARRAY_{UPPER,LOWER}_BOUND_TYPE by a bit if {un,}defined.
> 	* gdb/c-typeprint.c (c_type_print_varspec_suffix), gdb/m2-typeprint.c
> 	(m2_array), gdb/p-typeprint.c (pascal_type_print_varspec_prefix),
> 	gdb/valops.c (value_cast), gdb/varobj.c (c_number_of_children): Replace
> 	TYPE_ARRAY_UPPER_BOUND_TYPE compared to BOUND_CANNOT_BE_DETERMINED by
> 	TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED.
[...]

I am not sure about the reason why you listed all the filenames with
the gdb/ subdirectory in it, but the gdb/ subdir has its own ChangeLog,
so it shouldn't be part of the file name. Perhaps it's because you wanted
to make it clear that the changes are in the gdb/ directory.  Usually,
it's obvious enough that I don't bother.  When I make changes to more
than one directory such that it will cause more than one ChangeLog to
be updated, I sometimes write something like this:

    gdb/
    2008-09-22  Joel Brobecker <....>
    [...]

    gdb/testsuite/
    2008-09-22  Joel Brobecker <...>

Most of the time, I don't even bother, as it is clear enough.  I do
make sure to write each ChangeLog separately as shown above, though.
I noticed that you grouped all your changes, including your testsuite
changes into one CL entry.

> -      retcode = f77_get_dynamic_lowerbound (type, &lower_bound);
> -
> -      lower_bound_was_default = 0;
> -
> -      if (retcode == BOUND_FETCH_ERROR)
> -	fprintf_filtered (stream, "???");
> -      else if (lower_bound == 1)	/* The default */
> -	lower_bound_was_default = 1;
> -      else
> -	fprintf_filtered (stream, "%d", lower_bound);
> -
> -      if (lower_bound_was_default)
> -	lower_bound_was_default = 0;
> -      else
> -	fprintf_filtered (stream, ":");
> +      lower_bound = f77_get_lowerbound (type);
> +      if (lower_bound != 1)	/* Not the default.  */
> +	fprintf_filtered (stream, "%d:", lower_bound);

Here, it looks like  we're slightly modifying the behavior - if the lower
bound was undefined, then we're throwing an error when we used not to.
I think that would be unfriendly if this issue is caused by bad debug
info. Should we check that the lower bound is not undefined first, and
print "???" if it is?

> @@ -2719,14 +2690,13 @@ recursive_dump_type (struct type *type, 
>      }
>    puts_filtered ("\n");
>    printfi_filtered (spaces, "length %d\n", TYPE_LENGTH (type));
> -  printfi_filtered (spaces, "upper_bound_type 0x%x ",
> -		    TYPE_ARRAY_UPPER_BOUND_TYPE (type));
> -  print_bound_type (TYPE_ARRAY_UPPER_BOUND_TYPE (type));
> -  puts_filtered ("\n");
> -  printfi_filtered (spaces, "lower_bound_type 0x%x ",
> -		    TYPE_ARRAY_LOWER_BOUND_TYPE (type));
> -  print_bound_type (TYPE_ARRAY_LOWER_BOUND_TYPE (type));
> -  puts_filtered ("\n");
> +  if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
> +    {
> +      printfi_filtered (spaces, "upper bound undefined is %d\n",
> +			TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type));
> +      printfi_filtered (spaces, "lower bound undefined is %d\n",
> +			TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED (type));
> +    }

I think this is only repetitive, and shouldn't be displayed. The
artificial field value will be displayed a little later, and that
should be good enough.  No strong objection, though.

-- 
Joel


  reply	other threads:[~2008-09-24 19:15 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-15 15:06 [gdb] Fortran dynamic arrays Tobias Burnus
2008-08-18 11:12 ` Joel Brobecker
2008-08-18 15:54   ` Ulrich Weigand
2008-09-07 11:59 ` [patch] static_kind -> bit0, bit1 [Re: [gdb] Fortran dynamic arrays] Jan Kratochvil
2008-09-08 15:32   ` Tom Tromey
2008-09-08 17:27     ` Jan Kratochvil
2008-09-19 22:29       ` Joel Brobecker
2008-09-26 23:04         ` Tom Tromey
2008-09-27 14:53           ` Joel Brobecker
2008-09-19  6:04   ` Joel Brobecker
2008-09-22 15:25     ` Jan Kratochvil
2008-09-24 19:15       ` Joel Brobecker [this message]
2008-09-26  5:03         ` Jan Kratochvil
2008-09-26 22:12           ` Joel Brobecker
2008-10-02 22:13             ` [patch] Fortran obsolete bounds type [Re: [patch] static_kind -> bit0, bit1] Jan Kratochvil
2008-09-26 12:52         ` [patch] static_kind -> bit0, bit1 [Re: [gdb] Fortran dynamic arrays] Daniel Jacobowitz
2008-09-26 22:15           ` Joel Brobecker
2008-09-26 22:20             ` Daniel Jacobowitz
2008-09-19 22:13   ` Joel Brobecker
2008-09-26  5:06     ` Accessor macro wrappers removal [Re: [patch] static_kind -> bit0, bit1] Jan Kratochvil
2008-09-26 12:55       ` Daniel Jacobowitz
2008-10-02 20:59         ` Jan Kratochvil
2008-10-02 21:05           ` Daniel Jacobowitz
2008-09-26 23:15       ` Tom Tromey
2008-09-26 12:58     ` [patch] static_kind -> bit0, bit1 [Re: [gdb] Fortran dynamic arrays] Daniel Jacobowitz
     [not found]       ` <20081006200928.GD3588@adacore.com>
2008-10-06 20:26         ` Jan Kratochvil
2008-10-07 23:22         ` type/main_type/field size [Re: [patch] static_kind -> bit0, bit1] Jan Kratochvil
2008-10-08  3:32           ` Joel Brobecker
2008-10-08 23:56             ` Tom Tromey
2008-10-04 20:28     ` [patch] static_kind -> bit0, bit1 [Re: [gdb] Fortran dynamic arrays] Jan Kratochvil
2008-10-06 20:00       ` Joel Brobecker
2008-10-07 23:18         ` Jan Kratochvil
2008-10-08  3:28           ` Joel Brobecker
2008-10-08 12:54             ` Jan Kratochvil

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=20080924191504.GA3613@adacore.com \
    --to=brobecker@adacore.com \
    --cc=burnus@net-b.de \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=jimb@codesourcery.com \
    --cc=jimb@red-bean.com \
    --cc=uweigand@de.ibm.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