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/Plugins/Process/Utility/UnwindLLDB.h b/source/Plugins/Process/Utility/UnwindLLDB.h
new file mode 100644
index 0000000..5c12117
--- /dev/null
+++ b/source/Plugins/Process/Utility/UnwindLLDB.h
@@ -0,0 +1,70 @@
+//===-- UnwindLLDB.h --------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef lldb_UnwindLLDB_h_
+#define lldb_UnwindLLDB_h_
+
+#include "lldb/lldb-private.h"
+#include "lldb/Target/Unwind.h"
+#include "lldb/Symbol/FuncUnwinders.h"
+#include "lldb/Symbol/UnwindPlan.h"
+#include "RegisterContextLLDB.h"
+#include "lldb/Target/RegisterContext.h"
+#include <vector>
+
+
+namespace lldb_private {
+
+class UnwindLLDB : public lldb_private::Unwind
+{
+public: 
+    UnwindLLDB (lldb_private::Thread &thread);
+    
+    virtual
+    ~UnwindLLDB() { }
+    
+    void
+    Clear()
+    {
+        m_frames.clear();
+    }
+
+    virtual uint32_t
+    GetFrameCount();
+
+    bool
+    GetFrameInfoAtIndex (uint32_t frame_idx,
+                         lldb::addr_t& cfa, 
+                         lldb::addr_t& start_pc);
+    
+    lldb_private::RegisterContext *
+    CreateRegisterContextForFrame (lldb_private::StackFrame *frame);
+
+private:
+    struct Cursor
+    {
+        lldb::addr_t start_pc;  // The start address of the function/symbol for this frame - current pc if unknown
+        lldb::addr_t cfa;       // The canonical frame address for this stack frame
+        lldb_private::SymbolContext sctx;  // A symbol context we'll contribute to & provide to the StackFrame creation
+        lldb::RegisterContextSP reg_ctx; // These are all RegisterContextLLDB's
+
+        Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx() { }
+    };
+
+    std::vector<Cursor> m_frames;
+
+    //------------------------------------------------------------------
+    // For UnwindLLDB only
+    //------------------------------------------------------------------
+    DISALLOW_COPY_AND_ASSIGN (UnwindLLDB);
+};
+
+}
+
+#endif  // lldb_UnwindLLDB_h_