From: Daniel Jacobowitz <drow@false.org>
To: Andrew STUBBS <andrew.stubbs@st.com>
Cc: GDB Patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Fixup internal variables' endian (again)
Date: Thu, 30 Mar 2006 00:17:00 -0000 [thread overview]
Message-ID: <20060329232241.GD9916@nevyn.them.org> (raw)
In-Reply-To: <4408847C.9040907@st.com>
On Fri, Mar 03, 2006 at 06:01:32PM +0000, Andrew STUBBS wrote:
> Hi all,
>
> This is a rework of a patch I submitted last autumn. I have updated it
> to fit with the new convenience variable preservation and rethought the
> requirements.
>
> The patch fixes up the endian of all integer and pointer internal
> variables and leaves all other types alone.
Hi Andrew,
This seems like a sensible thing to do now, and a sensible way to do
it.
> My understanding is that an internal variable cannot contain anything
> other than a built-in type. Any other value is merely a memory
> reference. Indeed, value_of_internalvar() goes out of it's way to ensure
> that values loaded from memory are never saved long term. The result is
> that there is no point in attempting to do anything with the endian of
> these values because they will always be of the same endian as the
> target/program being debugged.
I'm pretty sure that we can come up with ways to get structs into
internal variables, et cetera. But, this is a best-effort thing;
I think it's OK as long as we do better than we do now, since it's
pretty apparent that what we do now is not useful.
So, just minor comments.
> + /* Values are always stored in the target's byte order. When connected to a
> + target this will most likely always be correct, so there's normally no
> + need to worry about it.
> +
> + However, internal variables can be set up before the target endian is
> + known and so may become out of date. Fix it up before anybody sees.
> +
> + Since internal variables cannot hold complex types, such as structs,
> + unions, arrays and strings - those are always held in target memory and
> + the variable just holds a reference, there is no need to worry about
> + those either.
> +
> + Floating point values vary differently across endianness - many targets
> + just keep them the same. If they do no work correctly on your host/target
> + then add support as required here. */
How do you feel about replacing those last two paragraphs with:
Internal variables usually hold simple scalar values, and we can
correct those. More complex values (e.g. structures and floating
point types) are left alone, because they would be too complicated
to correct.
I don't think we really want someone to fix this by adding floating
point support.
> + if (var->endian != TARGET_BYTE_ORDER)
> + {
> + array = value_contents_raw (val);
> + switch (TYPE_CODE (value_type (val)))
You should use type = check_typedef (value_type (val)) here; that's the
other easy case.
> + {
> + case TYPE_CODE_INT:
> + case TYPE_CODE_PTR:
> + /* Reverse the bytes. */
> + for (i=0,j=TYPE_LENGTH (value_enclosing_type (val))-1; i<j; i++,j--)
Formatting; you've skipped a lot of customary whitespace here. We have
vertical space and we know how to use it!
for (i=0, j=TYPE_LENGTH (value_enclosing_type (val)) - 1;
i < j;
i++, j--)
Also, I think you used eight spaces instead of a tab here; the diff
looked funny.
> - value_print (var->value, gdb_stdout, 0, Val_pretty_default);
> + value_print (value_of_internalvar (var), gdb_stdout, 0, Val_pretty_default);
And this line needs to be wrapped, it's too long now.
--
Daniel Jacobowitz
CodeSourcery
next prev parent reply other threads:[~2006-03-29 23:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-03 21:39 Andrew STUBBS
2006-03-30 0:17 ` Daniel Jacobowitz [this message]
2006-03-30 14:16 ` Andrew STUBBS
2006-03-30 16:25 ` Daniel Jacobowitz
2006-03-31 14:16 ` Andrew STUBBS
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=20060329232241.GD9916@nevyn.them.org \
--to=drow@false.org \
--cc=andrew.stubbs@st.com \
--cc=gdb-patches@sourceware.org \
/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