From: Kevin Buettner <kevinb@redhat.com>
To: "Martin M. Hunt" <hunt@redhat.com>, gdb-patches@sources.redhat.com
Subject: Re: [RFA] string_to_core_addr fix
Date: Thu, 10 Oct 2002 15:40:00 -0000 [thread overview]
Message-ID: <1021010223959.ZM14496@localhost.localdomain> (raw)
In-Reply-To: "Martin M. Hunt" <hunt@redhat.com> "[RFA] string_to_core_addr fix" (Oct 10, 3:07pm)
On Oct 10, 3:07pm, Martin M. Hunt wrote:
> This is necessary for 64-bit targets where sometimes 32-bit
> values must be sign-extended to 64-bits.
>
> 2002-10-10 Martin M. Hunt <hunt@redhat.com>
>
> * utils.c (string_to_core_addr): After turning string into
> a number, convert to a CORE_ADDR using POINTER_TO_ADDRESS
> which will do necessary sign-extension, etc.
>
> Index: utils.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/utils.c,v
> retrieving revision 1.80
> diff -u -p -r1.80 utils.c
> --- utils.c 20 Sep 2002 00:24:01 -0000 1.80
> +++ utils.c 10 Oct 2002 22:06:50 -0000
> @@ -2649,7 +2649,7 @@ string_to_core_addr (const char *my_stri
> internal_error (__FILE__, __LINE__, "invalid decimal");
> }
> }
> - return addr;
> + return POINTER_TO_ADDRESS (builtin_type_void_data_ptr, &addr);
> }
>
> char *
While I agree that something like this is needed, I'm not convinced that
using POINTER_TO_ADDRESS on a CORE_ADDR is right. By default,
unsigned_pointer_to_address() is used. It looks like this:
/* Given a pointer of type TYPE in target form in BUF, return the
address it represents. */
CORE_ADDR
unsigned_pointer_to_address (struct type *type, void *buf)
{
return extract_address (buf, TYPE_LENGTH (type));
}
The problem is that ``addr'' is an address in host format (i.e, a CORE_ADDR),
not a target address. I suspect you'll get incorrect results if the
host and target are of different endianness or if sizeof (CORE_ADDR) !=
TYPE_LENGTH (type).
I think you could get the right results by writing addr to a buffer
(maybe using store_typed_address) and then using extract_typed_address(),
but there may be a more straightforward way to do it.
Kevin
next prev parent reply other threads:[~2002-10-10 22:40 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 [this message]
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
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=1021010223959.ZM14496@localhost.localdomain \
--to=kevinb@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