Author: tberghammer
Date: Fri Jul  3 04:30:22 2015
New Revision: 241334

URL: http://llvm.org/viewvc/llvm-project?rev=241334&view=rev
Log:
Enable usage of eh_frame based unwind plan as a fallback

Previously if the instruction emulation based unwind plan failed then
we fall back to the arch default unwind plan. Change it to fall back
to the eh_frame based one even on non call sites if we have eh_frame
as that one tend to be more reliable.

Differential revision: http://reviews.llvm.org/D10902

Modified:
    lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=241334&r1=241333&r2=241334&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Fri Jul  
3 04:30:22 2015
@@ -855,12 +855,26 @@ RegisterContextLLDB::GetFullUnwindPlanFo
         {
             if (unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolNo)
             {
-                // We probably have an UnwindPlan created by inspecting 
assembly instructions, and we probably
-                // don't have any eh_frame instructions available.
-                // The assembly profilers work really well with 
compiler-generated functions but hand-written
-                // assembly can be problematic.  We'll set the architecture 
default UnwindPlan as our fallback
-                // UnwindPlan in case this doesn't work out when we try to 
unwind.
-                m_fallback_unwind_plan_sp = arch_default_unwind_plan_sp;
+                // We probably have an UnwindPlan created by inspecting 
assembly instructions. The
+                // assembly profilers work really well with compiler-generated 
functions but hand-
+                // written assembly can be problematic. We set the eh_frame 
based unwind plan as our
+                // fallback unwind plan if instruction emulation doesn't work 
out even for non call
+                // sites if it is available and use the architecture default 
unwind plan if it is
+                // not available. The eh_frame unwind plan is more reliable 
even on non call sites
+                // then the architecture default plan and for hand written 
assembly code it is often
+                // written in a way that it valid at all location what helps 
in the most common
+                // cases when the instruction emulation fails.
+                UnwindPlanSP eh_frame_unwind_plan = 
func_unwinders_sp->GetEHFrameUnwindPlan (process->GetTarget(), 
m_current_offset_backed_up_one);
+                if (eh_frame_unwind_plan &&
+                    eh_frame_unwind_plan.get() != unwind_plan_sp.get() &&
+                    eh_frame_unwind_plan->GetSourceName() != 
unwind_plan_sp->GetSourceName())
+                {
+                    m_fallback_unwind_plan_sp = eh_frame_unwind_plan;
+                }
+                else
+                {
+                    m_fallback_unwind_plan_sp = arch_default_unwind_plan_sp;
+                }
             }
             UnwindLogMsgVerbose ("frame uses %s for full UnwindPlan", 
unwind_plan_sp->GetSourceName().GetCString());
             return unwind_plan_sp;
@@ -887,12 +901,25 @@ RegisterContextLLDB::GetFullUnwindPlanFo
     }
     if (unwind_plan_sp && unwind_plan_sp->GetSourcedFromCompiler() == 
eLazyBoolNo)
     {
-        // We probably have an UnwindPlan created by inspecting assembly 
instructions, and we probably
-        // don't have any eh_frame instructions available.
-        // The assembly profilers work really well with compiler-generated 
functions but hand-written
-        // assembly can be problematic.  We'll set the architecture default 
UnwindPlan as our fallback
-        // UnwindPlan in case this doesn't work out when we try to unwind.
-        m_fallback_unwind_plan_sp = arch_default_unwind_plan_sp;
+        // We probably have an UnwindPlan created by inspecting assembly 
instructions. The assembly
+        // profilers work really well with compiler-generated functions but 
hand- written assembly
+        // can be problematic. We set the eh_frame based unwind plan as our 
fallback unwind plan if
+        // instruction emulation doesn't work out even for non call sites if 
it is available and use
+        // the architecture default unwind plan if it is not available. The 
eh_frame unwind plan is
+        // more reliable even on non call sites then the architecture default 
plan and for hand
+        // written assembly code it is often written in a way that it valid at 
all location what
+        // helps in the most common cases when the instruction emulation fails.
+        UnwindPlanSP eh_frame_unwind_plan = 
func_unwinders_sp->GetEHFrameUnwindPlan (process->GetTarget(), 
m_current_offset_backed_up_one);
+        if (eh_frame_unwind_plan &&
+            eh_frame_unwind_plan.get() != unwind_plan_sp.get() &&
+            eh_frame_unwind_plan->GetSourceName() != 
unwind_plan_sp->GetSourceName())
+        {
+            m_fallback_unwind_plan_sp = eh_frame_unwind_plan;
+        }
+        else
+        {
+            m_fallback_unwind_plan_sp = arch_default_unwind_plan_sp;
+        }
     }
 
     if (IsUnwindPlanValidForCurrentPC(unwind_plan_sp, valid_offset))


_______________________________________________
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to