This is an archive of the discontinued LLVM Phabricator instance.

[DWARF] Get RA from RA register even if it appears unused
AcceptedPublic

Authored by whitequark on May 16 2018, 12:17 PM.

Details

Reviewers
compnerd
Summary

If prolog info lists the RA register as unused, it means that
the current stack frame corresponds to a leaf function which never
needs to save the RA register. The RA register is of course used
to return from this leaf function.

Such a frame may be in the middle of the stack if another frame was
pushed on top of it by a signal or CPU exception. In this case,
unless we extract RA from the RA register, _Unwind_Backtrace would
stop at the frame right above the signal or exception frame.

Diff Detail

Repository
rUNW libunwind

Event Timeline

whitequark created this revision.May 16 2018, 12:17 PM

Reuploaded diff with context.

It would be nice if we had a test case added for this, but, seems correct to me.

src/DwarfInstructions.hpp
195

I think that we should stick to LLVM style (coddled braces) and use C++ style casts.

It would be nice if we had a test case added for this

This is inherently architecture and platform specific, and libunwind currently doesn't have any provisions for this... In principle, would a x86-only Linux-only test suffice? I'm not sure if I can spend time making it more portable.

src/DwarfInstructions.hpp
195

Ack re braces.

I was copying that cast from ten lines above. Should I change that too? This should be a static_cast, right?

compnerd accepted this revision.Jun 12 2018, 8:05 PM

x86-Linux-only test is good. LG with the discussed changes.

src/DwarfInstructions.hpp
195

Yeah, it should be a static_cast. And, yes, it should be fine to adjust the style there too (just do it as a separate commit).

This revision is now accepted and ready to land.Jun 12 2018, 8:05 PM