[patch/hppa-linux] MD_FALLBACK_FRAME_STATE_FOR definition
Andrew Haley
aph@redhat.com
Fri Apr 9 20:06:00 GMT 2004
Randolph Chung writes:
> > You'll need a PC adjustment for boundary cases. It's quite possible
> > that you haven't yet seen a test case that fails. (Unless hppa leaves
> > PC pointing at the insn after the one that traps, in which case you
> > may ignore this advice.)
>
> do you have a specific test case for me? :)
No, and it's impossible certainly to write one unless you resort to
assembly language. You need a faulting instruction that's the first
instruction in a EH region.
> or point me to the bit of
> code that uses this "adjusted PC"?
Yes. See below.
> there are several things:
> - on palinux, the "PC" (iaoq[0]) has the 2 lower bits set for userspace
> addresses, so if the fault occured in 0x10780, the iaoq[0] in the
> sigcontext will have 0x10783. (instructions are all 4-bytes wide, so
> the next insn will usually be at 0x10784)
This should be fine. However, relying on this is so very weird that
it might deserve a comment...
> - pa has a two-level deep "PC", so there's an iaoq[0] and iaoq[1].
> iaoq[1] points to the next insn to be executed. in some cases this is
> not iaoq[0]+4 (for some branching cases).
Well, I presume your MD_FALLBACK_FRAME_STATE_FOR will do the Right
Thing. SEGV on most processors leaves PC pointing at the faulting
insn, presumably so that it can be restarted; I dunno about hppa.
> so... i need to know how this is used to know if/how we need to adjust
> the PC.
It's here. Note that, unlesss PC is adjusted, this "context->ra - 1"
may move the address into a previous region. That's the crux of the
matter: "context->ra - 1" *must* point into an insn that's in your EH
region.
static _Unwind_Reason_Code
uw_frame_state_for (struct _Unwind_Context *context, _Unwind_FrameState *fs)
{
const struct dwarf_fde *fde;
const struct dwarf_cie *cie;
const unsigned char *aug, *insn, *end;
memset (fs, 0, sizeof (*fs));
context->args_size = 0;
context->lsda = 0;
if (context->ra == 0)
return _URC_END_OF_STACK;
fde = _Unwind_Find_FDE (context->ra - 1, &context->bases);
Andrew.
More information about the Gcc-patches
mailing list