From: Andrew Cagney <cagney@gnu.org>
To: Orjan Friberg <orjan.friberg@axis.com>
Cc: gdb-patches@sources.redhat.com,
Michael Elizabeth Chastain <mec.gnu@mindspring.com>,
Joel Brobecker <brobecker@gnat.com>
Subject: Re: CRIS port; frame cleanup crash
Date: Sat, 14 Feb 2004 14:52:00 -0000 [thread overview]
Message-ID: <402E3612.50001@gnu.org> (raw)
In-Reply-To: <402E24DC.8060006@axis.com>
[Joel, MichaelC, FYI]
> Andrew Cagney wrote:
>
>> The term "unwind" is used by the dwarf-2 specification. http://www.eagercon.com/dwarf/dwarf3std.htm
>> it includes a working example in the appendix.
>
> Excellent, thanks a lot. Section 6.4 regarding Call Frame Information cleared up some of the confusion regarding unwinding.
>> The important thing is to "dig out" the register from the correct frame. frame_unwind_register (next_frame, "pc") will "dig out" the PC from the next frame (often found in next frame's link register) returning the value as it should be in "this_frame".
>
> This explanation has me slightly puzzled. I gather from the code that "PC" refers to the current program location within a frame, and not an actual CPU register. Is "next" synonymous with "outer" in your explanation above? (Perhaps a stupid question; maybe unwind by definition works on the outer frame/caller.) And "link register" I assume is the equivalent of a subroutine return pointer.
Yes, "pc" is a misnomer, within GDB it doesn't mean the "pc register",
"resume address" is closer. Check the comments in frame.c:struct
frame_info for definitions of: "next", "inner", "newer" and separatly
"prev", "outer", "older". Yes, link register is the return address
register.
This frame (the caller) calls next frame (the callee). As part of that
the callers resume addresses ends up in the callee's return-address
register. The callee (next) then saves the return-address register on
the stack. Hence to get the callers (this) PC, it needs to be dug out
of the callers (next) frame's stack. Anyway, sounds like you've got it
right.
> Approaching it from another direction, what would be a good test to see if the unwind code works correctly? At present, step (into function calls), next (over function calls), finish, and backtrace seem to work ok for both leaf- and non-leaf-functions (for CRIS the prologue differs slightly as the SRP isn't pushed in case of a leaf function). Is there any particular existing testcase that would be good at detecting errors in the frame code?
Exactly that.
Also "advance.exp", in particular the sequence:
./gdb advance
(gdb) break func
(gdb) run
(gdb) advance func3
--- should break in main and not func3
is a good check of the frame ID.
And callfuncs.exp, and a sequence like:
./gdb callfuncs
(gdb) break add
(gdb) break main
(gdb) run
(gdb) print add(1,2)
(gdb) bt
(gdb) print add(3,4)
(gdb) bt
add(3,4)
<dummy frame>
add (1,2)
<dummy frame>
main ()
(gdb)
is a good check of dummy frames
> Another question: should I hook in the dwarf-2 frame sniffer from the very beginning? Or wait until the other stuff seems to be working ok?
Towards the end. It's good to first get the old code working reasonably
well.
Andrew
next prev parent reply other threads:[~2004-02-14 14:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-11 13:30 Orjan Friberg
2003-08-12 15:11 ` Orjan Friberg
2003-08-12 17:36 ` Andrew Cagney
2003-08-13 10:17 ` Orjan Friberg
2004-02-12 18:59 ` Orjan Friberg
2004-02-12 20:06 ` Andrew Cagney
2004-02-14 13:38 ` Orjan Friberg
2004-02-14 14:52 ` Andrew Cagney [this message]
2004-02-15 17:41 ` Orjan Friberg
2004-02-16 18:19 ` Orjan Friberg
2004-02-16 18:43 ` Andrew Cagney
2004-02-18 17:06 ` Orjan Friberg
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=402E3612.50001@gnu.org \
--to=cagney@gnu.org \
--cc=brobecker@gnat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=mec.gnu@mindspring.com \
--cc=orjan.friberg@axis.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