From: Andrew Cagney <ac131313@redhat.com>
To: "Martin M. Hunt" <hunt@redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA] string_to_core_addr fix
Date: Tue, 22 Oct 2002 22:35:00 -0000 [thread overview]
Message-ID: <3DB632A2.4010003@redhat.com> (raw)
In-Reply-To: <1035342441.19691.112.camel@localhost.localdomain>
> On Mon, 2002-10-21 at 13:06, Andrew Cagney wrote:
>
>
>> Insight parse_and_eval_address() was simply bogus. See the thread
>> around the original introduction of these functions.
>
>
> I looked. All I found was something about parse_and_eval_address()
> being broken for harvard arch.
Sigh, looks like it was private e-mail :-(
>> A short summary is
>> that parse_and_eval_address() does conversions like you describe and
>> none are needed. Instead functions that parse in, write out, raw
>> CORE_ADDR values are needed.
>
>
> I believe we have target addrs and CORE_ADDRs, where CORE_ADDRs are
> sometimes target addrs sign-extended to 64-bits. Is that not right?
(not sure what `sometimes' was bound too)
A CORE_ADDR always contains an address converted to a canonical form.
For the MIPS (32 or 64 bit), when GDB is debugging a 32 bit ABI, the
CORE_ADDR will always contain a canonical value that has been created by
sign-extending the 32 bit pointer or register value.
>>From memory, you print out a target addr by using paddr_nz. If you
> wanted to print a CORE_ADDR you would use core_addr_to_string_nz. You
> can read in a CORE_ADDR with string_to_core_addr. So how do you read in
> a target addr and have it converted to a CORE_ADDR?
(is core_addr_to_string_nz() used?)
Addresses are ment to be displayed using print_address_numeric() and
similar. A user specified value would be parsed with something like
parse_and_eval_address().
On the other hand, string<->core_addr() is used as a way for Insight to
create an internal address handle (for saving things like frames). The
user should not be able to access or manipulate such values directly.
>
>> I believe that this change is wrong and should be reverted.
>
>
> By your definition of string_to_core_addr below, I agree. However, this
> bug has been here a long time and I would like some agreement on how it
> should properly be fixed.
I know of several ongoing bugs:
- GDB forgetting to convert a pointer into a core_addr
- GDB/Insight incorrectly interchanging addresses and core_addr
> The bug is simply that Insight gets CORE_ADDRs for any symbol lookup.
> It must convert them to strings and uses paddr_nz. Then the user does
> something with that address and Insight converts that address string
> back into a CORE_ADDR incorrectly (it doesn't sign-extend to 64-bits,
> therefore my patch).
That code is definitly wrong. The equality:
core_addr == string_to_core_addr (paddr_nz (core_addr))
does NOT hold.
The code should either:
- use string <-> core_addr() and not let the user directly manipulate
the values (insight could manipulate it though).
- Convert the CORE_ADDR back into an address, let the user manipulate
the address, and then use parse_and_eval_address() to get the core_addr
back. Not sure how well this would go with harvard architectures though
- for them, a simple address may not be sufficient for re-constructing
the CORE_ADDR.
Any way, the patch should be reverted.
Andrew
prev parent reply other threads:[~2002-10-23 5:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-10 15:09 Martin M. Hunt
2002-10-10 15:40 ` Kevin Buettner
2002-10-10 21:31 ` Martin M. Hunt
2002-10-11 0:08 ` Kevin Buettner
2002-10-21 13:06 ` Andrew Cagney
2002-10-22 20:08 ` Martin M. Hunt
2002-10-22 22:35 ` Andrew Cagney [this message]
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=3DB632A2.4010003@redhat.com \
--to=ac131313@redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=hunt@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