[Lldb-commits] [PATCH] D124492: Update CFA to be in terms of $sp instead of $fp when $fp is overwritten in epilogue on AArch64

Jason Molenda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 26 17:46:54 PDT 2022


jasonmolenda created this revision.
jasonmolenda added reviewers: jingham, JDevlieghere.
jasonmolenda added a project: LLDB.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
jasonmolenda requested review of this revision.
Herald added a subscriber: lldb-commits.

When we can the instructions of an AArch64 to create an unwind plan, and we see an instruction to add a value to $fp and assign it to $sp, lldb recognizes this as meaning that CFA is now set in terms of $sp. e.g.

28: 0xd10043bf   sub    sp, x29, #0x10
32: 0xa9417bfd   ldp    x29, x30, [sp, #0x10]

This is a common method used in clang codegen.  But clang will sometimes overwrite $fp by restoring it from the stack, to the caller's $fp value.  At this point, lldb is still expressing the CFA in terms of $fp but $fp is now the caller's $fp and our CFA value changes, which can confuse the stepper algorithms.

This change recognizes the restoring of $fp to mean the CFA should switch back to $sp.  e.g.

12: 0xa9417bfd ldp x29, x30, [sp, #0x10]
16: 0x910083ff add sp, sp, #0x20

Backtraces are not impacted; we get all of the register values correct, but because the CFA changes, stepping algorithms can get confused and stop in the middle of the epilogue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124492

Files:
  lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
  lldb/test/API/symbol_ondemand/shared_library/TestSharedLib.py
  lldb/unittests/UnwindAssembly/ARM64/TestArm64InstEmulation.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124492.425369.patch
Type: text/x-patch
Size: 10537 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220427/0b5be759/attachment-0001.bin>


More information about the lldb-commits mailing list