Check in the native lldb unwinder.  

Not yet enabled as the default unwinder but there are no known
backtrace problems with the code at this point.

Added 'log enable lldb unwind' to help diagnose backtrace problems;
this output needs a little refining but it's a good first step.

eh_frame information is currently read unconditionally - the code
is structured to allow this to be delayed until it's actually needed.
There is a performance hit when you have to parse the eh_frame
information for any largeish executable/library so it's necessary
to avoid if possible.

It's confusing having both the UnwindPlan::RegisterLocation struct
and the RegisterConextLLDB::RegisterLocation struct, I need to rename
one of them.

The writing of registers isn't done in the RegisterConextLLDB subclass
yet; neither is the running of complex DWARF expressions from eh_frame
(e.g. used for _sigtramp on Mac OS X).



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@117256 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Symbol/UnwindPlan.cpp b/source/Symbol/UnwindPlan.cpp
index cc4dcf2..6f370de 100644
--- a/source/Symbol/UnwindPlan.cpp
+++ b/source/Symbol/UnwindPlan.cpp
@@ -11,6 +11,7 @@
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Thread.h"
+#include "lldb/Core/ConstString.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -220,6 +221,10 @@
 UnwindPlan::GetRowForFunctionOffset (int offset) const
 {
     const UnwindPlan::Row *rowp = NULL;
+    if (offset == -1 && m_row_list.size() > 0)
+    {
+        return &m_row_list[m_row_list.size() - 1];
+    }
     for (int i = 0; i < m_row_list.size(); ++i)
     {
         if (m_row_list[i].GetOffset() <= offset)
@@ -268,7 +273,10 @@
 void
 UnwindPlan::SetPlanValidAddressRange (const AddressRange& range)
 {
-   m_plan_valid_address_range = range;
+   if (range.GetBaseAddress().IsValid() && range.GetByteSize() != 0)
+   {
+       m_plan_valid_address_range = range;
+   }
 // .GetBaseAddress() = addr;
 //    m_plan_valid_address_range.SetByteSize (range.GetByteSize());
 }
@@ -276,7 +284,7 @@
 bool
 UnwindPlan::PlanValidAtAddress (Address addr)
 {
-    if (!m_plan_valid_address_range.GetBaseAddress().IsValid())
+    if (!m_plan_valid_address_range.GetBaseAddress().IsValid() || m_plan_valid_address_range.GetByteSize() == 0)
         return true;
 
     if (m_plan_valid_address_range.ContainsFileAddress (addr))
@@ -288,9 +296,20 @@
 void
 UnwindPlan::Dump (Stream& s, Thread *thread) const
 {
-    s.Printf ("Address range of this UnwindPlan: ");
-    m_plan_valid_address_range.Dump (&s, &thread->GetProcess().GetTarget(), Address::DumpStyleSectionNameOffset);
-    s.Printf ("\n");
+    if (!m_source_name.IsEmpty())
+    {
+        s.Printf ("This UnwindPlan originally sourced from %s\n", m_source_name.GetCString());
+    }
+    if (m_plan_valid_address_range.GetBaseAddress().IsValid() && m_plan_valid_address_range.GetByteSize() > 0)
+    {
+        s.Printf ("Address range of this UnwindPlan: ");
+        m_plan_valid_address_range.Dump (&s, &thread->GetProcess().GetTarget(), Address::DumpStyleSectionNameOffset);
+        s.Printf ("\n");
+    }
+    else
+    {
+        s.Printf ("No valid address range recorded for this UnwindPlan.\n");
+    }
     s.Printf ("UnwindPlan register kind %d", m_register_kind);
     switch (m_register_kind)
     {
@@ -308,3 +327,15 @@
         m_row_list[i].Dump(s, m_register_kind, thread);
     }
 }
+
+void
+UnwindPlan::SetSourceName (const char *source)
+{
+    m_source_name = ConstString (source);
+}
+
+ConstString
+UnwindPlan::GetSourceName () const
+{
+    return m_source_name;
+}