[Lldb-commits] [PATCH] D96839: Add a callout to the LanguageRuntime to override the normal UnwindPlan used for a frame

Jason Molenda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 16 22:55:01 PST 2021


jasonmolenda created this revision.
jasonmolenda added a reviewer: jasonmolenda.
jasonmolenda added a project: LLDB.
Herald added a subscriber: JDevlieghere.
jasonmolenda requested review of this revision.

Swift is gaining asynchronous functions, which may not be executing when a function they call is executing.  In the backtrace, we want to show the logical caller of this currently-executing function even though it is not present on the stack like a real frame.  The LanguageRuntime can provide an UnwindPlan that will provide that function.

When the async function is actually executing, we'll use its normal UnwindPlans.  But when it is not executing, we'll use the LanguageRuntime's UnwindPlan to show it in the stack.

The way this is actually implemented by the swift runtime is that the stack has a chain of these async-not-running functions and pointers to a data block with saved context for them, and as we walk the chain we will get back to real stack functions again.  The swift language runtime uses a flag in the spilled fp register to tell when it should provide its special unwind plan.

This patch adds code to LanguageRuntime to see if any LanguageRuntime plugins can provide an UnwindPlan given a RegisterContext.  It adds code to RegisterContextUnwind to see if the LanguageRuntime can provide an UnwindPlan before we start looking at the function's normal UnwindPlans, and uses the async unwind plan if it was provided.  Pretty simple hooks out to the LanguageRuntime where the details are encapsulated.

Without interjecting a LanguageRuntime plugin in a live debug session, this isn't testable in standard lldb; in the swift branch of lldb I can have an API test that has some async calls on the stack and do a stack walk.  But I need the LanguageRuntimeSwift support for one of these to get that to work.

Open to any comments or suggestions, not sure if anyone is really into the unwinder enough to spend time reviewing it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96839

Files:
  lldb/include/lldb/Target/LanguageRuntime.h
  lldb/source/Target/LanguageRuntime.cpp
  lldb/source/Target/RegisterContextUnwind.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96839.324191.patch
Type: text/x-patch
Size: 6292 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210217/2c763d03/attachment.bin>


More information about the lldb-commits mailing list