* [RFA] Arm/Thumb tweak for generic_dummy_frames
@ 2002-05-21 18:45 Michael Snyder
2002-05-22 2:52 ` Richard Earnshaw
0 siblings, 1 reply; 4+ messages in thread
From: Michael Snyder @ 2002-05-21 18:45 UTC (permalink / raw)
To: gdb-patches; +Cc: rearnsha
Richard,
This is a corner case that Andrew missed when he did the
transition to generic dummy frames.
2002-05-21 Michael Snyder <msnyder@redhat.com>
* arm-tdep.c (arm_frame_chain): Recognize dummy-frame as a
special case that does not indicate a transition from arm
to thumb or vice versa.
Index: arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.62
diff -p -r1.62 arm-tdep.c
*** arm-tdep.c 21 May 2002 15:36:02 -0000 1.62
--- arm-tdep.c 22 May 2002 01:38:08 -0000
*************** arm_frame_chain (struct frame_info *fi)
*** 1039,1062 ****
struct frame_info caller_fi;
struct cleanup *old_chain;
! /* Create a temporary frame suitable for scanning the caller's
! prologue. (Ugh.) */
! memset (&caller_fi, 0, sizeof (caller_fi));
! caller_fi.extra_info = (struct frame_extra_info *)
! xcalloc (1, sizeof (struct frame_extra_info));
! old_chain = make_cleanup (xfree, caller_fi.extra_info);
! caller_fi.saved_regs = (CORE_ADDR *)
! xcalloc (1, SIZEOF_FRAME_SAVED_REGS);
! make_cleanup (xfree, caller_fi.saved_regs);
! /* Now, scan the prologue and obtain the frame register. */
! caller_fi.pc = caller_pc;
! arm_scan_prologue (&caller_fi);
! framereg = caller_fi.extra_info->framereg;
! /* Deallocate the storage associated with the temporary frame
! created above. */
! do_cleanups (old_chain);
}
/* If the caller used a frame register, return its value.
--- 1039,1066 ----
struct frame_info caller_fi;
struct cleanup *old_chain;
! if (!(USE_GENERIC_DUMMY_FRAMES
! && PC_IN_CALL_DUMMY (caller_pc, 0, 0)))
! {
! /* Create a temporary frame suitable for scanning the caller's
! prologue. (Ugh.) */
! memset (&caller_fi, 0, sizeof (caller_fi));
! caller_fi.extra_info = (struct frame_extra_info *)
! xcalloc (1, sizeof (struct frame_extra_info));
! old_chain = make_cleanup (xfree, caller_fi.extra_info);
! caller_fi.saved_regs = (CORE_ADDR *)
! xcalloc (1, SIZEOF_FRAME_SAVED_REGS);
! make_cleanup (xfree, caller_fi.saved_regs);
! /* Now, scan the prologue and obtain the frame register. */
! caller_fi.pc = caller_pc;
! arm_scan_prologue (&caller_fi);
! framereg = caller_fi.extra_info->framereg;
! /* Deallocate the storage associated with the temporary frame
! created above. */
! do_cleanups (old_chain);
! }
}
/* If the caller used a frame register, return its value.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] Arm/Thumb tweak for generic_dummy_frames
2002-05-21 18:45 [RFA] Arm/Thumb tweak for generic_dummy_frames Michael Snyder
@ 2002-05-22 2:52 ` Richard Earnshaw
2002-05-22 22:01 ` Andrew Cagney
2002-05-23 14:21 ` Michael Snyder
0 siblings, 2 replies; 4+ messages in thread
From: Richard Earnshaw @ 2002-05-22 2:52 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches, rearnsha
msnyder@cygnus.com said:
> This is a corner case that Andrew missed when he did the transition
> to generic dummy frames.
> 2002-05-21 Michael Snyder <msnyder@redhat.com>
> * arm-tdep.c (arm_frame_chain): Recognize dummy-frame as a
> special case that does not indicate a transition from arm
> to thumb or vice versa.
I can't (easily) work out from this what was wrong, and how you've fixed
it. Could you provide some more detailed analysis? Why would a dummy
frame never involve a transition between ARM and Thumb state?
R.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] Arm/Thumb tweak for generic_dummy_frames
2002-05-22 2:52 ` Richard Earnshaw
@ 2002-05-22 22:01 ` Andrew Cagney
2002-05-23 14:21 ` Michael Snyder
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Cagney @ 2002-05-22 22:01 UTC (permalink / raw)
To: Richard.Earnshaw; +Cc: Michael Snyder, gdb-patches, rearnsha
> msnyder@cygnus.com said:
>
>> This is a corner case that Andrew missed when he did the transition
>> to generic dummy frames.
>
>
>> 2002-05-21 Michael Snyder <msnyder@redhat.com>
>
>
>> * arm-tdep.c (arm_frame_chain): Recognize dummy-frame as a
>> special case that does not indicate a transition from arm
>> to thumb or vice versa.
>
>
> I can't (easily) work out from this what was wrong, and how you've fixed
> it. Could you provide some more detailed analysis? Why would a dummy
> frame never involve a transition between ARM and Thumb state?
(I didn't really miss a corner case - the code was broken before/after
the dummy frame conversion. The results for thumb are different to arm
though).
When you have an Arm v Thumb stack you see:
Thumb-frame(Thumb FP) (callee)
Arm-frame (Arm FP) (caller)
The function frame_chain(Thumb-frame) needs to return the frame-pointer
for the calling Arm-frame.
To do this it first compares the caller and callee PC to check for a
mode change. If one occure the callers prologue is examined to
determine which register was used for the FP and hence, which register
of the oposite mode needs to be unwound to obtain the frame chain.
What it didn't handle was:
Thumb-frame
dummy-frame
Arm-frame
in fact, it was even messing up
Thumb-frame
dummy-frame
Thumb-frame
(and that is before my change :-) The problem being that the
dummy-frame's PC is assumed to be Arm (based on symbol and address
analysis).
Michael's patch changes things to detect the presence of a dummy frame
and then, for that case, assume the callee and caller are the same. It
doesn't help thumb dummy arm though (but the old code didn't appear to
handle that case either).
enjoy,
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA] Arm/Thumb tweak for generic_dummy_frames
2002-05-22 2:52 ` Richard Earnshaw
2002-05-22 22:01 ` Andrew Cagney
@ 2002-05-23 14:21 ` Michael Snyder
1 sibling, 0 replies; 4+ messages in thread
From: Michael Snyder @ 2002-05-23 14:21 UTC (permalink / raw)
To: Richard.Earnshaw; +Cc: Michael Snyder, gdb-patches, rearnsha
Richard Earnshaw wrote:
>
> msnyder@cygnus.com said:
> > This is a corner case that Andrew missed when he did the transition
> > to generic dummy frames.
>
> > 2002-05-21 Michael Snyder <msnyder@redhat.com>
>
> > * arm-tdep.c (arm_frame_chain): Recognize dummy-frame as a
> > special case that does not indicate a transition from arm
> > to thumb or vice versa.
>
> I can't (easily) work out from this what was wrong, and how you've fixed
> it. Could you provide some more detailed analysis?
Yeah, but not without drawing some pictures. ;-)
OK, here's the context. You're debugging in main, you put a breakpoint
at foo, and then you call foo, thusly:
(gdb) print foo()
(Let's say that main and foo are both thumb).
You hit the breakpoint, and now your runtime stack looks something like
this:
#0 foo
#1 dummy frame created by gdb
#2 main
At this point, GDB has already constructed a frame_info for foo,
doing all the prolog analysis and computing the saved registers.
So now you say "backtrace".
So gdb callse arm_frame_chain to find and start analyzing frame #1.
The first thing arm_frame_chain does is ask whether this frame
(frame #0) is a dummy frame. No, it's not, so we continue.
Then we compute the return address of frame #0, which for a
generic dummy frame is always the entry point address ("_start"
or crt0 or whatever).
Next, we compare the return address to the current frame's address,
to see whether we've made a transition between arm code and
thumb code. But this isn't a valid question if the caller_pc
is actually gdb's dummy frame, because the situation
(caller_pc == _start) is artificial. _start may be arm code,
and frame #0 may be thumb code, but we weren't actually called
from _start, so we don't want to act as if we were.
Now as to your second question --
> Why would a dummy frame never involve a transition between
> ARM and Thumb state?
Well, that's not what this change is actually about -- this change
is about thumb-calling-thumb (with a bogus "arm" dummy frame in
the middle). However, Andrew and I discussed what would happen
if you were in arm code and you tried to have GDB call a thumb
function (or vice versa), and decided that, well, we haven't
really handled that situation either before or after this change.
Someday we need to address it.
I guess I also should have mentioned that I ran testsuites
before and after. This change definitely fixes some failures,
and it doesn't introduce any new ones.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-05-23 20:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-21 18:45 [RFA] Arm/Thumb tweak for generic_dummy_frames Michael Snyder
2002-05-22 2:52 ` Richard Earnshaw
2002-05-22 22:01 ` Andrew Cagney
2002-05-23 14:21 ` Michael Snyder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox