Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] static_kind -> bit0, bit1  [Re: [gdb] Fortran dynamic 	arrays]
Date: Mon, 08 Sep 2008 17:27:00 -0000	[thread overview]
Message-ID: <20080908172701.GA18549@host0.dyn.jankratochvil.net> (raw)
In-Reply-To: <m38wu2psd4.fsf@fleche.redhat.com>

On Mon, 08 Sep 2008 17:30:47 +0200, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> 
> Jan> The patch modifies a lot of sources trying to follow the new
> Jan> style of main_type bitfields instead of the former FLAGS
> Jan> variable.  I do not think current main_type layout is right but
> Jan> the patch tries to follow the current main_type style.
> 
> Do you mean the main_type layout after this patch, or before this patch?
> If before -- could you be more specific?

Both before and it gets a bit worse after.  There should be a union with
fields for each very specific TYPE_CODE_*.

TYPE_CODE_ARRAY is terrible - it has always exactly NFIELDS==1 with
fields[0].type->main_type pointing to TYPE_CODE_RANGE having exactly NFIELDS==2
(for the lower and upper bound).  If we try so much to save some main_type
memory:
* fields[0].loc is not used.
* nfields everywhere is not used.
* main_type for TYPE_CODE_RANGE is not used as DW_TAG_subrange_type's
  DW_AT_type is stored into TYPE_CODE_RANGE's TYPE_TARGET_TYPE.
We should have just one TYPE_CODE_ARRAY main_type pointing to the element-type
(DW_TAG_array_type's DW_AT_type - which is right as its target_type) also also
one simple pointer to the index type (DW_TAG_subrange_type's DW_AT_type
- currently stored in TYPE_CODE_RANGE's target_type).

target_type, vptr_fieldno, vptr_basetype and some cases of fields[] is used
only for some types and for other types they are left unused.  These fields
should be moved to the type_specific union.

fields[] with nfields should be moved into the type_specific union for
specific types TYPE_CODE_FUNC, TYPE_CODE_STRUCT and some others.

Simple union would make it all more clear, optimal for the memory size and
even allocatable with variable length.

Some better encapsulation would benefit the dynamic bounds I hacked into the
current code.  There should be a virtual method with MAIN_TYPE containing
generic abstract class type.
class debuginfo_value                  { virtual LONGEST get() = 0; };
class dwarf2_integer : debuginfo_value { virtual LONGEST get() { ... }; };
class dwarf2_block   : debuginfo_value { virtual LONGEST get() { ... }; };
class main_type { ...; debuginfo_value upper_bound_value; ... };
LONGEST is not right as we need to return also unbound/undefined results.
Just C++ requires pointer (or reference) as upper_bound_value which is
inefficient so a C implementation (knowing the maximum size of all the
inherited classes) should be better here, right?

If the memory of main_type is so critical (I doubt so but i did not measure
it) in my Fortran/dynamic-bounds patch main_type had to get three new pointers
almost always being NULL.  These three pointers may need to be set for any
type so the base struct main_type has to be extended for them.
We could instead use the Amiga "tags" data format with variable block size
allocation (but sure slow access time which should not matter here):
struct main_type { ...; void *tags[1]; };
memcpy (main_type->tags,
	{ DW_AT_allocated, 0x601010,
	  DW_AT_associated, 0x610348,
	  NULL /* terminator */
	});


Regards,
Jan


  reply	other threads:[~2008-09-08 17:27 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 [this message]
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
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=20080908172701.GA18549@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@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