1 //===-- UnwindMacOSXFrameBackchain.h ----------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef lldb_UnwindMacOSXFrameBackchain_h_
11 #define lldb_UnwindMacOSXFrameBackchain_h_
12 
13 // C Includes
14 // C++ Includes
15 #include <vector>
16 
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/lldb-private.h"
20 #include "lldb/Target/Unwind.h"
21 
22 class UnwindMacOSXFrameBackchain : public lldb_private::Unwind
23 {
24 public:
25     UnwindMacOSXFrameBackchain (lldb_private::Thread &thread);
26 
27     ~UnwindMacOSXFrameBackchain() override = default;
28 
29 protected:
30     void
31     DoClear() override
32     {
33         m_cursors.clear();
34     }
35 
36     uint32_t
37     DoGetFrameCount() override;
38 
39     bool
40     DoGetFrameInfoAtIndex(uint32_t frame_idx,
41                           lldb::addr_t& cfa,
42                           lldb::addr_t& pc) override;
43 
44     lldb::RegisterContextSP
45     DoCreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
46 
47     friend class RegisterContextMacOSXFrameBackchain;
48 
49     struct Cursor
50     {
51         lldb::addr_t pc;    // Program counter
52         lldb::addr_t fp;    // Frame pointer for us with backchain
53     };
54 
55 private:
56     std::vector<Cursor> m_cursors;
57 
58     size_t
59     GetStackFrameData_i386 (const lldb_private::ExecutionContext &exe_ctx);
60 
61     size_t
62     GetStackFrameData_x86_64 (const lldb_private::ExecutionContext &exe_ctx);
63 
64     //------------------------------------------------------------------
65     // For UnwindMacOSXFrameBackchain only
66     //------------------------------------------------------------------
67     DISALLOW_COPY_AND_ASSIGN (UnwindMacOSXFrameBackchain);
68 };
69 
70 #endif // lldb_UnwindMacOSXFrameBackchain_h_
71