[Lldb-commits] [PATCH] D75007: When unwinding out of a trap handler, fetch the saved pc even if there's a return address register defined

Jason Molenda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 21 19:38:16 PST 2020


jasonmolenda created this revision.
jasonmolenda added a project: LLDB.
Herald added a subscriber: kristof.beyls.

On targets with a return address register (e.g. $lr on arm), when the unwinder is asked to fetch the caller's pc, we rewrite that to fetch the return address value.

However, when we're in a trap handler -- either from an interrupt or an async signal -- we will have a full register context for the frame that was interrupted/trapped.  The unwinder correctly allows you to fetch volatile registers when you're above a trap handler.  But we are still rewriting the "fetch the pc" request when the trap handler is asked to find the caller's saved pc.  This is incorrect, and results in lldb showing the wrong function that was interrupted/faulted.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75007

Files:
  lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp


Index: lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
===================================================================
--- lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -1203,9 +1203,13 @@
       // If we're fetching the saved pc and this UnwindPlan defines a
       // ReturnAddress register (e.g. lr on arm), look for the return address
       // register number in the UnwindPlan's row.
+      // If this is a trap handler frame, we have access to the complete
+      // register context when the interrupt/async signal was received, so
+      // we need to fetch the actual saved $pc value.
       if (pc_regnum.IsValid() && pc_regnum == regnum &&
           m_full_unwind_plan_sp->GetReturnAddressRegister() !=
-              LLDB_INVALID_REGNUM) {
+              LLDB_INVALID_REGNUM &&
+          m_frame_type != eTrapHandlerFrame) {
 
         return_address_reg.init(
             m_thread, m_full_unwind_plan_sp->GetRegisterKind(),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75007.246056.patch
Type: text/x-patch
Size: 1038 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200222/b04a8b7c/attachment.bin>


More information about the lldb-commits mailing list