From: "Nathan J. Williams" <nathanw@wasabisystems.com>
To: Jim Blandy <jimb@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: RFA: general prologue analysis framework
Date: Fri, 07 Oct 2005 21:25:00 -0000 [thread overview]
Message-ID: <mtu8xx5rped.fsf@scrubbing-bubbles.mit.edu> (raw)
In-Reply-To: <m3y8568as0.fsf@alligator.red-bean.com>
Jim Blandy <jimb@redhat.com> writes:
> If folks are interested, I can post the m32c prologue analyzer that
> uses these functions, as an example of how they can be used.
I would be interested. I like the general concept; I have one question
about the use, based on a remark in the comments:
> + Once you've reached the current PC, or an instruction that you
> + don't know how to simulate, you stop. Now you can examine the
> + state of the registers and stack slots you've kept track of.
> +
> + - To see how large your stack frame is, just check the value of the
> + stack pointer register; if it's the original value of the SP
> + minus a constant, then that constant is the stack frame's size.
> + If the SP's value has been marked as 'unknown', then that means
> + the prologue has done something too complex for us to track, and
> + we don't know the frame size.
Short form: "What about branches?"
Long form: I recently did a port for a target CPU whose compiler
didn't provide any debug information about the stack frame. I dug out
their sizes at any given point by examining the code from the function
entry point to the current PC, and tracking the values added or
subtracted to the SP (said compiler also did not believe in adjusting
the SP once on function entry, and didn't gave a frame
pointer). However, I was tripped up by code kind of like:
; function entry
add sp,-64
...
...
beq 1f
add sp, 64
ret
1: ...
...
add sp, 64
ret
When my analyzer linearly plowed through the code, it would have
computed the net frame size as 0 at point 1, which was wrong. I worked
around this by ignoring sp adjustments right before a return
instruction, but it was clunky. I wanted to implement a computation of
the stack offset at each point in the function, but didn't have
time. Would this framework be amenable to maintaining such a mapping?
- Nathan
next prev parent reply other threads:[~2005-10-07 21:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-07 20:39 Jim Blandy
2005-10-07 21:25 ` Nathan J. Williams [this message]
2005-10-07 21:30 ` Daniel Jacobowitz
2005-10-07 21:41 ` Nathan J. Williams
2005-10-08 7:02 ` Jim Blandy
2005-10-08 7:01 ` Jim Blandy
2005-10-08 16:00 ` Daniel Jacobowitz
2005-10-09 20:27 ` Daniel Jacobowitz
2005-10-13 0:20 ` Jim Blandy
2005-10-13 1:04 ` Daniel Jacobowitz
2005-10-13 13:50 ` Ulrich Weigand
2005-10-13 17:17 ` Jim Blandy
2005-10-13 17:48 ` Ulrich Weigand
2005-10-13 18:03 ` Daniel Jacobowitz
2005-10-14 18:13 ` Jim Blandy
2005-10-17 18:52 ` Ulrich Weigand
2005-10-17 20:28 ` Jim Blandy
2005-11-23 2:56 ` Ulrich Weigand
2005-10-15 12:12 ` Eli Zaretskii
2005-10-17 20:32 ` Jim Blandy
2005-10-19 8:55 ` Eli Zaretskii
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=mtu8xx5rped.fsf@scrubbing-bubbles.mit.edu \
--to=nathanw@wasabisystems.com \
--cc=gdb-patches@sourceware.org \
--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