Re: Difficulties while adding local init_regs support to libebl

Subject: Re: Difficulties while adding local init_regs support to libebl

Hi Ben,
I hope you haven't given up on these ideas. I would really like to see
some of them integrated.
On Tue, Sep 08, 2015 at 02:58:39PM +0200, Mark Wielaard wrote:
> > Unfortunately, this is idea is dead on arrival (which I didn't realize
> > until far too much head-scratching): the stack frames between
> > x86_64_set_initial_registers_local and dwfl_thread_getframes are gone by
> > the time we try to unwind. We return three times back to
> > dwfl_thread_getframes, before calling into the unwinder.
>
> O fun. I also didn't realize this till now... You want to unwind a bit
> before starting to unwind so you start unwinding at the correct frame...
>
> > This didn't affect me in GHC since there were no stack frames sitting
> > between the initial register collection and the unwinder.
> >
> > I see two ways to work around this,
> >
> > 1. Implement a small amount of unwinding in the initial register collection
> > code to get back to a stack frame which won't disappear from
> > beneath our feet
> >
> > 2. Ensure that there are no stack frames sitting between initial
> > register collection and the unwinder
> >
> > Option 1 strikes me as quite complex and fragile.
>
> Yeah. I will think a bit about whether we can have a callback interface
> for ebl_set_initial_registers_local so it can reuse the libdwfl
> unwinder. I hope it doesn't have to be complex and fragile, but I am not
> 100% sure yet. The current code isn't really setup for it. But I think
> it should be possible. But...
I tried to implement option 1 anyway. Does the attached help you?
Cheers,
Mark