public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Cagney <ac131313@redhat.com>
To: Jim Blandy <jimb@redhat.com>
Cc: gdb@sources.redhat.com
Subject: Re: IBM S/390 prologue analysis revisited
Date: Wed, 02 Jul 2003 18:33:00 -0000	[thread overview]
Message-ID: <3F032568.5060700@redhat.com> (raw)
In-Reply-To: <vt2wuf1zta4.fsf@zenia.home>


>> Editor note: It's missing the undefined state.  I'll add it.
> 
> 
> I'd say that 'struct trad_frame_saved_reg' and 'struct prologue_value'
> are inverses of each other.  They represent information at different
> steps in the process:
> - First you interpret your prologue to get a bunch of prologue values.
> - Then you use those to compute a set of trad_frame_saved_reg values.
> - Finally, those are what you'd use to find registers.
> 
> Let me explain what I mean.

Ah!  Yes, in that case my suggestion doesn't make sense.

Can I encourage you to add this to either the s390 to trad-frame code? 
Trad frame might be better as it then provides a pointer towards the 
``new technique'' (but which ever).

Andrew


> The S/390 prologue analyzer creates a table of registers' current
> values, expressed as simple expressions:
>   - "unknown",
>   - "the constant K", or
>   - "the original value of register R plus the constant K"
> 
> To build this info, you just "interpret" the prologue, starting at the
> entry point, using prologue values instead of actual integers.  Here's
> the code for the S/390 "add register" instruction when it appears in a
> prologue:
> 
>       ...
>       /* AR r1, r2 -- add register */
>       else if (is_rr (insn, op_ar, &r1, &r2))
>         pv_add (&gpr[r1], &gpr[r1], &gpr[r2]);
>       ...
> 
> That is, you just "add" the current values of r1 and r2, and store the
> "result" in r1.  (The "pv_*" functions do addition, subtraction,
> etc. on prologue values, returning "unknown" whenever the answer can't
> be expressed in one of the forms above.)  When you stop, you've got
> the information you need to unwind: a description of the machine's
> resultant state after running the prologue.
> 
> So, suppose your prologue moves the SP into the FP, and then subtracts
> 100 from the SP.  In that case, the S/390 prologue analyzer will end
> up with the following "values" in those registers:
> 
>   SP: "the original value of SP plus the constant -100"
>   FP: "the original value of SP plus the constant 0"
> 
> Given this it's easy to find the original SP, the frame size, and so
> on.
> 
> But here's what's cool: suppose your prologue is actually:
> - save the SP in the FP
> - move the constant "-100" into register R4
> - subtract R4 from SP
> 
> That extra step, going through register R4, would break a traditional
> prologue analyzer, even though it's equivalent to the original
> sequence (as far as SP and FP are concerned), unless you add special
> code to recognize that maneuver.  But the S/390 prologue analyzer
> handles this just fine, with no special cases, producing a final state
> of:
> 
>   R4: "the constant -100"
>   SP: "the original value of SP plus the constant -100"
>   FP: "the original value of SP plus the constant 0"
> 
> So you still get the information you wanted.
> 
> This is the point where trad_frame_saved_reg comes in: that final
> state information there is not exactly what you need for register
> unwinding.  To find the original SP, say, you need to search the
> register set for a register whose current value is "the original value
> of SP plus the constant Q".  In the above case, we could recover the
> original SP from either the current SP or the current FP.  (The FP is
> a little easier, but if you make sure you can handle either case, then
> you've got support for FP-less functions, too.)  But if you simply
> make a pass over the entire register set, and record where one can
> find the original values of registers, then you've produced a complete
> set of 'struct trad_frame_saved_reg' values in one pass.
> 
> So as things stand, prologue values and trad_frame_saved_reg
> structures are inverses of each other: they play different roles.  A
> trad_frame_saved_reg points to one of the values your prologue
> "interpreter" tracks: a register, stack slot, or whatever.
> 


  reply	other threads:[~2003-07-02 18:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <vt2d6gv2lt3.fsf@zenia.home>
     [not found] ` <1030630233621.ZM27669@localhost.localdomain>
2003-07-01  0:14   ` Elena Zannoni
2003-07-01  0:57 ` Andrew Cagney
2003-07-01 12:28   ` Andrew Cagney
2003-07-02  0:06     ` Jim Blandy
2003-07-02 18:33       ` Andrew Cagney [this message]
2003-07-02 19:20         ` Daniel Jacobowitz
2003-07-01 22:51   ` Jim Blandy

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=3F032568.5060700@redhat.com \
    --to=ac131313@redhat.com \
    --cc=gdb@sources.redhat.com \
    --cc=jimb@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).