Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <ac131313@redhat.com>
To: Michal Ludvig <mludvig@suse.cz>
Cc: Andreas Schwab <schwab@suse.de>,
	GDB Patches <gdb-patches@sources.redhat.com>
Subject: Re: [RFA] Skip the "red zone" on AMD64
Date: Thu, 07 Aug 2003 14:10:00 -0000	[thread overview]
Message-ID: <3F325DE5.3000706@redhat.com> (raw)
In-Reply-To: <3F3237D8.10502@suse.cz>

 > This is pretty obvious patch that doesn't harm anything, but anyway - 
OK to apply?

Hmm,

> Andreas Schwab told me that:
> Michal Ludvig <mludvig@suse.cz> writes:
> 
> |> 2003-08-07  Michal Ludvig  <mludvig@suse.cz>
> |>     * x86-64-tdep.c (x86_64_push_arguments): Skip the red zone.
> 
> Please add an empty line after the heading.
> 
> Done.
> 
> Otherwise OK.
> 
> Thanks, committed to 6.0 and head.

The PowerOpen (a.k.a. AIX) and (as I only just discovered) PPC64 ABIs 
make use of the stack beyond the top-of-stack (SP) address.  A very long 
standing bug is that GDB needs to skip that area before allocating stack 
space.

This architecture's `red zone' sounds like the same [mis-]feature.  If 
it is then the posted change won't fix the problem :-(  The return 
structure, already allocated on the stack, will smash that stack area.

I think this code:

   /* Ensure that the initial SP is correctly aligned.  */
   {
     CORE_ADDR old_sp = read_sp ();
     if (gdbarch_frame_align_p (current_gdbarch))
       {
         /* NOTE: cagney/2002-09-18:

            On a RISC architecture, a void parameterless generic dummy
            frame (i.e., no parameters, no result) typically does not
            need to push anything the stack and hence can leave SP and
            FP.  Similarly, a frameless (possibly leaf) function does
            not push anything on the stack and, hence, that too can
            leave FP and SP unchanged.  As a consequence, a sequence of
            void parameterless generic dummy frame calls to frameless
            functions will create a sequence of effectively identical
            frames (SP, FP and TOS and PC the same).  This, not
            suprisingly, results in what appears to be a stack in an
            infinite loop --- when GDB tries to find a generic dummy
            frame on the internal dummy frame stack, it will always
            find the first one.

            To avoid this problem, the code below always grows the
            stack.  That way, two dummy frames can never be identical.
            It does burn a few bytes of stack but that is a small price
            to pay :-).  */
         sp = gdbarch_frame_align (current_gdbarch, old_sp);
         if (sp == old_sp)
           {
             if (INNER_THAN (1, 2))
               /* Stack grows down.  */
               sp = gdbarch_frame_align (current_gdbarch, old_sp - 1);
             else
               /* Stack grows up.  */
               sp = gdbarch_frame_align (current_gdbarch, old_sp + 1);
           }
         gdb_assert ((INNER_THAN (1, 2) && sp <= old_sp)
                     || (INNER_THAN (2, 1) && sp >= old_sp));
       }

so that it uses a new architecture method (size_of_frame_red_zone? 
default 1, assert > 0, doco) to pad out the stack before using it.

If this is the case, can you please revert the patch and post something 
more along the above lines.  Is there code in the testsuite that 
fails/passes with the fix?

Andrew

PS: In case you're wondering.  The above code was only added a few 
months ago.  Prior to that there wasn't anywhere to put the fix.



  reply	other threads:[~2003-08-07 14:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-07 11:05 Michal Ludvig
2003-08-07 11:18 ` Andreas Schwab
2003-08-07 11:27   ` Michal Ludvig
2003-08-07 14:10     ` Andrew Cagney [this message]
2003-08-07 14:40       ` Michal Ludvig
2003-08-07 15:04         ` 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=3F325DE5.3000706@redhat.com \
    --to=ac131313@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=mludvig@suse.cz \
    --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