[RFA/sparc] Add handling of stack-check probes

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[RFA/sparc] Add handling of stack-check probes

Joel Brobecker
Hello,

GDB is currently unable to unwind past stack-check probes that are
inserted by the compiler when compiling with -stack-check. The attached
patch adds handling for the sequences currently emitted by GCC. Eric
Botcazou told us that they can take 3 forms:

    1. A single probe
   
      sethi <some immediate>,%g1
      sub   %sp, %g1, %g1
      clr [%g1 - some immediate]
   
    2. A small number of probes (at most 5)
   
      sethi <some immediate>,%g1
      sub   %sp, %g1, %g1
      clr [%g1]
      add   %g1, -<some immediate>, %g1
      clr [%g1]
    [...]
      add   %g1, -<some immediate>, %g1
      clr [%g1]
      clr [%g1 - some immediate]
   
    3. A probing loop
   
      sethi  <some immediate>,%g1
      sub  %sp, %g1, %g1
      sethi  <some immediate>, %g4
      sub  %g1, %g4, %g4
      cmp  %g1, %g4
      be  <disp>
        add  %g1, -<some immediate>, %g1
      ba  <disp>
        clr  [%g1]
      clr [%g4 - some immediate]

2007-03-28  Joel Brobecker  <[hidden email]>

        * sparc-tdep.c (X_RS2): New macro.
        (sparc_skip_stack_check): New function.
        (sparc_analyze_prologue): Adjust PC past stack probing
        sequence if necessary.

Tested on sparc-solaris, no regression.
OK to apply?

Thanks,
--
Joel

PS: Do other people think that it is simpler for the human brain to understand
        if (pc >= current_pc)
    than
        if (current_pc <= pc)

    In other words, the boundary value is put on the rhs of the condition,
    and the variable value is put on the lhs... It's just an aesthetic
    consideration, but I can change it if others agree.

stack-check.diff (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [RFA/sparc] Add handling of stack-check probes

Eli Zaretskii
> Date: Wed, 28 Mar 2007 15:50:13 -0700
> From: Joel Brobecker <[hidden email]>
>
> PS: Do other people think that it is simpler for the human brain to understand
>         if (pc >= current_pc)
>     than
>         if (current_pc <= pc)
>
>     In other words, the boundary value is put on the rhs of the condition,
>     and the variable value is put on the lhs... It's just an aesthetic
>     consideration, but I can change it if others agree.

I prefer the variable to be on the left and the boundary on the right.

The only case where it is justified to reverse the order is when you
use ==, to avoid the frequent typo that uses only one `='.
Reply | Threaded
Open this post in threaded view
|

Re: [RFA/sparc] Add handling of stack-check probes

Daniel Jacobowitz-2
In reply to this post by Joel Brobecker
On Wed, Mar 28, 2007 at 03:50:13PM -0700, Joel Brobecker wrote:
> Hello,
>
> GDB is currently unable to unwind past stack-check probes that are
> inserted by the compiler when compiling with -stack-check. The attached
> patch adds handling for the sequences currently emitted by GCC. Eric
> Botcazou told us that they can take 3 forms:

The patch seems right to me, though I don't know too much about SPARC.

> 2007-03-28  Joel Brobecker  <[hidden email]>
>
>         * sparc-tdep.c (X_RS2): New macro.
>         (sparc_skip_stack_check): New function.
>         (sparc_analyze_prologue): Adjust PC past stack probing
>         sequence if necessary.
>
> Tested on sparc-solaris, no regression.
> OK to apply?

Yes, go ahead.

--
Daniel Jacobowitz
CodeSourcery
Reply | Threaded
Open this post in threaded view
|

Re: [RFA/sparc] Add handling of stack-check probes

Joel Brobecker
> > 2007-03-28  Joel Brobecker  <[hidden email]>
> >
> >         * sparc-tdep.c (X_RS2): New macro.
> >         (sparc_skip_stack_check): New function.
> >         (sparc_analyze_prologue): Adjust PC past stack probing
> >         sequence if necessary.
> >
> > Tested on sparc-solaris, no regression.
> > OK to apply?
>
> Yes, go ahead.

Thank you! Now checked in.

--
Joel