From: Andrew Cagney <ac131313@redhat.com>
To: Keith Walker <keith.walker@arm.com>
Cc: Richard.Earnshaw@arm.com, Andreas Schwab <schwab@suse.de>,
gdb-patches@sources.redhat.com
Subject: Re: [rfa?] Add frame_align(); Was: ARM stack alignment on hand called functions
Date: Thu, 28 Nov 2002 07:34:00 -0000 [thread overview]
Message-ID: <3DE6377E.1040106@redhat.com> (raw)
In-Reply-To: <4.3.2.7.2.20021128105650.01e91010@mhsun1.maidenhead.arm.com>
> At 10:40 28/11/2002 +0000, Richard Earnshaw wrote:
>> Richard Earnshaw <rearnsha@arm.com> writes:
>>
>> |> > +/* Ensure that the ARM's stack pointer has the correct alignment for a
>> |> > + new frame. */
>> |> > +static CORE_ADDR
>> |> > +arm_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
>> |> > +{
>> |> > + return (addr & -16);
>> |> > +}
>> |>
>> |> Yuck, two's complement assumption.
>>
>> No, -16 is implicitly cast to bfd_vma, which is unsigned, and this
>> operation is completely defined independent of the representation of
>> signed integers.
>
> Hmm, strictly speaking you are correct. I don't have to like it though,
> and it means that the code is heavily dependent on the non-obvious fact
> that addr is an unsigned type to get the correct behaviour (if bfd_vma
> were to be changed to a signed type then this code would quietly break).
>
> So I'll change my comment to:
>
> Yuck, implicit cast of negative number to unsigned.
>
> I notice that the h8300-tdep.c file defines some macros to do this sort of rounding ... round_up() and round_down(). As aligning addresses is a reasonable common thing to do maybe these macros should be moved to a more generic place and used whenever such rounding is required. It doesn't fix the implicit cast issue, but would at least make finding where such alignment occurs easier.
Hmm, the've been breeding. So does the MIPS and s390 ....
Equivalent functions that spell out each step vis:
ULONGEST mask = -(ULONGEST)(n);
ULONGEST maddr = (addr & mask);
return maddr;
and have a 10:1 comment:code ratio sound like a good idea.
A GDB goal can be to debug this at -O3 :-)
Andrew
next prev parent reply other threads:[~2002-11-28 15:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200211270917.gAR9HNE29771@pc960.cambridge.arm.com>
2002-11-27 10:43 ` Andrew Cagney
2002-11-28 1:26 ` Richard Earnshaw
2002-11-28 2:20 ` Andreas Schwab
2002-11-28 2:41 ` Richard Earnshaw
2002-11-28 2:45 ` Andreas Schwab
2002-11-28 2:57 ` Richard Earnshaw
2002-11-28 5:52 ` Keith Walker
2002-11-28 7:34 ` Andrew Cagney [this message]
2002-11-28 7:19 ` Andrew Cagney
2002-11-28 8:33 ` Richard Earnshaw
2002-11-28 8:45 ` Andrew Cagney
2002-11-28 8:50 ` Richard Earnshaw
2002-11-28 9:00 ` Andrew Cagney
2003-01-29 5:19 ` Andrew Cagney
2003-01-29 14:50 ` Kris Warkentin
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=3DE6377E.1040106@redhat.com \
--to=ac131313@redhat.com \
--cc=Richard.Earnshaw@arm.com \
--cc=gdb-patches@sources.redhat.com \
--cc=keith.walker@arm.com \
--cc=schwab@suse.de \
/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