From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: Re: [unavailable values part 1, 03/17] expose list of available ranges to common code
Date: Tue, 15 Feb 2011 19:14:00 -0000 [thread overview]
Message-ID: <201102151859.03901.pedro@codesourcery.com> (raw)
In-Reply-To: <20110214211223.GA9425@host1.dyn.jankratochvil.net>
On Tuesday 15 February 2011 21:12:23, Jan Kratochvil wrote:
> On Mon, 14 Feb 2011 20:39:10 +0100, Pedro Alves wrote:
> > On Monday 14 February 2011 11:59:39, Jan Kratochvil wrote:
> > > > +struct mem_range
> > > > +{
> > > > + /* Lowest address in the range. */
> > > > + CORE_ADDR start;
> > > > +
> > > > + /* Length of the range. */
> > > > + int length;
> > > > +};
> > >
> > > Why couldn't GDB become 64bit clean - that is CORE_ADDR length.
> >
> > Probably a leftover from the value ranges stuff (value lengths
> > are ints, and so I made the value range lengths be ints too).
> > But I disagree with making it a CORE_ADDR. I think
> > lengths should be LONGEST or ULONGEST.
>
> While ULONGEST should work due to this invariant:
> ULONGEST_MAX >= CORE_ADDR_MAX
>
> Still in which case an inferior object size does not fit in CORE_ADDR?
> I do not think it can happen, CORE_ADDR should be OK for inferior size_t.
It's (mainly) not about fitting. An address is fundamently not the same
as a length/size. Representing a size with a type meant for
addresses is just not right, IMO. Imagine if CORE_ADDR was a C++ object
that also included a reference to an address space (I'm not saying
it should, only that it could. Even today you have the ppc/cell
gdb using special bit hacks in CORE_ADDRs to represent address
spaces). Then it would be clear that using it for lengths/sizes
wasn't right. Just as size_t should be used for host sizes, and
uintptr_t/intptr_t/pointers for host addresses. The opposite of what you
said is actually quite possible. There are systems where the addressable
address space is wider than the size of a single object/array can
be (thus size_t bitwidth may be narrower than than of uintptr_t).
As for what type for use then instead of CORE_ADDR, we traditionaly
use LONGEST/ULONGEST throughout, AFAICS. I guess nobody ever saw
a real need to come up with a special type for it.
OOC, I did:
$ grep "CORE_ADDR len" * -rn
python/py-inferior.c:63: CORE_ADDR length;
And I'm going to claim that this only hit shouldn't be
using CORE_ADDR.
Grepping for "LONGEST len" actually finds a large number
of uses.
--
Pedro Alves
next prev parent reply other threads:[~2011-02-15 18:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-07 14:29 Pedro Alves
2011-02-14 11:59 ` Jan Kratochvil
2011-02-14 19:54 ` Pedro Alves
2011-02-14 21:44 ` Jan Kratochvil
2011-02-15 18:42 ` Tom Tromey
2011-02-15 19:14 ` Pedro Alves [this message]
2011-02-15 21:02 ` 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=201102151859.03901.pedro@codesourcery.com \
--to=pedro@codesourcery.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@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