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
19// Project includes
20#include "lldb/lldb-private.h"
21#include "lldb/Target/Unwind.h"
22
23class UnwindMacOSXFrameBackchain : public lldb_private::Unwind
24{
25public:
26    UnwindMacOSXFrameBackchain (lldb_private::Thread &thread);
27
28    virtual
29    ~UnwindMacOSXFrameBackchain()
30    {
31    }
32
33protected:
34    virtual void
35    DoClear()
36    {
37        m_cursors.clear();
38    }
39
40    virtual uint32_t
41    DoGetFrameCount();
42
43    bool
44    DoGetFrameInfoAtIndex (uint32_t frame_idx,
45                         lldb::addr_t& cfa,
46                         lldb::addr_t& pc);
47
48    lldb::RegisterContextSP
49    DoCreateRegisterContextForFrame (lldb_private::StackFrame *frame);
50
51    friend class RegisterContextMacOSXFrameBackchain;
52
53    struct Cursor
54    {
55        lldb::addr_t pc;    // Program counter
56        lldb::addr_t fp;    // Frame pointer for us with backchain
57    };
58
59private:
60    std::vector<Cursor> m_cursors;
61
62    size_t
63    GetStackFrameData_i386 (const lldb_private::ExecutionContext &exe_ctx);
64
65    size_t
66    GetStackFrameData_x86_64 (const lldb_private::ExecutionContext &exe_ctx);
67
68    //------------------------------------------------------------------
69    // For UnwindMacOSXFrameBackchain only
70    //------------------------------------------------------------------
71    DISALLOW_COPY_AND_ASSIGN (UnwindMacOSXFrameBackchain);
72};
73
74#endif  // lldb_UnwindMacOSXFrameBackchain_h_
75