FuncUnwinders: remove "current_offset" from function arguments
authorPavel Labath <pavel@labath.sk>
Tue, 23 Apr 2019 09:57:14 +0000 (09:57 +0000)
committerPavel Labath <pavel@labath.sk>
Tue, 23 Apr 2019 09:57:14 +0000 (09:57 +0000)
commit2359429168a8f8882cd9caaac7c4e24803fabbb8
tree2ee2f40090721a91dbf336dc7425792725e254dc
parent1cdc3dbc58923f66758b9b718175db2e41e80b0d
FuncUnwinders: remove "current_offset" from function arguments

Summary:
This argument was added back in 2010 (r118882) to support the ability to unwind
from functions whose eh_frame entry does not cover the entire range of
the function.

However, due to the caching happening in FuncUnwinders, this solution is
very fragile. FuncUnwinders will cache the plan it got from eh_frame
regardless of the value of the current_offset, so our ability to unwind
from a given function depended what was the value of "current_offset" the
first time that this function was called.

Furthermore, since the "image show-unwind" command did not know what's
the right offset to pass, this created an unfortunate situation where
"image show-unwind" would show no valid plans for a function, even
though they were available and being used.

In this patch I implement the feature slightly differently. Instead of
giving just a base address to the eh_frame unwinder, I give it the
entire range we are interested in. Then, I change the unwinder to return
the first plan that covers (even partially) that range. This way even a
partial plan will be returned, regardless of the address in the function
where we are stopped at.

This solution is still not 100% correct, as it will not handle a
function which is covered by two independent fde entries. However, I
don't expect anybody will write this kind of functions, and this wasn't
handled by the previous implementation either. If this is ever needed in
the future. The eh_frame unwinder can be extended to return "composite"
unwind plans created by merging sevelar fde entries.

I also create a test which triggers this scenario. As doing this is
virtually impossible without hand-written assembly, the test only works
on x86 linux.

Reviewers: jasonmolenda, clayborg

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D60829

llvm-svn: 358964
lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
lldb/include/lldb/Symbol/FuncUnwinders.h
lldb/include/lldb/Utility/RangeMap.h
lldb/lit/Unwind/Inputs/eh-frame-small-fde.s [new file with mode: 0644]
lldb/lit/Unwind/eh-frame-small-fde.test [new file with mode: 0644]
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
lldb/source/Symbol/DWARFCallFrameInfo.cpp
lldb/source/Symbol/FuncUnwinders.cpp