libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libunwind-devel] [PATCH 1/2] Restore the interpretation of the NULL


From: Lassi Tuura
Subject: Re: [Libunwind-devel] [PATCH 1/2] Restore the interpretation of the NULL %rbp location as end of frame chain.
Date: Thu, 20 Sep 2012 07:49:00 +0200

Hey,

>> > Looking at the unpatched Gstep.c, I see the following sequence
>> > of the events:
>> >
>> > 1. %rbp is zero, as read by DWARF_GET_LOC().
>> > 2. The rip_loc is set to DWARF_NULL_LOC, and then reassigned to cursor
>> >    dwarf.loc[RIP].
>> > 3. The check !DWARF_IS_NULL_LOC (c->dwarf.loc[RIP] returns false, which
>> >    causes assignment the c->dwarf.ip = 0.
>> > 4. The last non-return statement in unw_step() is executed, which verifies
>> >    that stepper has made a progress. It would not on the next step,
>> >    returning UNW_EBADFRAME.
>> >
>> > My patch explicitely handles the case of zero %ebp if dwarf unwinder
>> > already declained,
>>
>> Thanks for this! Are we talking about this code in src/x86_64/Gstep.c?
>>
>>  217       if (c->dwarf.ip == prev_ip && c->dwarf.cfa == prev_cfa)
>>  218         return -UNW_EBADFRAME;
>>
>> In that case, any idea why the previous unw_step() didn't flag it as
>> the last frame and return zero? It seems it's stuck looping on the
>> same frame if that condition trips? The previous frame should have
>> triggered either code around line 83 (dwarf-based; or the end-of-stack
>> code from Gparser.c) or line 152 (frame-pointer based), and unw_step()
>> should have returned zero? Or did I misunderstand?
>
> Goal of my patch is to make the code at line 152 to result in actually
> returning zero from unw_step(). I do not see how frame-based unwinder
> could return zero in unpatched code.

You wouldn't happen to have a debug log for that? I am unfortunately
not able to try the code just now, but from what I recall and reading
the code now, it should come into the "DWARF failed" branch with ret <
0, and should either set ret to zero via calls (mainly dwarf_get()),
or set it to 1 or 0 in the if block at the end.

For the particular case of zero rbp for the last frame, it should
return with the ret = 0 from the dwarf_get(), with a few intermediate
things done in between.

L.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]