[Lldb-commits] [PATCH] D124198: [LLDB][Unwind] Add stack scanning as fallback unwind plan if no symbol file is available.

Zequan Wu via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 28 17:04:20 PDT 2022

zequanwu added inline comments.

Comment at: lldb/include/lldb/Symbol/UnwindPlan.h:225
+          // Not the first search.
+          m_value.ra_search.search_offset |= 1;
+        }
clayborg wrote:
> What is this magic number/bit here? Is it ok to clobber bit zero here?
When the last bit isn't set, it's the first ra search. 

The reason why we want to know this info is because after we got cfa via stack scanning in `TryFallbackUnwindPlan` when initializing zeroth/nonzeroth frames in `RegisterContextUnwind`, we will use that cfa for unwind next frame. If the next frame is valid, we are done. Otherwise, we get the incorrect cfa for the parent frame. Then we need to redo the stack scanning to find parent frame's cfa (`UnwindLLDB::GetOneMoreFrame`) but should skip the region that we have already scanned. So, the search_offset tells how many bytes should we skip. 

Comment at: lldb/include/lldb/Symbol/UnwindPlan.h:266
+      int32_t GetRaSearchOffset() const {
+        return m_type == isRaSearch ? m_value.ra_search.search_offset & ~1 : 0;
+      }
clayborg wrote:
> Are we assuming "search_offset" must be aligned to at least a 4 bit boundary so that we can put something in bit zero?
search_offset is usually the multiple of 4 or 8, so we can use the last bit.

Comment at: lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp:734
+bool ABIWindows_x86_64::CreateStackWalkingUnwindPlan(UnwindPlan &unwind_plan) {
+  unwind_plan.Clear();
clayborg wrote:
> What code actually does the search for a return address? Is that already available somewhere in the unwind plans? Reading through this plan I see that it sets the CFA to be RA search but I fail to see any searching going on.
This sets the unwind plan row to be ra search. The actual ra search happens on `RegisterContextUnwind::ReadFrameAddress` at the case `UnwindPlan::Row::FAValue::isRaSearch`.

  rG LLVM Github Monorepo



More information about the lldb-commits mailing list