From: David Taylor <taylor@candd.org>
To: Jim Blandy <jimb@zwingli.cygnus.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: RFA: fix GDB casts when pointers are not addresses
Date: Mon, 09 Jul 2001 19:55:00 -0000 [thread overview]
Message-ID: <200107100255.WAA09863@houston.candd.org> (raw)
From: Jim Blandy <jimb@zwingli.cygnus.com>
Date: Thu, 28 Jun 2001 17:57:04 -0500 (EST)
This patch changes GDB to match GCC's behavior when casting pointers
to integers on machines where pointers are not direct byte addresses
(like Harvard architectures).
This patch is a prerequisite for removing the D10V-specific code from
the GDB core (for example, see value_at in valops.c).
The details:
In the scope of a declaration like this:
void (*f) ();
the C standards say expressions like these yield unspecified values:
(int) f;
In the absence of clear direction from an independent standard, I feel
that GDB should match GCC's behavior.
On most processors, there's a single obvious behavior for a cast from
a pointer to an integer of the same size. However, the D10V has a
256k code address space, indexed by 16-bit pointers; all instructions
are 32-bit values, naturally aligned, so we multiply a 16-bit code
pointer's value by four to get the corresponding byte address in code
space. This means that there are two plausible interpretations for a
cast from code ptr to integer:
- the integer produced is the byte address in the code segment (so for
the D10V, this would be the pointer's value times four), or
- the integer produced is the 16-bit pointer value reinterpreted as a
16-bit integer --- no adjustment takes place.
Currently, GDB implements the former, while GCC implements the former.
This patch changes GDB to match GCC.
former, former; one should be latter...
One could argue that `value_as_long' should not convert pointers to
addresses, but there are many other places in GDB that assume it will.
2001-06-28 Jim Blandy <jimb@redhat.com>
* valops.c (value_cast): When casting a pointer to an integer,
don't convert it to an address.
I approve of bringing the compiler and debugger into agreement on how
to interpret an expression. You might want to make note of that in
the ChangeLog entry.
Approved.
next reply other threads:[~2001-07-09 19:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-09 19:55 David Taylor [this message]
[not found] <20010628225704.9AB635E9CB@zwingli.cygnus.com>
2001-07-04 22:15 ` Andrew Cagney
2001-07-05 11:48 ` Jim Blandy
2001-07-05 13:09 ` Andrew Cagney
2001-07-05 16:23 ` Jim Blandy
2001-07-05 23:08 ` Andrew Cagney
2001-07-06 16:28 ` Jim Blandy
2001-07-10 13:33 ` Andrew Cagney
2001-07-05 23:12 ` Andrew Cagney
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=200107100255.WAA09863@houston.candd.org \
--to=taylor@candd.org \
--cc=gdb-patches@sources.redhat.com \
--cc=jimb@zwingli.cygnus.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